[GRADLE-2046] Cannot mix file and http protocols to resolve artifacts for a single maven repository Created: 13/Jan/12  Updated: 07/Feb/17  Resolved: 07/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-7
Fix Version/s: None

Type: Bug
Reporter: Mauro Molinari Assignee: Unassigned
Resolution: Duplicate Votes: 4

Attachments: Zip Archive GRADLE-2046.zip    

 Description   

Please see http://forums.gradle.org/gradle/topics/making_gradle_find_a_jar_in_a_flatdir_repo_when_it_is_missing_from_a_maven_repo for a background.

Consider the attached project.

Try to run:
gradle compileJava
with 1.0-milestone-7. You'll see that it can't find jmxtools-1.2.1.jar, although I put it in the repo dir. If you use --debug you'll see:

(please note that D:\test-gradle is the path of the project in my file system)

15:31:13.043 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 		tried http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.044 [DEBUG] [org.gradle.api.internal.artifacts.repositories.ResourceCollectionResolver] Loading http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.044 [DEBUG] [org.gradle.api.internal.artifacts.repositories.transport.http.HttpResourceCollection] Constructing GET resource: http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.436 [DEBUG] [org.apache.commons.httpclient.params.DefaultHttpParams] Set parameter http.method.retry-handler = org.gradle.api.internal.artifacts.repositories.transport.http.HttpResourceCollection$1@99c873d
15:31:13.442 [DEBUG] [org.gradle.api.internal.artifacts.repositories.transport.http.HttpResourceCollection] Performing HTTP GET: http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.454 [DEBUG] [org.apache.commons.httpclient.HttpConnection] Open connection to repo1.maven.org:80
15:31:13.584 [DEBUG] [httpclient.wire.header] >> "GET /maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar HTTP/1.1[\r][\n]"
15:31:13.585 [DEBUG] [org.apache.commons.httpclient.HttpMethodBase] Adding Host request header
15:31:13.602 [DEBUG] [httpclient.wire.header] >> "User-Agent: Gradle/1.0-milestone-7[\r][\n]"
15:31:13.602 [DEBUG] [httpclient.wire.header] >> "Accept-Encoding: identity[\r][\n]"
15:31:13.603 [DEBUG] [httpclient.wire.header] >> "Host: repo1.maven.org[\r][\n]"
15:31:13.603 [DEBUG] [httpclient.wire.header] >> "[\r][\n]"
15:31:13.639 [DEBUG] [httpclient.wire.header] << "HTTP/1.1 404 Not Found[\r][\n]"
15:31:13.640 [DEBUG] [httpclient.wire.header] << "HTTP/1.1 404 Not Found[\r][\n]"
15:31:13.642 [DEBUG] [httpclient.wire.header] << "Server: nginx/1.0.1[\r][\n]"
15:31:13.642 [DEBUG] [httpclient.wire.header] << "Date: Fri, 13 Jan 2012 14:31:14 GMT[\r][\n]"
15:31:13.643 [DEBUG] [httpclient.wire.header] << "Content-Type: text/html[\r][\n]"
15:31:13.643 [DEBUG] [httpclient.wire.header] << "Content-Length: 168[\r][\n]"
15:31:13.644 [DEBUG] [httpclient.wire.header] << "Connection: keep-alive[\r][\n]"
15:31:13.644 [DEBUG] [httpclient.wire.header] << "[\r][\n]"
15:31:13.646 [INFO] [org.gradle.api.internal.artifacts.repositories.transport.http.HttpResourceCollection] Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar]
15:31:13.647 [DEBUG] [org.gradle.api.internal.artifacts.repositories.ResourceCollectionResolver] Resource not reachable for com/sun/jdmk#jmxtools;1.2.1: res=MissingResource: http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.648 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 		tried file:/D:/test-gradle/repo/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.648 [DEBUG] [org.gradle.api.internal.artifacts.repositories.ResourceCollectionResolver] Loading file:/D:/test-gradle/repo/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.649 [DEBUG] [org.gradle.api.internal.artifacts.repositories.transport.http.HttpResourceCollection] Constructing GET resource: file:/D:/test-gradle/repo/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:31:13.742 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] WARN: 	[FAILED     ] com.sun.jdmk#jmxtools;1.2.1!jmxtools.jar: unsupported protocol: 'file' (703ms)
15:31:13.744 [WARN] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyResolverBackedArtifactToFileResolver] Download failed for artifact 'com.sun.jdmk:jmxtools:1.2.1@jar': unsupported protocol: 'file'

This makes me think it could be a regression introduced with the use of HTTPClient instead of java.net.URL. So I tried 1.0-milestone-3 and swapped line 4 of build.gradle with line 5. Funny enough, this didn't work with 1.0-milestone-3 either... Running with --debug showed:

15:27:28.775 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] http://repo1.maven.org/maven2_jars: no namespace defined: using system
15:27:28.778 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 	 trying http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:27:28.779 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 		tried http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:27:28.956 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] HTTP response status: 404 url=http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:27:28.956 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] CLIENT ERROR: Not Found url=http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:27:28.957 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 	http://repo1.maven.org/maven2_jars: resource not reachable for com/sun/jdmk#jmxtools;1.2.1: res=http://repo1.maven.org/maven2/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:27:28.958 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 	 trying file://D:\test-gradle/repo/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:27:28.958 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 		tried file://D:\test-gradle/repo/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:28:32.979 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.IvyLoggingAdaper] 	http://repo1.maven.org/maven2_jars: resource not reachable for com/sun/jdmk#jmxtools;1.2.1: res=file://D:/test-gradle/repo/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
15:28:32.980 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyResolver] Resolved artifact com.sun.jdmk:jmxtools:1.2.1;default;jmxtools contains a null value.

although the URL file://D:/test-gradle/repo/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar, if pasted into a browser, does work.

Please make this work, because it would be extremely useful to me.



 Comments   
Comment by Mauro Molinari [ 20/Jul/12 ]

This would be really important to us. Could you please consider for the next Gradle release?

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Mauro Molinari [ 15/Nov/16 ]

So much time as passed that this does not work anymore with Gradle 3.2 ({{Could not find method mavenRepo() for arguments [

{url=http://repo1.maven.org/maven2, artifactUrls=[D:\tmp\GRADLE-2046/repo]}

] on repository container.}}). However, the need I expressed in the original discussion at http://forums.gradle.org/gradle/topics/making_gradle_find_a_jar_in_a_flatdir_repo_when_it_is_missing_from_a_maven_repo is still valid.

Comment by Eric Wendelin [ 07/Feb/17 ]

Moved to https://github.com/gradle/gradle/issues/1350 — please add any corrections or details you think would be useful there.

Generated at Wed Jun 30 12:11:20 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.