问题
Question is in the title. I sucess to first to do a jar (project packaging jar)....then i move it before id do
mvn clean
to keep it elsewhere.
Or i'm a in a war project so i have to rename project packaging to war then i have to do a
mvn clean install
I got my war. I then import the first jar to use from my war.
Is there a clearer way do that with maven shade plugin to generate both war and jar.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-final</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.clb.genomic.lyon.external.MainExternal</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.tooling</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
The packaging follow
war/jar
in project description at the begining of the file and i have to change it each time i throw maven.
Thanks
回答1:
for me you're trying to build two products (a jar and a war) in the same maven module. I don't really understand your requirement to have this in the same module? and why are you using maven shade plugin ?
Here is the way I would follow to first make a jar and second make a war that is using the previously just generated jar:
- a parent module (packaging "pom") that defines 2 modules : module_myjar and module_mywar
- a child module module_myjar (packaging "jar")
- a child submodule module_mywar (packaging "war") this module could includes jar as dependency.
来源:https://stackoverflow.com/questions/23238199/maven-shade-plugin-make-a-jar-whereas-we-are-in-war-project