Petr Kozelka created MNG-5219:
---------------------------------
Summary: Regression from M2: Installing non-existing artifact is
silently ignored
Key: MNG-5219
URL: https://jira.codehaus.org/browse/MNG-5219
Project: Maven 2 & 3
Issue Type: Bug
Components: Artifacts and Repositories
Affects Versions: 3.0.3, 3.0.4
Environment: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /home/kozelka/opt/apache-maven-3.0.3
Java version: 1.6.0_22, vendor: Sun Microsystems Inc.
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "2.6.38-13-generic", arch: "amd64", family: "unix"
Reporter: Petr Kozelka
Attachments: MNG-fail-install-ifnotfound.patch, pom.xml
Maven 2.2.1 used to fail during "install" phase when an attached artifact did
not exist.
This is no longer true with version 3.0.3.
To reproduce the bug, store attached pom.xml into an empty directory and try:
a) maven 2.2.1 - use command "mvn clean install -e" to see the stacktrace:
{noformat}
[INFO] [install:install {execution: default-install}]
[INFO] Installing /TESTDIR/pom.xml to
/LOCALREPO/test/mvn/install/test-mvn-install/1-SNAPSHOT/test-mvn-install-1-SNAPSHOT.pom
[INFO] Installing /TESTDIR/target/nonexistent.nonsense to
/LOCALREPO/test/mvn/install/test-mvn-install/1-SNAPSHOT/test-mvn-install-1-SNAPSHOT.nonsense
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error installing artifact: File /TESTDIR/target/nonexistent.nonsense
does not exist
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error installing
artifact: File /TESTDIR/target/nonexistent.nonsense does not exist
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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:597)
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.plugin.MojoExecutionException: Error installing
artifact: File /TESTDIR/target/nonexistent.nonsense does not exist
at org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:143)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.apache.maven.artifact.installer.ArtifactInstallationException:
Error installing artifact: File /TESTDIR/target/nonexistent.nonsense does not
exist
at
org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:119)
at org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:133)
... 19 more
Caused by: java.io.IOException: File /TESTDIR/target/nonexistent.nonsense does
not exist
at hidden.org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1003)
at
org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:98)
... 20 more
[INFO] ------------------------------------------------------------------------
{noformat}
Here, M2 fails, and gives nice explanatory message.
b) maven 3.0.3 - use command "mvn clean install -X" to see the improper message
from aether:
{noformat}
[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-install-plugin:2.3.1:install' with basic
configurator -->
[DEBUG] (f) artifact = test.mvn.install:test-mvn-install:pom:1-SNAPSHOT
[DEBUG] (f) attachedArtifacts =
[test.mvn.install:test-mvn-install:nonsense:1-SNAPSHOT]
[DEBUG] (f) createChecksum = false
[DEBUG] (f) localRepository = id: local
url: file:///LOCALREPO/
layout: none
[DEBUG] (f) packaging = pom
[DEBUG] (f) pomFile = /TESTDIR/pom.xml
[DEBUG] (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
[INFO] Installing /TESTDIR/pom.xml to
/LOCALREPO/test/mvn/install/test-mvn-install/1-SNAPSHOT/test-mvn-install-1-SNAPSHOT.pom
[DEBUG] Installing
test.mvn.install:test-mvn-install:1-SNAPSHOT/maven-metadata.xml to
/LOCALREPO/test/mvn/install/test-mvn-install/1-SNAPSHOT/maven-metadata-local.xml
[DEBUG] Installing test.mvn.install:test-mvn-install/maven-metadata.xml to
/LOCALREPO/test/mvn/install/test-mvn-install/maven-metadata-local.xml
[INFO] Installing /TESTDIR/target/nonexistent.nonsense to
/LOCALREPO/test/mvn/install/test-mvn-install/1-SNAPSHOT/test-mvn-install-1-SNAPSHOT.nonsense
[DEBUG] Skipped re-installing /TESTDIR/target/nonexistent.nonsense to
/LOCALREPO/test/mvn/install/test-mvn-install/1-SNAPSHOT/test-mvn-install-1-SNAPSHOT.nonsense,
seems unchanged
[DEBUG] Installing
test.mvn.install:test-mvn-install:1-SNAPSHOT/maven-metadata.xml to
/LOCALREPO/test/mvn/install/test-mvn-install/1-SNAPSHOT/maven-metadata-local.xml
[DEBUG] Installing test.mvn.install:test-mvn-install/maven-metadata.xml to
/LOCALREPO/test/mvn/install/test-mvn-install/maven-metadata-local.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
{noformat}
In this case, the problem is (almost silently) ignored, because M3 (aether)
sees that the new file is the same as the old one _(correct :) - none of them
exist)_, due to a [bug
here|https://github.com/sonatype/sonatype-aether/blob/master/aether-impl/src/main/java/org/sonatype/aether/impl/internal/DefaultInstaller.java#L260].
He simply believes that same timestamp on both sides means that the artifact
does not need to be copied.
This is true *except when the timestamp is -1* - indicating missing file.
There are several ways to fix this:
- in maven-3 code (attached patch does this)
- in aether code
- in both - which I believe is best
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira