首页 文章

maven assembly - 独立的jar和dependecies

提问于
浏览
0

我有一个带有多个jar项目的父项目,我正在使用一个特定的子项目来组装所有jar和dependecies的zip包,实际上我添加了所有项目作为这个特定项目的dependecies . 有没有办法将jar和dependecies分成两个不同的拉链?

1 回答

  • 0

    我能想到的最简单的方法是使用两个汇编描述符 .

    pom.xml:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptors>
                        <descriptor>src/assembly/assembly-myjars.xml</descriptor>
                        <descriptor>src/assembly/assembly-dependencies.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    assembly-myjars.xml:

    <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
        <id>myjars</id>
        <formats>
            <format>zip</format>
        </formats>
        <includeBaseDirectory>false</includeBaseDirectory>
        <dependencySets>
            <dependencySet>
                <includes>
                    <include>your.groupId:*</include>
                </includes>
            </dependencySet>
        </dependencySets>
    </assembly>
    

    assembly-dependencies.xml:

    <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
        <id>dependencies</id>
        <formats>
            <format>zip</format>
        </formats>
        <includeBaseDirectory>false</includeBaseDirectory>
        <dependencySets>
            <dependencySet>
                <excludes>
                    <exclude>your.groupId:*</exclude>
                </excludes>
            </dependencySet>
        </dependencySets>
    </assembly>
    

相关问题