maven assembly include the current project jar in the final zip/tar

后端 未结 1 1037
北荒
北荒 2020-12-29 20:36

I am using maven assembly plugin to generate a .tar file contain several other files, dependent jars. All the files are being copied correctly to the given fold

相关标签:
1条回答
  • 2020-12-29 20:42

    In <dependencySet> you can exclude the current project jar by saying <useProjectArtifact>false</useProjectArtifact>, but it's true by default, so it should work.

    From the warning, it seems that you need to do mvn package first, but due to some internal maven issue, it does not work if you do mvn package and mvn assembly:single in separate commands.

    It works if you do mvn package assembly:single in one command.

    Alternatively, add maven-assembly-plugin in your pom and bind it to the 'package' phase so it will trigger automatically on mvn package:

       <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>tar-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>etc/assembly.xml</descriptor>
                  </descriptors>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
    0 讨论(0)
提交回复
热议问题