Reputation: 1645
I have a normal maven dependency
<dependency>
<groupId>a.b.c.com</groupId>
<artifactId>xyz</artifactId>
<classifier>dist</classifier>
<version>1.234</version>
<type>zip</type>
</dependency>
This is not a jar. It's just a set of .q files (q language). I would like to exclude certain files.
I tried a few things and nothing seems to be working.
In the build, I added a maven-dependency-plugin, with unpack-dependencies as id, phase as package, goal to unpack, and inside the configuration, the artifact with the right groupId, artifactId, version, classifier, type, and the excludes.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>a.b.c.com</groupId>
<artifactId>xyz</artifactId>
<version>1.1234</version>
<type>zip</type>
<classifier>dist</classifier>
<excludes>code/lib/libcommon/filetoexclude.q</excludes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
And I can see in the logging that it's being logged as excluded but when I look at the actual target folder, it's still in there.
What am i missing?
Upvotes: 0
Views: 448
Reputation: 9303
As per documentation dependency:unpack-dependencies
simply "unpacks the project dependencies from the repository to a defined location", then it's up to you to do something with the unpacked resources.
I have a similar scenario in an application: a dependency contains a collection of .drl files (Drools language) and my application must use just a subset of those files. Instead of phisically removing unwanted files, I keep the dependency unchanged (as it should be, IMHO) and I use a config param called "rulesPath" that lists the files used by the application. Any other .drl file is simply ignored. In other words I solve the problem at run-time (in my application), not build-time (in Maven).
Upvotes: 1