maven nexus

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2.   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  3.   <modelVersion>4.0.0</modelVersion>  
  4.     
  5.   <groupId>org.maven.demo</groupId>  
  6.   <artifactId>MavenDemo</artifactId>  
  7.   <version>0.0.1-SNAPSHOT</version>  
  8.   <packaging>jar</packaging>  
  9.     
  10.   <name>MavenDemo</name>  
  11.   <url>http://maven.apache.org</url>  
  12.     
  13.     <repositories>  
  14. <repository>
     
    <id>spring-maven-milestone</id>
     
    <name>Springframework Maven Repository</name>
     
    <url>http://maven.springframework.org/milestone</url>
    </repository>
  15.         <repository>  
  16.             <snapshots>  
  17.                 <enabled>true</enabled>  
  18.             </snapshots>  
  19.             <id>public</id>  
  20.             <name>Public Repositories</name>  
  21.             <url>http://172.28.189.138:8081/nexus/content/groups/public/</url>  
  22.         </repository>  
  23.     </repositories>  
  24.     <pluginRepositories>  
  25.         <pluginRepository>  
  26.             <id>public</id>  
  27.             <name>Public Repositories</name>  
  28.             <url>http://172.28.189.138:8081/nexus/content/groups/public/</url>  
  29.         </pluginRepository>  
  30.     </pluginRepositories>  
  31.     <dependencies>  
  32.         <dependency>  
  33.             <groupId>junit</groupId>  
  34.             <artifactId>junit</artifactId>  
  35.             <version>4.8.1</version>  
  36.             <type>jar</type>  
  37.             <scope>compile</scope>  
  38.         </dependency>  
  39.     </dependencies>

  Pax-Construct 是用来创建osgi工程的maven的插件,以后创建osgi架构的工程再也不用import一大堆plugin工程了。
   http://www.ops4j.org/projects/pax/construct/ 是Pax插件官网的入门教程,简单的说分为以下几步:
   1)http://repo1.maven.org/maven2/org/ops4j/pax/construct/scripts/1.4/scripts-1.4.zip 是pax插件的下载地址,下载了该插件后设置环境变量就可以使用了。
   2)pax-create-project -g examples -a test 该命令是创建一个OSGI的工程, -g 代表groupId为 examples ; -a 代表artifactId 为test
   3)进入到test 目录创建一个bundle。命令如下:cd test
     pax-create-bundle -p org.example.pkg -n test.bundle  其中-p 代表包名 -n代表bundle的名称
   4)mvn pax:eclipse -DdownloadSources 编译代码,导入到eclipse中
   5)mvn clean install pax:provision 部署工程到felix 。在这一步有可能报如下的错误:
     An API incompatibility was encountered while executing org.ops4j:maven-pax-plugin:1.4:compile: java.lang.NoSuchMethodError: org.apache.maven.project.MavenProject.addPlugin(Lorg/apache/maven/model/Plugin;)V  该错误的原因是Pax-Construct 试图改变maven的编译接口以更好的适应osgi。解决办法为修改poms/pom.xml文件。

<pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.ops4j</groupId>
          <artifactId>maven-pax-plugin</artifactId>
          <!--
           | enable improved OSGi compilation support for the bundle life-cycle.
           | to switch back to the standard bundle life-cycle, move this setting
           | down to the maven-bundle-plugin section
          -->
        </plugin>
        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <version>1.4.3</version>
          <extensions>true</extensions>                        <!-- 移动到这里 -->
        </plugin>
      </plugins>
    </pluginManagement>

猜你喜欢

转载自ssydxa219.iteye.com/blog/1851354