Maven Shade Plugin to produce two Jars

前端 未结 1 1946
暗喜
暗喜 2021-01-04 02:27

Till now I was using maven assembly plugin to generate two JARs for each artifact - compiled sources and dependencies - the reason for this was simple - deploying only the c

相关标签:
1条回答
  • 2021-01-04 03:09

    Instead of defining the plugin twice, simply define it once but with two execution sections. So in your situation it would be:

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <id>shade-libs</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <outputFile>target/assembly/${project.artifactId}-libs.jar</outputFile>
              <artifactSet>
                <excludes>
                  <exclude>...</exclude>
                </excludes>
              </artifactSet>
              <transformers>
                <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>
              </transformers>
            </configuration>
          </execution>
          <execution>
            <id>shade-main</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <outputFile>target/assembly/${project.artifactId}.jar</outputFile>
              <artifactSet>
                <includes>
                  <include>...</include>
                </includes>
              </artifactSet>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    
    0 讨论(0)
提交回复
热议问题