1 year ago
#317164

Roberto Morávia
`outputFileNameMapping` uses the name of the artifact running the plugin instead of the dependency
I'm using maven-assembly-plugin
v.3.3.0 with the following configuration in my assembly file (the module name is example
):
pom file:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-example</artifactId>
<groupId>com.mysite</groupId>
<version>see-jgitver</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>example</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>A</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>B</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.myLib</groupId>
<artifactId>A</artifactId>
<version>${lib.version}</version>
</dependency>
<dependency>
<groupId>com.myLib</groupId>
<artifactId>B</artifactId>
<version>${lib.version}</version>
</dependency>
<dependencies>
Assembly file:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>dist</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySet>
<unpack>false</unpack>
<includes>
<include>*:tar.gz</include>
</includes>
<outputFileNameMapping>${artifact.groupId}${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
</dependencySets>
</assembly>
(Not sure if the ${artifact.groupId}
property is correct.)
The include tag matches artifact A
and B
.
I was expecting them to appear in the final package as
A.tar.gz
and B.tar.gz
.
Instead I get a single artifact called example.tar.gz
So, artifact.artifactId
is referring to the example artifact, that is running the plugin, and not to the dependency. Is this expected behavior? How can I achieve my goal?
Additional info(edit):
why do you like to use outputFileNameMapping? I'm trying to understand how it is used. In this case I have multiple dependencies with the same artifactId (although different groupId), so it would be useful to add the groupId to all of them.
What is the problem? Although, there's a context here, which I tried to clarify with this edit, I think my question is really straightforward. From the documentation I was expecting a different behavior.
Why have you changed the outputDirectory? I removed that tag, as it is not relevant in this case.
Why an include on tar.gz? So, there are several dependencies that are being joined in single tar. This is not my project, is part of a bigger construction.
Thanks!
maven
maven-assembly-plugin
0 Answers
Your Answer