Maven dependency exceptions in pom.xml are not excluded by the assembly

So, I have a project in which I excluded all transitive dependencies from one of my dependencies (oracle jdbc stubbornly pulls in all banks that someone might need, which causes problems for me, replacing my xml parser).

My project build uses the dependencySet to pull in the boxes I need, but this does not apply to these exceptions at all: banks that should be excluded are displayed in the final package.

I know that I can explicitly exclude these dependencies in the assembly descriptor itself, but it is undesirable to maintain exceptions in two places, and this becomes cumbersome if you have many exceptions in pom.xml

Minimum playback example:

all files

$ find . ./src ./src/assembly ./src/assembly/tar.gz.xml ./pom.xml 

pom.xml

 <?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>bug.maven</groupId> <artifactId>maven-bug</artifactId> <version>1-SNAPSHOT</version> <packaging>jar</packaging> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <configuration> <descriptors> <descriptor>src/assembly/tar.gz.xml</descriptor> </descriptors> <finalName>maven-bug-${project.version}</finalName> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>attached</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> <version>1.4.1</version> <exclusions> <exclusion> <groupId>*</groupId> <artifactId>*</artifactId> </exclusion> </exclusions> </dependency> </dependencies> </project> 

Csi / assembly / tar.gz.xml

 <?xml version="1.0"?> <assembly> <id>pkg</id> <formats> <format>tar.gz</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <outputDirectory>/lib</outputDirectory> <useProjectArtifact>false</useProjectArtifact> </dependencySet> </dependencySets> </assembly> 

Play

 $ mvn clean package $ tar tzf target/maven-bug-1-SNAPSHOT-pkg.tar.gz lib/commons-validator-1.4.1.jar lib/commons-beanutils-1.8.3.jar lib/commons-logging-1.2.jar lib/commons-digester-1.8.1.jar lib/commons-collections-3.2.1.jar 

Expected results

 $ mvn clean package $ tar tzf target/maven-bug-1-SNAPSHOT-pkg.tar.gz lib/commons-validator-1.4.1.jar 

From what I can tell, this is just a bug without documentation in maven. Does anyone have an idea that I'm missing or a solution?

+1
source share
1 answer

There is a simple entry in the assembly descriptor: <useTransitiveDependencies>false</useTransitiveDependencies> , which should solve your problem. In addition, if you think that some documentation is missing, you should open Ticket in JIRA . Oh by the way. The attached target is outdated and should not be used. In release 3.0.0 (which is the latest, it has been removed). See page docs . There is a deliberate difference between the dependencies in your pom file and those that you can define in the maven assembly descriptor, because the descriptor describes what you are packing, and not what is in the classpath, there may be differences ... and they are not always the same.

+1
source

All Articles