I dont get any error with this code. Just that the file that I want to exclude still gets added. I am using the maven plugin for eclipse
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>only</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>com.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<excludes>
<exclude>**/com/uiservices/controllers/*.* </exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
I had a similar issue with
maven-assembly-plugin
:beans-conversion
has filesapplication.properties
,logback.xml
, andlogback.xsd
extract-conversion
has also files calledapplication.properties
,logback.xml
, andlogback.xsd
extract-conversion.jar
should includebeans-conversion.jar
content butapplication.properties
,logback.xml
, andlogback.xsd
ofextract-conversion.jar
should override thebeans-conversion.jar
.Solution:
We solved this using
maven-shade-plugin
as below in extract-conversion's pom.xml.The
maven-assembly-plugin
doesn't work like that.There what you want to do is override the configuration of the assembly descriptor
jar-with-dependencies
and that's not possible.If what you want to do is create a jar similar to the one created by the assembly
jar-with-dependencies
but without some specific classes of your own project, you have to write your own assembly and call it in themaven-assembly-plugin
like what follows.Assembly in
src/assembly/jar-with-deps-with-exclude.xml
:This will create an assembly with no the dependencies unpacked and with your classes added except the ones excluded.
And then in your pom.xml :
But if what you need is your classical jar without excluded classes, you can exclude them in the
maven-jar-plugin
directly :