Http status code 403 stops ivy resolver?


(crotwell) #1

I am trying to add a build dependency on a url to a jar along the lines of the suggestions in given by Daz DeBoer in the forums here: http://gsfn.us/t/2m4hp

I think I have it working in one case, but another jar on githup doesn’t work. What I think is happening is the the Ivy resolver first tries to get the .ivy file, which doesn’t exist. But, because the github server returns a “403 Forbidden” instead of a 404, it gives up, even though if it just went ahead and tried to get the jar using the same pattern, it would succeed. To see this, replace “.xml” with “.jar” and the download works.

Is this an ivy or gradle bug? Should I be doing something different so that the lack of the .ivy file does not cause a build failure?

This is with Gradle 1.0-milestone-7. thanks Philip

Here is the build.gradle, using the izpack plugin as a test case:

buildscript {
    repositories {
        ivy {
            artifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }
      dependencies {
        classpath 'bmuschko:gradle-izpack-plugin:0.1'
    }
}

And the output:

FAILURE: Build failed with an exception.
  * What went wrong:
Could not resolve group:bmuschko, module:gradle-izpack-plugin, version:0.1.
Required by:
    :testDownload:unspecified
Cause: Could not GET 'http://cloud.github.com/downloads/bmuschko/gradle-izpack-plugin/gradle-izpack-plugin-0.1.xml'. Received status code 403 from server: Forbidden
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED

Here is another example for a different jar, also where the corresponding .ivy file does not exist:

buildscript {
    repositories {
        ivy {
            artifactPattern 'http://gradle-macappbundle.googlecode.com/files/[module]-[revision].[ext]'
        }
    }
      dependencies {
        classpath 'edu.sc.seis:gradle-macappbundle:1.0.1'
    }
}

and the output:

Download http://gradle-macappbundle.googlecode.com/files/gradle-macappbundle-1.0.1.jar
:help
  Welcome to Gradle 1.0-milestone-7.
  To run a build, run gradle <task> ...
  To see a list of available tasks, run gradle tasks
  To see a list of command-line options, run gradle --help
  BUILD SUCCESSFUL

Http 403 stopping resolver
#2

Thanks for the bug report: this is now GRADLE-2083.

This is another case where you have a repository with no published meta-data (jarfiles only). Gradle should make it easy to configure an ‘artifact-only’ repository, where Gradle would not search for ivy.xml or pom files.


#3

An (ugly) workaround is to specify the ivy pattern for the repository, pointing to a server that will return a 404 instead of a 403.

buildscript {
    repositories {
        ivy {
            ivyPattern 'http://google.com/FAKE_URL/not_a_real_file.txt'
            artifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }
    dependencies {
        classpath 'bmuschko:gradle-izpack-plugin:0.1'
    }
}

(crotwell) #4

I thought I had this work around working, but it seems to not be. Here is a short example. I think what is happening is it is trying the respositories in reverse order, and so it is getting the 403 from github when it is looking for the macappbundle jar. The order I put them in the build script seems to not determine the order they are tried. Also, I get a failure with or without the ivyPattern addition, although the error is different.

Is there a way to tell gradle that a dependency comes from a particular repository? I know that izpack comes from github and that macappbundle comes from gradle-macappbundle.googlecode.com. It seems wasteful to have it send out http queries that I know are going to fail.

I am guessing that until GRADLE-2083 is solved I can’t use multiple plugins where at least one is from github?

buildscript {
    repositories {
        ivy {
            url "http://gradle-macappbundle.googlecode.com"
            artifactPattern 'http://gradle-macappbundle.googlecode.com/files/[module]-[revision].[ext]'
        }
          ivy {
            name 'GitHub'
            ivyPattern 'http://www.seis.sc.edu/FAKE_URL/not_a_real_file.txt'
            artifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }
      dependencies {
        classpath 'bmuschko:gradle-izpack-plugin:0.2.1'
        classpath 'edu.sc.seis:gradle-macappbundle:1.0.3'
    }
}

and the result:

gradle --refresh dependencies --info
Starting Build
Settings evaluated using empty settings file.
Projects loaded. Root project using build file '/Users/crotwell/dev/gradlePlugins/testDownload/build.gradle'.
Included projects: [root project 'testDownload']
Evaluating root project 'testDownload' using build file '/Users/crotwell/dev/gradlePlugins/testDownload/build.gradle'.
Compiling build file '/Users/crotwell/dev/gradlePlugins/testDownload/build.gradle' using BuildScriptClasspathScriptTransformer.
file or directory '/Users/crotwell/.gradle/caches/artifacts-8/filestore', not found
Resource missing. [HTTP GET: http://gradle-macappbundle.googlecode.com/bmuschko/gradle-izpack-plugin/0.2.1/ivy-0.2.1.xml]
file or directory '/Users/crotwell/.gradle/caches/artifacts-8/filestore', not found
Resource missing. [HTTP GET: http://gradle-macappbundle.googlecode.com/files/gradle-izpack-plugin-0.2.1.xml]
Resource missing. [HTTP HEAD: http://gradle-macappbundle.googlecode.com/bmuschko/gradle-izpack-plugin/0.2.1/gradle-izpack-plugin-0.2.1.jar]
Resource missing. [HTTP HEAD: http://gradle-macappbundle.googlecode.com/files/gradle-izpack-plugin-0.2.1.jar]
file or directory '/Users/crotwell/.gradle/caches/artifacts-8/filestore', not found
Resource missing. [HTTP GET: http://www.seis.sc.edu/FAKE_URL/not_a_real_file.txt/]
Resource found. [HTTP HEAD: http://cloud.github.com/downloads/bmuschko/gradle-izpack-plugin/gradle-izpack-plugin-0.2.1.jar]
file or directory '/Users/crotwell/.gradle/caches/artifacts-8/filestore', not found
Resource missing. [HTTP GET: http://gradle-macappbundle.googlecode.com/edu.sc.seis/gradle-macappbundle/1.0.3/ivy-1.0.3.xml]
file or directory '/Users/crotwell/.gradle/caches/artifacts-8/filestore', not found
Resource missing. [HTTP GET: http://gradle-macappbundle.googlecode.com/files/gradle-macappbundle-1.0.3.xml]
Resource missing. [HTTP HEAD: http://gradle-macappbundle.googlecode.com/edu.sc.seis/gradle-macappbundle/1.0.3/gradle-macappbundle-1.0.3.jar]
Resource missing. [HTTP HEAD: http://gradle-macappbundle.googlecode.com/files/gradle-macappbundle-1.0.3.jar]
file or directory '/Users/crotwell/.gradle/caches/artifacts-8/filestore', not found
Resource missing. [HTTP GET: http://www.seis.sc.edu/FAKE_URL/not_a_real_file.txt/]
Failed to get resource: HEAD. [HTTP HTTP/1.0 403 Forbidden: http://cloud.github.com/downloads/edu.sc.seis/gradle-macappbundle/gradle-macappbundle-1.0.3.jar]
  FAILURE: Build failed with an exception.
  * What went wrong:
Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve group:edu.sc.seis, module:gradle-macappbundle, version:1.0.3.
  Required by:
      :testDownload:unspecified
   > Could not HEAD 'http://cloud.github.com/downloads/edu.sc.seis/gradle-macappbundle/gradle-macappbundle-1.0.3.jar'. Received status code 403 from server: Forbidden
  * Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
  BUILD FAILED
  Total time: 4.287 secs
------------------------------------------------------------
Gradle 1.0-milestone-8a
------------------------------------------------------------
  Gradle build time: Monday, February 20, 2012 4:00:18 PM UTC
Groovy: 1.8.4
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_29 (Apple Inc. 20.4-b02-402)
OS: Mac OS X 10.7.3 x86_64