Subartifact (ejb-client for example) are not reselved as active project artifacts ---------------------------------------------------------------------------------
Key: MNG-2871 URL: http://jira.codehaus.org/browse/MNG-2871 Project: Maven 2 Issue Type: Bug Components: Dependencies Affects Versions: 2.0.5, 2.0.4 Environment: Not platform dependent Reporter: Piotr Tabor I have prepared simple project to show the bug. It contains three artifacts: |-root \--- ejb3 \--- client Client depends on ejb3 with <type>ejb-client</type>. The local and remote repository must not contain those artifacts. When I do "mvn -X compile" (or even integration-tests) on root project I will get those errors: ... [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-resources-plugin:2.2:resources' --> [DEBUG] (f) filters = [] [DEBUG] (f) outputDirectory = /home/ptab/m2/bug/root/client/target/classes [DEBUG] (f) project = [EMAIL PROTECTED] [DEBUG] (f) resources = [EMAIL PROTECTED] [DEBUG] -- end configuration -- [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [DEBUG] pl.waw.tabor:client:jar:1.0-SNAPSHOT (selected for null) [DEBUG] junit:junit:jar:3.8.1:test (selected for test) [DEBUG] pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT:compile (selected for compile) [DEBUG] Skipping disabled repository Newitech-repository [DEBUG] Skipping disabled repository central [DEBUG] ejb3: using locally installed snapshot [DEBUG] Trying repository Newitech-snapshots-repository Downloading: scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech-snapshots/pl/waw/tabor/ejb3/1.0-SNAPSHOT/ejb3-1.0-SNAPSHOT-client.jar [WARNING] Unable to get resource 'pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT' from repository Newitech-snapshots-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech-snapshots) [DEBUG] Skipping disabled repository Newitech-repository [DEBUG] Trying repository Newitech-publiczne Downloading: scp://ivy.newitech.com/opt/maven/public_html/repozytoria/publiczne//pl/waw/tabor/ejb3/1.0-SNAPSHOT/ejb3-1.0-SNAPSHOT-client.jar [WARNING] Unable to get resource 'pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT' from repository Newitech-publiczne (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/publiczne/) [DEBUG] Trying repository Maven Snapshots Downloading: http://people.apache.org/maven-snapshot-repository/pl/waw/tabor/ejb3/1.0-SNAPSHOT/ejb3-1.0-SNAPSHOT-client.jar [WARNING] Unable to get resource 'pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT' from repository Maven Snapshots (http://people.apache.org/maven-snapshot-repository) [DEBUG] Trying repository codehausSnapshots Downloading: http://snapshots.maven.codehaus.org/maven2/pl/waw/tabor/ejb3/1.0-SNAPSHOT/ejb3-1.0-SNAPSHOT-client.jar [WARNING] Unable to get resource 'pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT' from repository codehausSnapshots (http://snapshots.maven.codehaus.org/maven2) [DEBUG] Skipping disabled repository central [DEBUG] Unable to download the artifact from any repository Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=pl.waw.tabor -DartifactId=ejb3 \ -Dversion=1.0-SNAPSHOT -Dpackaging=ejb-client -Dfile=/path/to/file Path to dependency: 1) pl.waw.tabor:client:jar:1.0-SNAPSHOT 2) pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT pl.waw.tabor:ejb3:ejb-client:1.0-SNAPSHOT from the specified remote repositories: Maven Snapshots (http://people.apache.org/maven-snapshot-repository), central (http://repo1.maven.org/maven2), codehausSnapshots (http://snapshots.maven.codehaus.org/maven2), Newitech-snapshots-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech-snapshots), Newitech-publiczne (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/publiczne/), Newitech-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech) [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. Missing: ---------- 1) pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=pl.waw.tabor -DartifactId=ejb3 \ -Dversion=1.0-SNAPSHOT -Dpackaging=ejb-client -Dfile=/path/to/file Path to dependency: 1) pl.waw.tabor:client:jar:1.0-SNAPSHOT 2) pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT ---------- 1 required artifact is missing. for artifact: pl.waw.tabor:client:jar:1.0-SNAPSHOT from the specified remote repositories: Maven Snapshots (http://people.apache.org/maven-snapshot-repository), central (http://repo1.maven.org/maven2), codehausSnapshots (http://snapshots.maven.codehaus.org/maven2), Newitech-snapshots-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech-snapshots), Newitech-publiczne (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/publiczne/), Newitech-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech) [INFO] ------------------------------------------------------------------------ [DEBUG] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Missing: ---------- 1) pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=pl.waw.tabor -DartifactId=ejb3 \ -Dversion=1.0-SNAPSHOT -Dpackaging=ejb-client -Dfile=/path/to/file Path to dependency: 1) pl.waw.tabor:client:jar:1.0-SNAPSHOT 2) pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT ---------- 1 required artifact is missing. for artifact: pl.waw.tabor:client:jar:1.0-SNAPSHOT from the specified remote repositories: Maven Snapshots (http://people.apache.org/maven-snapshot-repository), central (http://repo1.maven.org/maven2), codehausSnapshots (http://snapshots.maven.codehaus.org/maven2), Newitech-snapshots-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech-snapshots), Newitech-publiczne (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/publiczne/), Newitech-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:556) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:330) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:123) at org.apache.maven.cli.MavenCli.main(MavenCli.java:272) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing: ---------- 1) pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=pl.waw.tabor -DartifactId=ejb3 \ -Dversion=1.0-SNAPSHOT -Dpackaging=ejb-client -Dfile=/path/to/file Path to dependency: 1) pl.waw.tabor:client:jar:1.0-SNAPSHOT 2) pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT ---------- 1 required artifact is missing. for artifact: pl.waw.tabor:client:jar:1.0-SNAPSHOT from the specified remote repositories: Maven Snapshots (http://people.apache.org/maven-snapshot-repository), central (http://repo1.maven.org/maven2), codehausSnapshots (http://snapshots.maven.codehaus.org/maven2), Newitech-snapshots-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech-snapshots), Newitech-publiczne (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/publiczne/), Newitech-repository (scp://ivy.newitech.com/opt/maven/public_html/repozytoria/newitech) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:305) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:272) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:243) at org.apache.maven.plugin.DefaultPluginManager.resolveTransitiveDependencies(DefaultPluginManager.java:1142) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:374) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539) ... 16 more [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8 seconds [INFO] Finished at: Mon Mar 12 20:34:44 CET 2007 [INFO] Final Memory: 6M/15M [INFO] ------------------------------------------------------------------------ ================================================================================================== I am sure, the most important line from this log is: [DEBUG] pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT:compile (selected for compile) I would like to see "[DEBUG] active project artifact: artifact = pl.waw.tabor:ejb3:ejb-client:client:1.0-SNAPSHOT:compile; project: [EMAIL PROTECTED] (selected for compile)" instead. If I do "mvn install" -> The source will compile (because ejb3-client artifact will be found in local repository). I investigated the source, and found that the reason is in org.apache.maven.project.MavenProject class in replaceWithActiveArtifact (method): The line "if (( ref.getArtifact().getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() ))" fails because ref.getArtifact().getDependencyConflictId() is pl.waw.tabor:ejb3:ejb-client:client and pluginArtifact.getDependencyConflictId() is pl.waw.tabor:ejb3. It is my workaround. I know - it is very messy. If you helped me - where is the best place to correct it - i would prepare a proper patch. Index: components/maven-project/src/main/java/org/apache/maven/project/MavenProject.java =================================================================== --- components/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (wersja 517335) +++ components/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (kopia robocza) @@ -1582,7 +1582,14 @@ if ( ref != null && ref.getArtifact() != null ) { // TODO: if not matching, we should get the correct artifact from that project (attached) - if ( ref.getArtifact().getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() ) ) + if (( ref.getArtifact().getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() )) + || ( + (ref.getArtifactId().equals(pluginArtifact.getArtifactId()))&& + (ref.getGroupId().equals(pluginArtifact.getGroupId()))&& + (ref.getArtifact().getType().equals("ejb"))&& + (pluginArtifact.getType().equals("ejb-client")) + ) + ) { // if the project artifact doesn't exist, don't use it. We haven't built that far. if ( ref.getArtifact().getFile() != null && ref.getArtifact().getFile().exists() ) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira