I have dependencies with classifiers that contain placeholder property keys which can be overriden via system properties. The default property value for each classifier is empty. E.g.
<properties>
<branch.classifier></branch.classifier>
</properties>
<dependency>
<groupId>de.example</groupId>
<artifactId>example</artifactId>
<version>0.0.1</version>
<classifier>${branch.classifier}</classifier>
</dependency>
Furthermore I want to unpack dependencies and copy some resources into a specific output directory.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>${project.groupId}</includeGroupIds>
<includeArtifactIds>my-dpendency</includeArtifactIds>
<includeClassifiers>${branch.classifier}</includeClassifiers>
<excludeTransitive>true</excludeTransitive>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/${project.artifactId}/conf</outputDirectory>
<includes>myfile.txt</includes>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</plugin>
However, the dependency plugin cannot unpack the file because it doesn't find it. I've debugged the plugin code and it seems that the comparison in the ProjectTrasivityFilter
between maven's artifact object and the direct dependencies artifacts do not match, since maven handles empty classifiers as null values and the plugin sets the classifier to an empty string. Here is the problematic code:
public boolean artifactIsADirectDependency( Artifact artifact )
{
for ( Artifact dependency : this.directDependencies )
{
if ( dependency.equals( artifact ) ) //condition returns false since "" not equals null
{
return true;
}
}
return false;
}
Is this a bug in the plugin and does anyone have a workaround? If not how can I fix this issue?
Update: OK, I found a solution. If I set the plugin's excludeTransitive
property to false
it works. But still not sure whether this is a bug or not.