Sebastian Geiger created MASSEMBLY-824:
------------------------------------------

             Summary: Use of appendAssemblyId and finalName can cause problems
                 Key: MASSEMBLY-824
                 URL: https://issues.apache.org/jira/browse/MASSEMBLY-824
             Project: Maven Assembly Plugin
          Issue Type: Bug
    Affects Versions: 2.6
            Reporter: Sebastian Geiger


I recently had a usecase where I wanted to rename an artifact locally in the 
target/ folder. I configured the maven-assembly-plugin with the following 
options:

{{
<appendAssemblyId>false</appendAssemblyId>
<finalName>helper-${project.version}</finalName>
}}

As expected the resulting name was `helper-5.0.0-SNAPSHOT.jar`.

Next when I built the project I noticed warnings about a conflict with the 
default artifact for the project.

{quote}


    [WARNING] Configuration options: 'appendAssemblyId' is set to false, and 
'classifier' is missing. Instead of attaching the assembly file: 
[...]/target/helper-5.0.0-SNAPSHOT.jar, it will become the file for main 
project artifact.

    NOTE: If multiple descriptors or descriptor-formats are provided for this 
project, the value of this file will be non-deterministic!

    [WARNING] Replacing pre-existing project main-artifact file: 
[...]/target/my.module-5.0.0-SNAPSHOT.jar with assembly file: 
[...]/target/helper-5.0.0-SNAPSHOT.jar
{quote}

Irritated by these warnings I asked about this on 
[StackOverflow|http://stackoverflow.com/questions/38482839/maven-assembly-plugin-how-to-use-appendassemblyid/38484021#38484021]
 and received the following explanation:

Essentially during installation the standard maven coordinates (G-A-V-C) are 
still used independent of the {{finalName}} used to for the artifact, since 
this only affects the local name inside the {{target}} folder. Now, when the 
{{appendAssemblyId}} is set to {{false}} the classifier will be dropped not 
only from the local name, but also from the artifact's name used during 
installation and there will be a clash with the default artifact name if the 
project's packaging is set to jar.

Currently there seem to be only two solutions:

# Do not set the {{appendAssemblyId}} option to {{false}}, which means that the 
local name used inside the target folder will still get the assemblyId appended 
(e.g. <finalName>-jar-with-dependencies.jar).
# Alternatively, set the option {{attach}} to {{false}}, this will avoid the 
above mentioned warning but also means that the artifact will no longer be 
installed.

Of course I could just ignore he warning, but the after all the warning has a 
reason and I would much fix that then ignore the warning.

h1. Suggested solutions:

IMHO there are several solutions to resolve this:

# Omit the assemblyId on the local name by default if {{finalName}} is used. 
Additionally change the semantics of the {{appendAssemblyId}} option to only 
affect the installed artifact's name.

# Add an additional option to control if the assemblyId is appended to the 
local file name.

In any case, also if none of the suggested options are feasible I suggest to 
document this better.

* Make it clear in the {{appendAssemblyId}} option, that this affects both the 
local and the installed artifact's file name. Also clarify the warning that 
appears when this option is set to false. Also, maybe suggest to set {{attach}} 
to {{false}} if a conflict is detected?
* Make it clear in the {{finalName}} option, that this only affects the local 
file name and NOT the installed artifact's file name.

Thank your time and attention.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to