学习使用Archetype构建OpenDaylight项目

用命令 mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=http://nexus.opendaylight.org/content/repositories/opendaylight.release -DarchetypeCatalog=remote -DarchetypeVersion=1.3.4-Carbon

创建项目时,archetype各字段的填写请查看:

https://nexus.opendaylight.org/content/repositories/opendaylight.release/archetype-catalog.xml

主要参考: 

https://www.cnblogs.com/FrankZhou2017/p/7235167.html

https://www.cnblogs.com/FrankZhou2017/p/7236035.html

https://www.cnblogs.com/FrankZhou2017/p/7246946.html

https://www.cnblogs.com/FrankZhou2017/p/7251168.html

https://www.sdnlab.com/17863.html

 

最终我的记录过程如下:

root@odl_ubuntu:/home# mkdir test

root@odl_ubuntu:/home# cd test

root@odl_ubuntu:/home/test# mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=https://nexus.opendaylight.org/content/repositories/opendaylight.release/ -DarchetypeCatalog=remote -DarchetypeVersion=1.3.4-Carbon

......

Define value for property 'groupId': org.opendaylight.example
Define value for property 'artifactId': example
[INFO] Using property: version = 0.1.0-SNAPSHOT
Define value for property 'package' org.opendaylight.example: :
Define value for property 'classPrefix' Example: : Example
Define value for property 'copyright': No
[INFO] Using property: copyrightYear = 2017
Confirm properties configuration:
groupId: org.opendaylight.example
artifactId: example
version: 0.1.0-SNAPSHOT
package: org.opendaylight.example
classPrefix: Example
copyright: No
copyrightYear: 2017
 Y: : Y

