Maven Shade插件:具有依赖关系的不同jar的不同类

时间:2018-06-03 10:05:15

标签: java maven jar maven-assembly-plugin maven-shade-plugin

使用Maven Assembly Plugin我可以为不同的jar构建不同的类,每个类都有自己的依赖项,如下所示:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>

        <execution>
            <id>assembly1</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>my.package.MyClass1</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <finalName>MyClass1</finalName>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </execution>

        <execution>
            <id>assembly2</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>my.package.MyClass2</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <finalName>MyClass2</finalName>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </execution>
    </executions>
</plugin>

是否可以使用Maven Shade Plugin获得相同的结果,多次执行为每个生成的jar指定不同的清单?

0 个答案:

没有答案