Reputation: 2983
during maven package i have a strange behavior. I have an artifact "A" that depends from "B".
Within "A" i have a folder META-INF that contains a persistence.xml, also in "B" I have a folder that META-INF with a persistence.xml.
This is pom's file of A relative to shade plugin and dependencies
<dependency>
<groupId>com.mycopany</groupId>
<artifactId>B</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
How can I exclude the persistence.xml file from "B", considering that "B" is also a shaded artifact?
Upvotes: 0
Views: 714
Reputation: 112
One solution I found is to Create JPA EntityManager without persistence.xml configuration file. I have used PersistenceUnitInfo.
Here is the original thread : Create JPA EntityManager without persistence.xml configuration file
Upvotes: 1
Reputation: 2413
use a second filtre and exclude persistence.xml like this :
<filter>
<artifact>B</artifact>
<excludes>
<exclude>path/persistence.xml</exclude>
</excludes>
</filter>
more details is in this question and in the official documentation
Upvotes: 1