Maven 2 & 3

unable to resolve attached artifacts from reactor that are not in repo. (patch applied in svn and IT tests added)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.2, 2.0.3, 2.0.4, 2.0.5
  • Fix Version/s: 2.0.6
  • Labels:
    None
  • Complexity:
    Intermediate
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

The patch has been applied here: https://svn.apache.org/repos/asf/maven/components/branches/maven-project-mdep64

and the IT tests are already added to core-it but commented out from the suite. To enable it, uncomment this line: //suite.addTestSuite( MavenIT0118AttachedArtifactsInReactor.class );

-----------------------

This is from MDEP-64:

We have a project with a few sub-projects. Only one of those subprojects uses the maven-dependency-plugin, copying the jar file artifact from one of the sibling sub-projects. The dependency plugin has worked fine in another multi-project m2 buld and release when the dependency copy was only referencing projects outside the multi-project's project tree.

But in the present multi-project release, copying that sibling jar file with the dependency plugin causes the mvn release:prepare step to fail, because it can't find the released version in the release repository. It doesn't care about referencing sibling project dependencies from the regular pom dependencies, it only chokes for the dependency:copy.

Here's a diagram for the issue with three pseudo-poms. I omitted groupId's, scm, distributionManagement, and other content from the poms that were not necessary to communicate the basic issue. I've worked around this by using the antrun plugin, which is unpleasant and untidy. This seems like it might be related to MDEP-44.

superproject/
A/ -> no dependencies
B/ -> dependency:copy A

//superproject/pom.xml (abbrieviated)
<project>
<artifactId>superproject</artifactId>
<packaging>pom</packaging>
<version>1.0.0.1-SNAPSHOT</version>
<modules>
<module>A</module>
<module>B</module>
</modules>
</project>

// superproject/A/pom.xml (abbrievated)
<project>
<parent>
<artifactId>superproject</artifactId>
<version>1.0.0.1-SNAPSHOT</version>
</parent>
<artifactId>A</artifactId>
<version>1.0.0.1-SNAPSHOT</version>
</project>

// superproject/B/pom.xml (abbreviated)
<project>
<parent>
<artifactId>superproject</artifactId>
<version>1.0.0.1-SNAPSHOT</version>
</parent>
<artifactId>B</artifactId>
<packaging>war</packaging>
<version>1.0.0.1-SNAPSHOT</version>

<build>
<finalName>FooWar</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<goals>
<goal>copy</goal>
</goals>
<phase>package</phase>
<configuration>
<artifactItems>
<artifactItem>
<artifactId>A</artifactId>
<version>${pom.version}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/${pom.build.finalName}/jars</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<artifactId>A</artifactId>
<version>${pom.version}</version>
</dependency>
</dependencies>
</project>

The error message during mvn release:prepare is basically:
[INFO] Building B
[INFO] task-segment: [clean, integration-test]
[INFO] ----------------------------------------------------------------------------
[INFO] [clean:clean] <skip deleting directories>
[INFO] [dependency:copy {execution: copy}]
[INFO] Configured Artifact: <groupId>:A:null:1.0.0.1:jar
Downloading: <details>/1.0.0.1/A-1.0.0.1.jar
[WARNING] Unable to get resource from repository sizzle (<our repository details>)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: <groupId>
ArtifactId: A
Version: 1.0.0.1

Reason: Unable to download the artifact from any repository

Issue Links

Activity

Hide
Brian Fox added a comment -

Description from MDEP-44: (this has the patch and tests I used)

I have a parent project, which has two modules - "one" and "two".

"one" uses assembly:single to attach an assembly to its build.
"two" depends upon that assembly, and uses "dependency:unpack-dependencies" to unpack it.

This works fine if the projects are built separately - and the assembly is installed in the local repository. However, when using the reactor to build both projects at once, the dependency plugin still looks in the local repository for the assembly, rather than using the artifact which was just built. This either fails, or produces the wrong version of the assembly.

I suspect this may be a bug with the reactor mechanism - but I don't really understand how all that works...

The attachment demonstrates the problem.

Show
Brian Fox added a comment - Description from MDEP-44: (this has the patch and tests I used) I have a parent project, which has two modules - "one" and "two". "one" uses assembly:single to attach an assembly to its build. "two" depends upon that assembly, and uses "dependency:unpack-dependencies" to unpack it. This works fine if the projects are built separately - and the assembly is installed in the local repository. However, when using the reactor to build both projects at once, the dependency plugin still looks in the local repository for the assembly, rather than using the artifact which was just built. This either fails, or produces the wrong version of the assembly. I suspect this may be a bug with the reactor mechanism - but I don't really understand how all that works... The attachment demonstrates the problem.
Hide
Brian Fox added a comment -

The patch has been applied here: https://svn.apache.org/repos/asf/maven/components/branches/maven-project-mdep64

and the IT tests are already added to core-it but commented out from the suite. To enable it, uncomment this line: //suite.addTestSuite( MavenIT0118AttachedArtifactsInReactor.class );

All other core IT tests pass (at least all the ones that pass w/o the patch)

Show
Brian Fox added a comment - The patch has been applied here: https://svn.apache.org/repos/asf/maven/components/branches/maven-project-mdep64 and the IT tests are already added to core-it but commented out from the suite. To enable it, uncomment this line: //suite.addTestSuite( MavenIT0118AttachedArtifactsInReactor.class ); All other core IT tests pass (at least all the ones that pass w/o the patch)
Hide
Stephane Nicoll added a comment -

very cool. I was about to investigate this issue!

Show
Stephane Nicoll added a comment - very cool. I was about to investigate this issue!
Hide
Jason van Zyl added a comment -