[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: opendaylight-startup-archetype:1.3.4-Carbon
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.opendaylight.example
[INFO] Parameter: artifactId, Value: example
[INFO] Parameter: version, Value: 0.1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.opendaylight.example
[INFO] Parameter: packageInPathFormat, Value: org/opendaylight/example
[INFO] Parameter: classPrefix, Value: Example
[INFO] Parameter: package, Value: org.opendaylight.example
[INFO] Parameter: version, Value: 0.1.0-SNAPSHOT
[INFO] Parameter: copyright, Value: No
[INFO] Parameter: groupId, Value: org.opendaylight.example
[INFO] Parameter: artifactId, Value: example
[INFO] Parameter: copyrightYear, Value: 2017
[WARNING] Don't override file /home/test/example/pom.xml
[INFO] Project created from Archetype in dir: /home/test/example
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  21:06 min
[INFO] Finished at: 2018-11-23T07:15:43-08:00
[INFO] ------------------------------------------------------------------------

root@odl_ubuntu:/home/test/example# mvn clean install -Dmaven.test.failure.ignore=true

 首次编译可能会失败,因为缺少依赖库odlparent,所以:

(后来又另外测试了一个新工程hello,发现编译命令加一个不进行测试,就能通过,不需要下载编译odlparent:

mvn clean install -Dmaven.test.failure.ignore=true -DskipTests

root@odl_ubuntu:/home/test# git clone https://git.opendaylight.org/gerrit/p/odlparent.git

root@odl_ubuntu:/home/test/odlparent# git checkout stable/carbon

root@odl_ubuntu:/home/test/odlparent# mvn clean install -DskipTests

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] ODL :: odlparent :: odlparent-lite 1.8.5-SNAPSHOT .. SUCCESS [  6.725 s]
[INFO] ODL :: odlparent :: checkstyle 0.3.5-SNAPSHOT ...... SUCCESS [ 18.359 s]
[INFO] ODL :: odlparent :: findbugs 1.8.5-SNAPSHOT ........ SUCCESS [ 11.148 s]
[INFO] ODL :: odlparent :: odl-license 0.2.5-SNAPSHOT ..... SUCCESS [  5.883 s]
[INFO] ODL :: odlparent :: odlparent 1.8.5-SNAPSHOT ....... SUCCESS [  9.255 s]
[INFO] ODL :: odlparent :: bundle-parent 1.8.5-SNAPSHOT ... SUCCESS [  8.566 s]
[INFO] ODL :: odlparent :: bundles-test 1.8.5-SNAPSHOT .... SUCCESS [ 50.904 s]
[INFO] ODL :: odlparent :: bundles4-test 1.8.5-SNAPSHOT ... SUCCESS [ 55.104 s]
[INFO] ODL :: odlparent :: features-test 1.8.5-SNAPSHOT ... SUCCESS [ 23.439 s]
[INFO] ODL :: odlparent :: features4-test 1.8.5-SNAPSHOT .. SUCCESS [ 30.595 s]
[INFO] OpenDaylight :: Karaf :: Branding 1.8.5-SNAPSHOT ... SUCCESS [ 10.004 s]
[INFO] ODL :: odlparent :: opendaylight-karaf-resources 1.8.5-SNAPSHOT SUCCESS [ 15.257 s]
[INFO] ODL :: odlparent :: karaf-plugin 1.8.5-SNAPSHOT .... SUCCESS [ 36.373 s]
[INFO] ODL :: odlparent :: karaf-parent 1.8.5-SNAPSHOT .... SUCCESS [ 17.478 s]
[INFO] ODL :: odlparent :: opendaylight-karaf-empty 1.8.5-SNAPSHOT SUCCESS [ 33.860 s]
[INFO] ODL :: odlparent :: opendaylight-karaf4-resources 1.8.5-SNAPSHOT SUCCESS [ 13.070 s]
[INFO] ODL :: odlparent :: karaf4-plugin 1.8.5-SNAPSHOT ... SUCCESS [ 25.810 s]
[INFO] ODL :: odlparent :: karaf4-parent 1.8.5-SNAPSHOT ... SUCCESS [ 16.284 s]
[INFO] ODL :: odlparent :: opendaylight-karaf4-empty 1.8.5-SNAPSHOT SUCCESS [ 11.317 s]
[INFO] ODL :: odlparent :: karaf-aggregator 1.8.5-SNAPSHOT  SUCCESS [  4.693 s]
[INFO] ODL :: odlparent :: features-parent 1.8.5-SNAPSHOT . SUCCESS [ 18.143 s]
[INFO] ODL :: odlparent :: single-feature3-parent 1.8.5-SNAPSHOT SUCCESS [  2.232 s]
[INFO] ODL :: odlparent :: untested-single-feature-parent 1.8.5-SNAPSHOT SUCCESS [  7.299 s]
[INFO] ODL :: odlparent :: single-feature-parent 1.8.5-SNAPSHOT SUCCESS [  2.673 s]
[INFO] ODL :: odlparent :: feature3-repo-parent 1.8.5-SNAPSHOT SUCCESS [  2.152 s]
[INFO] ODL :: odlparent :: feature-repo-parent 1.8.5-SNAPSHOT SUCCESS [  2.047 s]
[INFO] Scala Runtime for OpenDaylight 1.8.5-SNAPSHOT ...... SUCCESS [ 12.624 s]
[INFO] Akka Actor Framework System Bundles 1.8.5-SNAPSHOT . SUCCESS [ 10.417 s]
[INFO] Akka Clustering 1.8.5-SNAPSHOT ..................... SUCCESS [  9.042 s]
[INFO] LevelDB 1.8.5-SNAPSHOT ............................. SUCCESS [ 13.690 s]
[INFO] Akka Persistence 1.8.5-SNAPSHOT .................... SUCCESS [  8.373 s]
[INFO] OpenDaylight :: Akka :: All 1.8.5-SNAPSHOT ......... SUCCESS [  8.239 s]
[INFO] ODL :: odlparent :: features-akka 1.8.5-SNAPSHOT ... SUCCESS [ 13.350 s]
[INFO] OpenDaylight :: Netty 1.8.5-SNAPSHOT ............... SUCCESS [  8.548 s]
[INFO] OpenDaylight :: Guava 18 1.8.5-SNAPSHOT ............ SUCCESS [  8.183 s]
[INFO] OpenDaylight :: Guava 21 1.8.5-SNAPSHOT ............ SUCCESS [  8.607 s]
[INFO] OpenDaylight :: LMAX Disruptor 1.8.5-SNAPSHOT ...... SUCCESS [  8.361 s]
[INFO] OpenDaylight :: Concurrent Trie HashMap 1.8.5-SNAPSHOT SUCCESS [  8.356 s]
[INFO] ODL :: odlparent :: features-odlparent 1.8.5-SNAPSHOT SUCCESS [  8.478 s]
[INFO] ODL :: odlparent :: features-aggregator 1.8.5-SNAPSHOT SUCCESS [  1.061 s]
[INFO] Scala Runtime for OpenDaylight (for Karaf 4) 1.8.5-SNAPSHOT SUCCESS [  9.803 s]
[INFO] Akka Actor Framework System Bundles (for Karaf 4) 1.8.5-SNAPSHOT SUCCESS [  8.904 s]
[INFO] Akka Clustering (for Karaf 4) 1.8.5-SNAPSHOT ....... SUCCESS [  8.577 s]
[INFO] LevelDB (for Karaf 4) 1.8.5-SNAPSHOT ............... SUCCESS [  8.363 s]
[INFO] Akka Persistence (for Karaf 4) 1.8.5-SNAPSHOT ...... SUCCESS [  8.346 s]
[INFO] OpenDaylight :: Akka :: All (for Karaf 4) 1.8.5-SNAPSHOT SUCCESS [  8.408 s]
[INFO] ODL :: odlparent :: features4-akka 1.8.5-SNAPSHOT .. SUCCESS [  8.298 s]
[INFO] ODL :: odlparent :: odl-karaf-feat-feature 1.8.5-SNAPSHOT SUCCESS [ 16.242 s]
[INFO] ODL :: odlparent :: odl-karaf-feat-jdbc 1.8.5-SNAPSHOT SUCCESS [  9.978 s]
[INFO] ODL :: odlparent :: odl-karaf-feat-jetty 1.8.5-SNAPSHOT SUCCESS [  9.968 s]
[INFO] ODL :: odlparent :: odl-karaf-feat-war 1.8.5-SNAPSHOT SUCCESS [ 10.842 s]
[INFO] OpenDaylight :: Netty (for Karaf 4) 1.8.5-SNAPSHOT . SUCCESS [  8.500 s]
[INFO] OpenDaylight :: Guava 18 (for Karaf 4) 1.8.5-SNAPSHOT SUCCESS [  8.296 s]
[INFO] OpenDaylight :: Guava 21 (for Karaf 4) 1.8.5-SNAPSHOT SUCCESS [  9.199 s]
[INFO] OpenDaylight :: LMAX Disruptor (for Karaf 4) 1.8.5-SNAPSHOT SUCCESS [  8.189 s]
[INFO] OpenDaylight :: Concurrent Trie HashMap (for Karaf 4) 1.8.5-SNAPSHOT SUCCESS [ 13.286 s]
[INFO] ODL :: odlparent :: features4-odlparent 1.8.5-SNAPSHOT SUCCESS [  8.609 s]
[INFO] ODL :: odlparent :: features4-aggregator 1.8.5-SNAPSHOT SUCCESS [  1.281 s]
[INFO] ODL :: odlparent :: odlparent-artifacts 1.8.5-SNAPSHOT SUCCESS [  0.407 s]
[INFO] odlparent 1.8.5-SNAPSHOT ........................... SUCCESS [04:52 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  17:12 min
[INFO] Finished at: 2018-11-23T20:00:10-08:00
[INFO] ------------------------------------------------------------------------

然后再回来:

root@odl_ubuntu:/home/test/example# mvn clean install -Dmaven.test.failure.ignore=true

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for example 0.1.0-SNAPSHOT:
[INFO]
[INFO] ODL :: org.opendaylight.example :: example-api ..... SUCCESS [ 32.200 s]
[INFO] ODL :: org.opendaylight.example :: example-impl .... SUCCESS [ 17.291 s]
[INFO] ODL :: org.opendaylight.example :: example-cli ..... SUCCESS [ 17.128 s]
[INFO] ODL :: org.opendaylight.example :: example-features  SUCCESS [  01:07 h]
[INFO] ODL :: org.opendaylight.example :: example-karaf ... SUCCESS [01:32 min]
[INFO] ODL :: org.opendaylight.example :: example-artifacts SUCCESS [  2.697 s]
[INFO] ODL :: org.opendaylight.example :: example-it ...... SUCCESS [01:14 min]
[INFO] example ............................................ SUCCESS [ 29.911 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:11 h
[INFO] Finished at: 2018-11-24T00:01:52-08:00
[INFO] ------------------------------------------------------------------------

root@odl_ubuntu:/home/test/example/karaf/target/assembly/etc# vim org.apache.karaf.management.cfg

rmiRegistryHost=127.0.0.1

rmiServerHost=127.0.0.1

现在可以验证Example是否加载成功:

root@odl_ubuntu:/home/test/example/karaf/target/assembly/bin# ./karaf

100% [========================================================================]
Karaf started in 80s. Bundle stats: 295 active, 295 total
    ________                       ________                .__  .__       .__     __
    \_____  \ ______   ____   ____ \______ \ _____  ___.__.|  | |__| ____ |  |___/  |_
     /   |   \\____ \_/ __ \ /    \ |    |  \\__  \<   |  ||  | |  |/ ___\|  |  \   __\
    /    |    \  |_> >  ___/|   |  \|    `   \/ __ \\___  ||  |_|  / /_/  >   Y  \  |
    \_______  /   __/ \___  >___|  /_______  (____  / ____||____/__\___  /|___|  /__|
            \/|__|        \/     \/        \/     \/\/            /_____/      \/

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown OpenDaylight.
opendaylight-user@root>log:display | grep Example
2018-11-24 04:51:14,190 | INFO  | rint Extender: 2 | ExampleProvider                  | 208 - org.opendaylight.example.impl - 0.1.0.SNAPSHOT | ExampleProvider Session Initiated
 
posted @ 2018-11-21 10:50  鸟瞰的鸟  阅读(567)  评论(0编辑  收藏  举报