0

当我在我的项目上运行命令“mvn package”时,来自 src/main/resources/META-INF 的资源文件(如 persistence.xml、persistence.xml.dev、persistence.xml.qa 等)被打包在包中。我需要帮助让 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>
4

2 回答 2

1

以下链接解释了如何在“说明 - > 包含资源”主题下的最终捆绑包中包含资源。 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>
于 2014-11-24T21:53:57.503 回答
0

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

于 2014-11-24T08:45:19.397 回答