如何创建一个包含我的 jar-with-dependencies 和其他文件的 tar 文件?

How can I create a tar file that contains my jar-with-dependacies along with other files?

目前我可以创建一个包含我的 jar 和其他文件的 tar,但是因为 jar-with-dependancies 是在 tar 文件之后构建的,所以它不包括在内。我怎样才能让 maven 首先构建 jar-with-dependancies,以便它将包含在 tar?

pom:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>

                <descriptors>
                    <descriptor>src/assembly/bin.xml</descriptor>
                </descriptors>
                <finalName>JAR-NAME-${project.version}</finalName>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

bin.xml:

<assembly>
    <id>bin</id>

    <formats>
        <format>tar.gz</format>
    </formats>

    <fileSets>
        <fileSet>
            <directory>target</directory>
            <outputDirectory>bin</outputDirectory>
            <includes>
                <include>JAR-NAME-*.jar</include>
            </includes>
        </fileSet>

        <fileSet>
            // Unrelated files
        </fileSet>

        <fileSet>
            // Unrelated files
        </fileSet>
    </fileSets>
</assembly>

好的,看来您可以通过将两个步骤拆分为各自的执行标签来控制构建顺序,如下所示:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>jar-with-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <finalName>JAR-NAME-${project.version}</finalName>
                    </configuration>
                </execution>

                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptors>
                            <descriptor>src/assembly/bin.xml</descriptor>
                        </descriptors>
                        <finalName>JAR-NAME-${project.version}</finalName>
                    </configuration>
                </execution>
            </executions>
        </plugin>