Jér*_*nge 25 java jar maven maven-assembly-plugin
Maven的程序集插件可以创建一个大jar,包括所有与descriptorRef的依赖关系jar-with-dependencies
.
如何排除其中一些依赖?好像它没有这样的配置?还有其他解决方案吗?
Jer*_*ens 24
添加<scope>provided</scope>
到您不希望包含在jar-with-dependencies中的依赖项,例如
<dependency>
<groupId>storm</groupId>
<artifactId>storm</artifactId>
<version>0.6.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
Rag*_*ram 11
此示例表明了一种方法:
<dependencySets>
<dependencySet>
....
<excludes>
<exclude>commons-lang:commons-lang</exclude>
<exclude>log4j:log4j</exclude>
</excludes>
</dependencySet>
....
</dependencySets>
Run Code Online (Sandbox Code Playgroud)
基本上我们会使用excludes
可用的选项dependencySet
.
另见:https://maven.apache.org/plugins/maven-assembly-plugin/assembly-component.html
fel*_*gnu 11
您应该使用excludes
可用的选项dependencySet
.
遵循以下:
pom.xml中的示例:
...
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<finalName>../final/${project.artifactId}</finalName>
<archive>
<manifest>
<addClasspath>false</addClasspath>
<mainClass>com.entrerprise.App</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/main/resources/jar-with-deps-with-exclude.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
Run Code Online (Sandbox Code Playgroud)
现在在你的新文件jar-with-deps-with-exclude.xml(其中dependencySet live):
<?xml version="1.0" encoding="UTF-8"?>
<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>jar-with-dependencies-and-exclude-classes</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
<excludes>
<exclude>junit:junit</exclude>
<exclude>commons-cli:commons-cli</exclude>
<exclude>org.apache.maven.wagon:wagon-ssh</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<directory>${project.build.outputDirectory}</directory>
</fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)
就这样.
归档时间: |
|
查看次数: |
29062 次 |
最近记录: |