[ 
https://issues.apache.org/jira/browse/MSHADE-286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Peter De Maeyer updated MSHADE-286:
-----------------------------------
    Description: 
Shading fails when a dependency's main artifact does not exist, see the methods 
{{ShadeMojo.invalidMainArtifact/createErrorOutput}} and their caller.
A similar existence check (luckily) does not exist for the other artifacts: 
test jar, sources, and test sources.
This was done intentionally, but it's overly strict because it prohibits a 
legitimate use case: some projects don't produce a main artifact, but only e.g. 
a test artifact.
Such projects can't be shaded because of this existence check.

It would be better to:
- Get rid of this check, or at least relax it, such that shading also works for 
projects that don't have a main artifact.
- Complete the symmetry between jar, test jar, sources and test sources by 
adding a {{shadeJar}} boolean with default value {{true}}, which disables 
shading of main artifacts in a similar way {{shadeTestJar}}, 
{{createSourcesJar}} and {{createTestSourcesJar}} work. This will allow shading 
to disable creation of a main artifact altogether, even when the dependencies 
_do_ have a main artifact.

  was:
While looking at {{ShadeMojo.execute}}, I noticed that the artifacts to be 
included for shading are not consistently checked for existence.

For example, on line 404, the main artifact file is _not_ checked for existence:
{code:java}
artifacts.add( project.getArtifact().getFile() );
{code}
But immediately below, the sources artifact file _is_ checked for existence:
{code:java}
if ( createSourcesJar )
{
    File file = shadedSourcesArtifactFile();
    if ( file.isFile() )
    {
        sourceArtifacts.add( file );
    }
}
{code}

Apparently, it's a conscious choice to fail when the main artifact does not 
exist.


> Shading fails when a dependency's main artifact does not exist
> --------------------------------------------------------------
>
>                 Key: MSHADE-286
>                 URL: https://issues.apache.org/jira/browse/MSHADE-286
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 3.1.0
>            Reporter: Peter De Maeyer
>            Assignee: Mark Struberg
>            Priority: Minor
>
> Shading fails when a dependency's main artifact does not exist, see the 
> methods {{ShadeMojo.invalidMainArtifact/createErrorOutput}} and their caller.
> A similar existence check (luckily) does not exist for the other artifacts: 
> test jar, sources, and test sources.
> This was done intentionally, but it's overly strict because it prohibits a 
> legitimate use case: some projects don't produce a main artifact, but only 
> e.g. a test artifact.
> Such projects can't be shaded because of this existence check.
> It would be better to:
> - Get rid of this check, or at least relax it, such that shading also works 
> for projects that don't have a main artifact.
> - Complete the symmetry between jar, test jar, sources and test sources by 
> adding a {{shadeJar}} boolean with default value {{true}}, which disables 
> shading of main artifacts in a similar way {{shadeTestJar}}, 
> {{createSourcesJar}} and {{createTestSourcesJar}} work. This will allow 
> shading to disable creation of a main artifact altogether, even when the 
> dependencies _do_ have a main artifact.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to