-1
是否可以告訴Maven或其常用插件之一將最終程序集中的一個依賴JAR打包爲JAR文件?在Maven項目中包含完整的依賴JAR作爲JAR
ie如果我依賴於org.some-group:some-artifact:1.2.3
,Maven插件只會將整個some-artifact-1.2.3.jar
填充到我的最終JAR文件中?
是否可以告訴Maven或其常用插件之一將最終程序集中的一個依賴JAR打包爲JAR文件?在Maven項目中包含完整的依賴JAR作爲JAR
ie如果我依賴於org.some-group:some-artifact:1.2.3
,Maven插件只會將整個some-artifact-1.2.3.jar
填充到我的最終JAR文件中?
如果我清楚地理解你的問題,你需要一個特定的jar添加到您的產生罐子,在這種情況下,你可以使用使用classifier
與maven-assembly-plugin
的pom.xml
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>jar-with-dependencies-module</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>jar-with-dependencies</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
assembly.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>final-assembly</id>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<!-- Include the jar-with-dependencies -->
<dependencySet>
<includes>
<include>org.some-group:some-artifact:1.2.3</include>
</includes>
<useProjectArtifact>false</useProjectArtifact>
<!-- Don't use transitive dependencies since they are already included in the jar -->
<useTransitiveDependencies>false</useTransitiveDependencies>
</dependencySet>t>
</dependencySets>
</assembly>
Ab ove配置可能會給你一個想法從哪裏開始,以及如何將特定的jar包含到最終的罐子中
是否要創建包含所有第三個庫罐子的獨立jar文件? –
你的意思是像'mvn install assembly:single'? –
@NiteshVirani,我只是有一個指定的依賴關係,我想將其整個JAR文件填充到我最終組裝好的JAR文件中*而不打開它*!我希望所有其他依賴項都能正常處理。 – 0xbe5077ed