2014-11-22 29 views
-1

当我在我的项目上运行命令“mvn package”时,资源文件像persistence.xml,persistence.xml.dev,persistence.xml.qa etc..from src/main /资源/ META-INF包装在捆绑中。我需要帮助才能使mvn-bundle-plugin查看目标文件夹而不是src文件夹,因为我的目标文件夹只有一个资源文件persistence.xml。我的pom mave-bundle-plugin低于src被用来代替绑定包的目标

<plugin> 
         <groupId>org.apache.felix</groupId> 
         <artifactId>maven-bundle-plugin</artifactId> 
         <extensions>true</extensions> 
         <executions> 
          <execution> 
           <id>bundle</id> 
           <phase>package</phase> 
           <goals> 
            <goal>bundle</goal> 
           </goals> 
          </execution> 
         </executions> 
         <configuration> 
          <instructions> 
           <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
           <Bundle-Classpath>.</Bundle-Classpath> 
           <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence> 
           <Embed-Dependency> 
            my-project-api 
           </Embed-Dependency> 
           <Export-Package></Export-Package> 
           <Import-Package> 
            javax.ws.rs;version="[2.0,3)", 
            javax.ws.rs.core;version="[2.0,3)", 
            *</Import-Package> 
         </instructions> 
         </configuration> 
</plugin> 
+0

究竟是什么问题? persistence.xml文件不在打包的jar文件中? – 2014-11-22 07:49:32

+0

@Balaza Zsoldos。问题在于构建插件使用项目src文件夹中的资源打包输出osgi bundle jar,而不是使用项目目标文件夹中的资源。 – auhuman 2014-11-24 00:26:27

回答

0

以下链接说明如何在最终捆绑包中的资源“指令 - >包括资源”下包含资源。 http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

继文档之后,我在下面的pom xml的说明中添加了Included-Resource标记,它的工作原理即插件打包了目标文件夹中的资源文件。

<instructions> 
    <Include-Resource> 
     META-INF/persistence.properties=target/classes/META-INF/persistence.properties 
    </Include-Resource> 
    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
    <Bundle-Classpath>.</Bundle-Classpath> 
    <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence> 
    <Embed-Dependency> 
      my-project-api 
    </Embed-Dependency> 
    <Export-Package></Export-Package> 
    <Import-Package> 
      javax.ws.rs;version="[2.0,3)", 
      javax.ws.rs.core;version="[2.0,3)", 
    *</Import-Package> 
</instructions> 
0

默认情况下,maven会在src/main/resources目录中查找资源。它与maven-bundle-plugin无关。要以不同的方式配置资源处理,请参阅http://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html

+0

我找到了一个maven-bundle-plugin文档链接,它解释了如何在目标包中包含资源。 http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html – auhuman 2014-11-24 21:46:01

+0

Balazs。谢谢你的协助。 – auhuman 2014-11-24 21:56:33