Garret Wilson created MSHADE-451:
------------------------------------

             Summary: Shade plugin not using `build.finalName` to produce 
artifact with classifier.
                 Key: MSHADE-451
                 URL: https://issues.apache.org/jira/browse/MSHADE-451
             Project: Maven Shade Plugin
          Issue Type: Bug
    Affects Versions: 3.4.1
            Reporter: Garret Wilson


I'm using Maven 3.9.1 with Java 17 on Windows 17, and Maven Shade Plugin 3.4.1.

I'm using a technique which I described in MNG-7815 which allows me to easily 
set the base filename of the generated artifacts in {{target/}}.

# In a separate parent pom ("Root POM") in the {{<properties>}} section I set a 
property {{<build.finalBaseName>${project.artifactId}</build.finalBaseName>}}.
# In the {{<build>}} section I set 
{{<finalName>${build.finalBaseName}-${project.version}</finalName>}}.

Let's suppose my project (which inherits from Root POM) has its own child 
project with an {{<artifactId>bar</artifactId>}}. Normally because of the 
default Maven {{build.finalName}}, setting, the target artifacts will be e.g.:

* {{bar-1.2.3.jar}}
* {{bar-1.2.3-javadoc.jar}}

However with the configuration I described above, I merely need to set the 
following property in the child project:

{code:xml}
<build.finalBaseName>foo-${project.artifactId}</build.finalBaseName>
{code}

Now my artifacts are generated with these names, just like I want:

* {{foo-bar-1.2.3.jar}}
* {{foo-bar-1.2.3-javadoc.jar}}

However the Maven Shade Plugin seems to be ignoring the final 
{{build.finalName}} and just assuming that it is set to the 
${project.artifactId}-${project.version} (which is the Maven default). For 
example let's say I add the following to my Maven Shade Plugin 
{{<configuration>}}:

{code:xml}
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>aws-lambda</shadedClassifierName>
{code}

I would expect the classifier to be added to the {{build.finalName}} (which is 
now {{foo-bar-1.2.3}})—after all, the Javadoc plugin does this just fine. 
However I get this:

* {{bar-aws-lambda-1.2.3.jar}}
* {{foo-bar-1.2.3.jar}}
* {{foo-bar-1.2.3-javadoc.jar}}

{{bar-aws-lambda-1.2.3.jar}} should be {{foo-bar-aws-lambda-1.2.3.jar}} 
(compare with the other generated artifacts. I'm guessing the Maven Shade 
Plugin is making assumptions about the value of {{build.finalName}} without 
using the actual value of {{build.finalName}}.

I have not yet done further investigations or tested with the latest version of 
the plugin. (I think I saw that a newer version has been released.) Nor have I 
done any further investigations. Nevertheless I wanted to record this bug while 
I have all the necessary windows open, before I stop for lunch and forget how 
all these pieces fit together.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to