2015-11-05 60 views
1

我开始创建一个OSGI包。所以它工作正常。但是当我把输出目录放在maven bundle插件的配置部分时,它不会添加任何编译类。简单地说,类路径是空的。我也使用maven编译器插件。他们互相冲突吗?有什么我配置错误的方式。这是我的pox.xml文件的构建部分。如何在maven bundle插件中提供输出目录

<build> 
    <plugins> 

     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
      <version>1.4.0</version> 
      <extensions>true</extensions> 
      <configuration> 
       <instructions> 
        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
        <Bundle-Name>${project.artifactId}</Bundle-Name> 
        <Export-Package> 
         demo.wso2.orderprocess.* 
        </Export-Package> 
       </instructions> 
       <outputDirectory>/home/wso2/product/wso2esb-4.9.0/repository/components/dropins</outputDirectory> 
      </configuration> 
     </plugin> 

    </plugins> 

+0

我还没有试过。但这可能是一个插件http://stackoverflow.com/questions/19964391/output-directory-for-maven-bundle-plugin中的错误,也参考http://stackoverflow.com/questions/9943392/classpath- empty-when-adding-outputdirectory-to-pom –

+0

Yeap我看到了。应该有办法做到这一点。不应该? – GPrathap

+0

可能是你可以检查maven来源:) –

回答

2

您应该使用<buildDirectory>/home/wso2/product/wso2esb-4.9.0/repository/components/dropins</buildDirectory>而不是<outputDirectory>/home/wso2/product/wso2esb-4.9.0/repository/components/dropins</outputDirectory>。它为我做了窍门,现在我可以提高OSGI捆绑包开发的速度!

参考: Maven Bundle Plugin documentation

+0

cool ..接受了答案 – GPrathap

1

这里是我做过什么来解决这个问题,它的工作!

保持您的项目包装类型为“jar”并向其中添加OSGI元数据。这可以通过将执行目标添加到maven-bundle-plugin并且从引用maven-jar-plugin来实现。现在,只需将outputDirectory路径添加到maven-jar-plugin您想放置该jar的位置。

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <configuration> 
    <archive> 
     <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
    </archive> 
    </configuration> 
    <outputDirectory>/path/to/output/directory</outputDirectory> 
</plugin> 
<plugin> 
    <groupId>org.apache.felix</groupId> 
    <artifactId>maven-bundle-plugin</artifactId> 
    <executions> 
    <execution> 
     <id>bundle-manifest</id> 
     <phase>process-classes</phase> 
     <goals>  
     <goal>manifest</goal> 
     </goals> 
    </execution> 
    </executions> 
</plugin> 

现在,要构建项目,请运行以下命令。这将生成清单文件并将其打包成jar。

mvn org.apache.felix:maven-bundle-plugin:manifest install 

参考:

Apache Felix Documentation

相关问题