基于Maven构建OSGI(二)
6、部署OSGI Bundle 到Maven 仓库
首先下载Nexus professional(收费),地址为:
http://nexus.sonatype.org/download-nexus.html
当前最新版本为1.9.2.2。
压缩文件为:
?
解压之后有两个文件夹,如下图:
?
进入nexus-professional-webapp-1.9.2.2\bin\jsw目录找到和自己相应系统的文件夹,如下图所示:
我的为windows-x86-32。然后执行nexus.bat。如下图:
?
在地址栏输入:http://localhost:8081/nexus/
如图:
?
点击Log In。admin用户的密码为admin123.deployment用户的密码为deployment123。
设置~/.m2/setting.xml文件的内容如下:
<settings><mirrors><mirror><!--This sends everything else to /public --><id>nexus</id><mirrorOf>*</mirrorOf><url>http://localhost:8081/nexus/content/groups/public</url></mirror></mirrors><profiles><profile><id>nexus</id><!--Enable snapshots for the built in central repo to direct --><!--all requests to nexus via the mirror --><repositories><repository><id>central</id><url>http://central</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><url>http://central</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles><servers><server><id>nx-snapshots</id><username>deployment</username><password>deployment123</password></server><server><id>nx-releases</id><username>deployment</username><password>deployment123</password></server></servers><activeProfiles><!--make the profile active all the time --><activeProfile>nexus</activeProfile></activeProfiles></settings>
?
设置父级pom.xml文件,在<project>节点下加入如下内容:
<distributionManagement><repository><id>nx-releases</id><name>NexusReleases</name><url>http://localhost:8081/nexus/content/repositories/releases</url></repository><snapshotRepository><id>nx-snapshots</id><name>NexusSnapshots</name><url>http://localhost:8081/nexus/content/repositories/snapshots</url></snapshotRepository></distributionManagement>?
新建Maven构建命令,deploy –DremoteOBR。然后会在Snapshots中看到如下图所示的内容:
完成此步骤之后,就可以在Maven中引用其他文件一样来依赖该jar文件。例如:
<dependency><groupId>com.yihua.osgi.test-osgi</groupId><artifactId>IQueryWor</artifactId><version>0.0.1-SNAPSHOT</version></dependency>
?http://www.linuxso.com/architecture/9182.html
?