Patch applied. ITs are good. Thanks.

Show
Jason van Zyl added a comment - Patch applied. ITs are good. Thanks.
Hide
Julien HENRY added a comment -

Are you sure this bug is fixed in Maven 2?

I just face it with Maven 2.2.1 when doing a release:prepare.

Here is an attached project to reproduce the issue. Running mvn clean verify fails to build with Maven 2.2.1.
Note that it is working with Maven 3 alpha 6.

Show
Julien HENRY added a comment - Are you sure this bug is fixed in Maven 2? I just face it with Maven 2.2.1 when doing a release:prepare. Here is an attached project to reproduce the issue. Running mvn clean verify fails to build with Maven 2.2.1. Note that it is working with Maven 3 alpha 6.
Hide
Julien HENRY added a comment -

Here is a sample project to reproduce the issue.

Show
Julien HENRY added a comment - Here is a sample project to reproduce the issue.
Hide
Brett Porter added a comment -

Julien - this fix doesn't encompass the dependency plugin. If you were to switch to a "real" dependency and copy-dependencies, the test project would work.
For the release plugin issue, make sure you use version 2.0.

Show
Brett Porter added a comment - Julien - this fix doesn't encompass the dependency plugin. If you were to switch to a "real" dependency and copy-dependencies, the test project would work. For the release plugin issue, make sure you use version 2.0.
Hide
Julien HENRY added a comment -

Hi Brett,

I'm using release plugin 2.0 and the problem is still here. During the release:prepare goal, I believe the forked execution is mvn clean verify.
And this is mvn clean verify that fails (even outside of the release process) when artifact I want to copy was not previously installed in the local repository.

The initial description of this issue (comming from MDEP-64) make me think this is the same issue and it was supposed to be fixed in 2.0.6.

Again it works with Maven 3 so I guess there is no chance it will be fixed in Maven 2.2.x but I just want to point out that ITs may not be complete.

Show
Julien HENRY added a comment - Hi Brett, I'm using release plugin 2.0 and the problem is still here. During the release:prepare goal, I believe the forked execution is mvn clean verify. And this is mvn clean verify that fails (even outside of the release process) when artifact I want to copy was not previously installed in the local repository. The initial description of this issue (comming from MDEP-64) make me think this is the same issue and it was supposed to be fixed in 2.0.6. Again it works with Maven 3 so I guess there is no chance it will be fixed in Maven 2.2.x but I just want to point out that ITs may not be complete.
Hide
Harold Shinsato added a comment -

We've run in this as well with the Maven Dependency Plugin 2.0.6 running with Maven 2.2.1. I'm confused as to why this bug is marked fixed with the Maven Dependency Plugin 2.0.6 - as the problem still seems to be present.

Show
Harold Shinsato added a comment - We've run in this as well with the Maven Dependency Plugin 2.0.6 running with Maven 2.2.1. I'm confused as to why this bug is marked fixed with the Maven Dependency Plugin 2.0.6 - as the problem still seems to be present.
Hide
Karl M. Davis added a comment -

The problem still seems to exist when running release:prepare in a multi-module project where one of the modules uses dependency:copy-dependencies for a secondary artifact of one of the other modules.

For example:

  • parent-proj (running release:prepare or verify here will fail)
    • child-a
      • produces a "primary" JAR artifact
      • also produces a "secondary" assembly artifact attached to the build, e.g. a .zip of PDF documentation
    • child-b
      • uses dependency:unpack-dependencies to get the "secondary" assembly from child-a

The release:prepare operation ends up failing when the unpack-dependencies goal can't find the secondary artifact of child-a in the repository (hasn't been installed yet) or in the reactor (this is the bug, I think). It fails with the following error:
Embedded error: Unable to download the artifact from any repository

I would recommend that this bug be re-opened. I am running Maven 2.2.1, using maven-release-plugin:2.0, and maven-dependency-plugin:2.1.

Show
Karl M. Davis added a comment - The problem still seems to exist when running release:prepare in a multi-module project where one of the modules uses dependency:copy-dependencies for a secondary artifact of one of the other modules. For example:
  • parent-proj (running release:prepare or verify here will fail)
    • child-a
      • produces a "primary" JAR artifact
      • also produces a "secondary" assembly artifact attached to the build, e.g. a .zip of PDF documentation
    • child-b
      • uses dependency:unpack-dependencies to get the "secondary" assembly from child-a
The release:prepare operation ends up failing when the unpack-dependencies goal can't find the secondary artifact of child-a in the repository (hasn't been installed yet) or in the reactor (this is the bug, I think). It fails with the following error: Embedded error: Unable to download the artifact from any repository I would recommend that this bug be re-opened. I am running Maven 2.2.1, using maven-release-plugin:2.0, and maven-dependency-plugin:2.1.
Hide
Benjamin Bentmann added a comment -

To clear things up, the reactor resolution in Maven 2.x is only available in certain scenarios, i.e. the resolution behavior has a subtle but important dependency on what a plugin goal actually does. In the case of the maven-dependency-plugin, the goals copy-/unpack-dependencies can work in a reactor, whereas the closely related goals copy/unpack don't because they employ the other/broken code path (which is still tracked as an unresolved issue, MNG-4233).

Show
Benjamin Bentmann added a comment - To clear things up, the reactor resolution in Maven 2.x is only available in certain scenarios, i.e. the resolution behavior has a subtle but important dependency on what a plugin goal actually does. In the case of the maven-dependency-plugin, the goals copy-/unpack-dependencies can work in a reactor, whereas the closely related goals copy/unpack don't because they employ the other/broken code path (which is still tracked as an unresolved issue, MNG-4233).

People

Vote (0)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: