[ 
https://issues.apache.org/jira/browse/MDEP-732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17483991#comment-17483991
 ] 

Arjan Tijms commented on MDEP-732:
----------------------------------

Just a ping, any updates here?

> unpack - artifactItem type attribute ignored
> --------------------------------------------
>
>                 Key: MDEP-732
>                 URL: https://issues.apache.org/jira/browse/MDEP-732
>             Project: Maven Dependency Plugin
>          Issue Type: Bug
>          Components: unpack
>    Affects Versions: 3.1.2
>            Reporter: Zoltán Forgó
>            Priority: Major
>
> If an existing artifact which has other types (e.g. test-jar) needs to be 
> unpacked the type attribute is getting ignored. Always jar type used.
> {code:xml}
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-dependency-plugin</artifactId>
>     <version>3.1.2</version>
>     <executions>
>         <execution>
>             <id>share-tests</id>
>             <phase>generate-test-sources</phase>
>             <goals>
>                 <goal>unpack</goal>
>             </goals>
>             <configuration>
>                 <artifactItems>
>                     <artifactItem>
>                         <groupId>io.github.zforgo.stackoverflow</groupId>
>                         <artifactId>shared-tests</artifactId>
>                         <version>0.1.0-SNAPSHOT</version>
>                         <type>test-jar</type>
>                         
> <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
>                     </artifactItem>
>                 </artifactItems>
>             </configuration>
>         </execution>
>     </executions>
> </plugin>
> {code}
>  While running {{mvn install}} the log says
> {noformat}
> [INFO] 
> [INFO] --- maven-dependency-plugin:3.1.2:unpack (share-tests) @ project ---
> [INFO] Configured Artifact: 
> io.github.zforgo.stackoverflow:shared-tests:0.1.0-SNAPSHOT:test-jar
> [INFO] Unpacking [...] 
> shared-tests/0.1.0-SNAPSHOT/shared-tests-0.1.0-SNAPSHOT.jar to [...] with 
> includes "" and excludes ""
> [INFO] 
> {noformat}
> It seems {{ArtifactItem}} was configured well but the {{Artifact}} is wrong.
> After some debugging it seems {{AbstractFromConfigurationMojo}} didn't set 
> type attribute when creating {{Artifact}} from {{ArtifactItem}}.
> Related code:
> {code:java}
>     protected Artifact getArtifact( ArtifactItem artifactItem )
>         throws MojoExecutionException
>     {
>         Artifact artifact;
>         try
>         {
> // ...
>             ProjectBuildingRequest buildingRequest = 
> newResolveArtifactProjectBuildingRequest();
>             if ( localRepositoryDirectory != null )
>             {
>                 buildingRequest =
>                     repositoryManager.setLocalRepositoryBasedir( 
> buildingRequest, localRepositoryDirectory );
>             }
>             // Map dependency to artifact coordinate
>             DefaultArtifactCoordinate coordinate = new 
> DefaultArtifactCoordinate();
>             coordinate.setGroupId( artifactItem.getGroupId() );
>             coordinate.setArtifactId( artifactItem.getArtifactId() );
>             coordinate.setVersion( artifactItem.getVersion() );
>             coordinate.setClassifier( artifactItem.getClassifier() );
>             final String extension;
>             ArtifactHandler artifactHandler = 
> artifactHandlerManager.getArtifactHandler( artifactItem.getType() );
>             //...
>         }
>         catch ( ArtifactResolverException e )
>         {
>             throw new MojoExecutionException( "Unable to find/resolve 
> artifact.", e );
>         }
>         return artifact;
>     }{code}
> The {{DefaultArtifactCoordinate}} sets type to {{jar}} and there is no place 
> where it was updated. Because of this wrong artifact will be unpacked.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to