1. 程式人生 > >我的第一個OpenDaylight工程

我的第一個OpenDaylight工程

1。從https://raw.githubusercontent.com/opendaylight/odlparent/stable/carbon/settings.xml下載此檔案或拷貝此檔案內容,替換

[email protected]_ubuntu:/etc/maven#

目錄下的同名檔案。

2。用如下Maven命令生成專案骨架:

[email protected]_ubuntu:/home/myodl# mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=https://nexus.opendaylight.org/content/repositories/public -DarchetypeVersion=1.3.2-Carbon

生成過程中在如下位置輸入如下黑體內容:

Define value for property 'groupId': : org.opendaylight.topology
Define value for property 'artifactId': : topology
[INFO] Using property: version = 0.1.0-SNAPSHOT
Define value for property 'package': org.opendaylight.topology: :
Nov 16, 2018 12:54:38 AM org.apache.velocity.runtime.log.JdkLogChute log


INFO: FileResourceLoader : adding path '.'
Define value for property 'classPrefix': Topology: :
Define value for property 'copyright': : ZebraDecoder
[INFO] Using property: copyrightYear = 2017
Confirm properties configuration:
groupId: org.opendaylight.topology
artifactId: topology
version: 0.1.0-SNAPSHOT
package: org.opendaylight.topology

classPrefix: Topology
copyright: ZebraDecoder
copyrightYear: 2017
Y: : Y

專案骨架建立完成後提示如下:

[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: opendaylight-startup-archetype:1.3.2-Carbon
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.opendaylight.topology
[INFO] Parameter: artifactId, Value: topology
[INFO] Parameter: version, Value: 0.1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.opendaylight.topology
[INFO] Parameter: packageInPathFormat, Value: org/opendaylight/topology
[INFO] Parameter: classPrefix, Value: Topology
[INFO] Parameter: package, Value: org.opendaylight.topology
[INFO] Parameter: version, Value: 0.1.0-SNAPSHOT
[INFO] Parameter: copyright, Value: ZebraDecoder
[INFO] Parameter: groupId, Value: org.opendaylight.topology
[INFO] Parameter: artifactId, Value: topology
[INFO] Parameter: copyrightYear, Value: 2017
[WARNING] Don't override file /home/myodl/topology/pom.xml
[INFO] project created from Archetype in dir: /home/myodl/topology
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:27 min
[INFO] Finished at: 2018-11-16T00:56:22-08:00
[INFO] Final Memory: 12M/28M
[INFO] ------------------------------------------------------------------------

同時生成topology資料夾,進去後的內容如下:

[email protected]_ubuntu:/home/myodl/topology# ll
total 56
drwxr-xr-x 10 root root 4096 Nov 16 00:56 ./
drwxr-xr-x 3 root root 4096 Nov 16 00:56 ../
drwxr-xr-x 3 root root 4096 Nov 16 00:56 api/      ---YANG模型目錄
drwxr-xr-x 2 root root 4096 Nov 16 00:56 artifacts/    ---專案元件座標管理目錄
drwxr-xr-x 3 root root 4096 Nov 16 00:56 cli/      ---karaf cli命令程式碼開發目錄
-rw-r--r-- 1 root root 1682 Nov 16 00:56 deploy-site.xml  ---部署的配置檔案,可以忽略
drwxr-xr-x 3 root root 4096 Nov 16 00:56 features/    ---feature組織管理目錄
-rw-r--r-- 1 root root 160 Nov 16 00:56 .gitignore
-rw-r--r-- 1 root root 88 Nov 16 00:56 .gitreview
drwxr-xr-x 3 root root 4096 Nov 16 00:56 impl/      ---業務邏輯的程式碼實現目錄
drwxr-xr-x 3 root root 4096 Nov 16 00:56 it/        ---整合測試目錄
drwxr-xr-x 2 root root 4096 Nov 16 00:56 karaf/      ---karaf打包目錄
-rw-r--r-- 1 root root 3576 Nov 16 00:56 pom.xml      ---專案跟pom檔案,描述maven專案的基本資訊
drwxr-xr-x 4 root root 4096 Nov 16 00:56 src/

3。在topology目錄下編譯工程:

[email protected]_ubuntu:/home/myodl/topology# mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Dcheckstyle.skip=true

其中:

-DskipTests表示不執行測試用例
-Dmaven.javadoc.skip=true表示跳過javadoc
-Dcheckstyle.skip=true表示跳過checkstyle檢查