使用src代替目标来捆绑包

时间:2014-11-22 01:58:01

标签: osgi osgi-bundle maven-bundle-plugin

当我运行命令" mvn package"在我的项目中,资源文件如persistence.xml,persistence.xml.dev,persistence.xml.qa等...来自src / main / resources / META-INF包装在捆绑包中。我需要帮助使mvn-bundle-plugin查看目标文件夹而不是src文件夹,因为我的目标文件夹只有一个资源文件persistence.xml。我的pom mave-bundle-plugin位于

之下
<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>

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

以下链接说明如何在主题&#34;说明 - &gt;主题下的最终捆绑中包含资源。包括资源&#34;。 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>