Reputation: 3667
In a maven project, maven-jar-plugin
and maven-shade-plugin
with classifier are configured in pom.xml
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<excludes>
<exclude>META-INF/persistence.xml</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>uber</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.github.rxue.dictionary.jpa.Main</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
Problem
uber-JAR is generated by maven-shade-plugin
on base of the jar generated by maven-jar-plugin
. So as long as META-INF/persistence.xml
is excluded by maven-jar-plugin
, META-INF/persistence.xml
is excluded in the generated uber-JAR as well
Question
How to exclude META-INF/persistence.xml
in the normal jar but include META-INF/persistence.xml
in the uber-JAR with man clean package
command in one go?
The purpose of generating jars in one goal is so that mvn deploy
can deploy all the jars into the Maven Central Repository
Upvotes: 0
Views: 38