Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Duplicate
-
Affects Version/s: 2.0.6, 2.0.7
-
Fix Version/s: None
-
Component/s: Artifacts and Repositories, Dependencies
-
Labels:None
-
Number of attachments :
Description
Using mvn deploy:deploy-file you can successfully upload a 'tar.gz' artifact to a repository.
Example without classifier:
mvn deploy:deploy-file -DgroupId=org.apache.tomcat -DartifactId=apache-tomcat -Dversion=6.0.13 -Dpackaging=tar.gz -DrepositoryId=repo-central -Durl=dav:http://repo.example.com:4000/maven-repos/repo-central/ -Dfile=apache-tomcat-6.0.13.tar.gz
Example with classifier
mvn deploy:deploy-file -DgroupId=org.apache.tomcat -DartifactId=apache-tomcat -Dversion=6.0.13 -Dpackaging=tar.gz -Dclassifier=bin -DrepositoryId=repo-central -Durl=dav:http://repo.example.com:4000/maven-repos/repo-central/ -Dfile=apache-tomcat-6.0.13.tar.gz
Once uploaded define a dependency in your pom to it.
Example without classifier
<project>
<packaging>pom</packaging>
...
<dependencies>
...
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>apache-tomcat</artifactId>
<version>6.0.13</version>
<type>tar.gz</type>
<optional>true</optional>
</dependency>
...
</dependencies>
...
</project>
Example with classifier
<project>
<packaging>pom</packaging>
...
<dependencies>
...
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>apache-tomcat</artifactId>
<version>6.0.13</version>
<type>tar.gz</type>
<classifier>bin</classifier>
<optional>true</optional>
</dependency>
...
</dependencies>
...
</project>
Now to reproduce the problem you could either do
mvn dependency:resolve
or
mvn assembly:assembly
(if the maven assembly plugin is configured with a dependency set that unpacks this dependency for example)
The reason I think this is a core bug and not an maven assembly plugin or maven-dependency-plugin bug is because the problem happens in both of these independent plugins.
When you run 'mvn dependency:resolve' you'll see that the dependency appears downloaded but then the build fails with :
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) org.apache.tomcat:apache-tomcat:tar.gz:bin:6.0.13
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.apache.tomcat -DartifactId=apache-tomcat \
-Dversion=6.0.13 -Dclassifier=bin -Dpackaging=tar.gz -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=org.apache.tomcat -DartifactId=apache-tomcat \
-Dversion=6.0.13 -Dclassifier=bin -Dpackaging=tar.gz -Dfile=/path/to/file \
-Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) com.example:core:pom:1.0.0-A1-SNAPSHOT
2) org.apache.tomcat:apache-tomcat:tar.gz:bin:6.0.13
----------
1 required artifact is missing.
...
... and even stranger here is the log which proves the dependency was found in the repo and downloaded, but NOT saved to local repository.
...
[DEBUG] Trying repository repo-central
Downloading: http://repo.example.com:4000/maven-repos/repo-central/org/apache/tomcat/apache-tomcat/6.0.13/apache-tomcat-6.0.13-bin.tar.gz
5826K downloaded
[DEBUG] Unable to get resource 'org.apache.tomcat:apache-tomcat:tar.gz:bin:6.0.13' from repository repo-central (http://repo.example.com:4000/maven-repos/repo-central)
[DEBUG] Unable to download the artifact from any repository
..and YOU MAY GET FOOLED into thinking all is well. mvn deploy:deploy-file also installs the same artifact into your local repo. So if you follow above steps and don't get an error it is because the deploy-file goal installed it in your local repo. However when someone else tries to use your project they will get above error.
So, first delete from your local repo. example:
rm -rf ~/.m2/repository/org/apache/tomcat/apache-tomcat
and then try to execute mvn dependency:resolve and it should fail as described.
...and finally I'll mention that doing the same thing with a 'zip' type/packaging there is NO PROBLEM.
Ultimately when using the maven assembly plugin I should be able to specify any type of dependency type supported by the maven assembly archiver.
Issue Links
- duplicates
-
WAGON-299
tgz artifacts ungzipped on download
-
You are correct this is a core issue. Dependency:resolve doesn't actually do any resolving itself. It just declares to Maven that it requires all dependencies resolved before execution. Only after everything is resolved does the mojo execute, and then it just prints out what was resolved.
Have you tried to unpack this artifact using dependency:unpack? You can specify the type etc in the configuration and it should be able to go retrieve and unpack the file.