src is used instead of target for bundling package

423 views Asked by At

When I run command "mvn package" on my project, resource files like persistence.xml, persistence.xml.dev, persistence.xml.qa etc..from src/main/resources/META-INF are packed in the bundle. I need help to make mvn-bundle-plugin to look at target folder instead of src folder because my target folder will have only one resource file persistence.xml. My pom mave-bundle-plugin is below

<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

There are 2 answers

0
auhuman On BEST ANSWER

Following Link explains how to include resources in the final bundle under topic "Instructions -> Include Resource". http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

Following the documentation, I added Included-Resource tag in instructions in pom xml as below and it worked i.e. the plugin packed the resource file from target folder.

<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>
2
Balazs Zsoldos On

By default maven looks for the resources in the src/main/resources directory. It has nothing to do with maven-bundle-plugin. To configure resource handling in a different way, see http://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html