maven-assembly-plugin does not work.
What you want to do is override the configuration of the assembly descriptor jar-with-dependencies and this is not possible.
If you need to create a jar similar to the one created by the jar-with-dependencies assembly, but without specific classes of your own project, you need to write your own assembly and call it in maven-assembly-plugin as it should.
Assembly in src/assembly/jar-with-deps-with-exclude.xml :
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.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> </dependencySet> </dependencySets> <fileSets> <fileSet> <outputDirectory>/</outputDirectory> <directory>${project.build.outputDirectory}</directory> <excludes> <exclude>com/uiservices/controllers/*.*</exclude> </excludes> </fileSet> </fileSets> </assembly>
This will create the assembly without unpacking the dependencies and add your classes except those that are excluded.
And then in your pom.xml:
<plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>only</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptors> <descriptor>src/assembly/jar-with-deps-with-exclude.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin>
But if you need your classic jar without excluded classes, you can directly exclude them in maven-jar-plugin :
<plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <excludes> <exclude>com/uiservices/controllers/*.*</exclude> </excludes> </configuration> </plugin>
source share