Dependency resolving take a long time when using Groovy's HttpBuilder


(Yan-hong Lin) #1

I have a small program using Groovy’s HttpBuilder, so build.gradle contains following settings:

dependencies {

compile ‘org.codehaus.groovy.modules.http-builder:http-builder:0.5.1’ }

But it always take a long time (>30secs) to resolve dependency when gradle running. Is there any solution for do it quickly? Maybe force skip the full dependency check. Thanks a lot.


(Adam Murdoch) #2

Which Gradle version are you using? You might want to try the 1.0-milestone-6 snapshot, which contains many performance improvements for dependency resolution: http://forums.gradle.org/gradle/topics/new_gradle_1_0_milestone_6_snapshot_available-1js19c


(Luke Daley) #3

HttpBuilder uses a very large version range for Groovy which causes this overhead.

If you exclude the groovy dependency from http-builder and specify your own specific version it will be much faster.


(Yan-hong Lin) #4

Thanks!

“exclude” works!

dependencies {
        groovy 'org.codehaus.groovy:groovy-all:1.8.3'
        compile ('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1')
{
                exclude group: 'org.codehaus.groovy', modules: 'groovy'
        }
}

(amin.zamani) #5

Hallo,

First Problem:

I have following gralde build script:

buildscript {

repositories {

maven {

credentials {

username repoUsername

password repoPassword

}

url ‘http://our-url

}

// Add here your classpath libs / build dependencies

dependencies {

classpath “org.codehaus.groovy.modules.http-builder:http-builder:0.5.2”

}

} }

When I try to run a task, where the http Builder class is used, I get following error: --------------- startup failed:

[exec] Script1.groovy: 1: unable to resolve class groovyx.net.http.HTTPBuilder

[exec] @ line 1, column 1.

[exec]

new groovyx.net.http.HTTPBuilder( “http://${x}:${y}”)

[exec]

^

[exec] 1 error ----------------

What do I do false?

Second Problem: So I have tried to do add the build dependecy so: -------------------- configurations{ buildDependencies }

dependencies {

buildDependencies( ‘org.codehaus.groovy.modules.http-builder:http-builder:0.5.2’ ) { exclude group:‘org.codehaus.groovy’, module:‘groovy’ }

}

// add libs to script classpath

configurations.buildDependencies.each {File file -> GroovyObject.class.classLoader.addURL(file.toURL());} ---------------------

As you see, I add the build dependency to the class path. The most time I run that tasks of this scripts, it is no problem. But sometimes, when I set up a new project and many libs must be downloaded I get an error. Then, when I comment out the line “buildDependencies( ‘org.codehaus.groovy.modules.http-builder:http-builder:0.5.2’ ) { exclude group:‘org.codehaus.groovy’, module:‘groovy’ }” I have no problem, it works. Then after the dependencies are downloaded, I can make the builddependency line active.

So how is it possible to use the “org.codehaus.groovy.modules.http-builder:http-builder:0.5.2” ?? Without getting errors? I thank you very much for answering and help me fixing that problem!

It should be possible to use 'classpath “org.codehaus.groovy.modules.http-builder:http-builder:0.5.2” ’ in my dependency, but it is not possible. So what is the wayx to use that dependency without getting errors?

Thanks very much for you help!


(amin.zamani) #6

Hi,

can some one tell me why I get following error when I have the following part inside my buildscript:

dependencies {
 classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.5.2"
 testCompile 'junit:junit:4.8.2'
   }

That is the error message:

Could not find method classpath() for arguments [org.codehaus.groovy.modules.http-builder:http-builder:0.5.2] on root project ‘AlfrescoPlugin’.

Thanks very much for your help

Shalom Amin Zamani


(amin.zamani) #7

That is all the buildscript:

apply plugin: 'groovy'
apply plugin: 'eclipse'
  dependencies {
    compile gradleApi()
    groovy localGroovy()
     }
  apply plugin: 'maven'
  repositories {
   maven {
   credentials {
    username artifactoryRepoUsername
    password artifactoryRepoPassword
   }
   url 'http://xyz'
  }
    maven {
   credentials {
    username artifactoryRepoUsername
    password artifactoryRepoPassword
   }
   url 'http://xyz'
  }
        }
      dependencies {
 classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.5.2"
 testCompile 'junit:junit:4.8.2'
   }
  group = 'com.westernacher.gradle.plugins'
version = '1.0.0-SNAPSHOT'
    uploadArchives {
 repositories {
  mavenDeployer {
    repository(url: 'http://xyz'){
    authentication(userName: artifactoryRepoUsername, password: artifactoryRepoPassword)
   }
  }
 }
}

(René Groeschke) #8

the classpath configuration is not available here. if you want to use the httpbuilder lib in your build scripts you have to configure the classpath within a buildscript {} closure.