maven-shade-plugin : make a jar whereas we are in war Project?

▼魔方 西西 提交于 2020-01-15 12:22:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!