Compiler error - very strange problem with dependencies


(strug) #1

I’m a little lost:)

I have a simple gradle file where I added the groovy http-builder libraray:

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web:${springBootStarterVersion}"
  compile "org.springframework.boot:spring-boot-starter-actuator:${springBootStarterVersion}"
    testCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.6'
  }

Next I have a groovy test case with:

import org.junit.Test
import groovyx.net.http.RESTClient
  class MyContractTest {
    @Test
  public void testIt() {
    def client = new RESTClient("http://localhost:8000")
    def resp = client.get(path : "/")
      assert resp.status == 200
    assert resp.data.text == "Greetings from Spring Boot!"
  }
}

When I run ‘gradle compileTestGroovy’ I get:

/Users/leif.hanack/projects/sample/src/test/groovy/MyContractTest.groovy: 2: unable to resolve class groovyx.net.http.RESTClient
 @ line 2, column 1.
   import groovyx.net.http.RESTClient
   ^
  1 error

Checking the deps show me that the lib is part of the classpath:

..
testCompile - Compile classpath for source set 'test'.
+--- org.codehaus.groovy:groovy-all:2.1.1
+--- org.springframework.boot:spring-boot-starter-web:1.0.0.RC1
|
  +--- org.springframework.boot:spring-boot-starter:1.0.0.RC1
..
\--- org.codehaus.groovy.modules.http-builder:http-builder:0.6
     +--- org.apache.httpcomponents:httpclient:4.2.1
     |
  +--- org.apache.httpcomponents:httpcore:4.2.1
     |
  +--- commons-logging:commons-logging:1.1.1
     |
  \--- commons-codec:commons-codec:1.6
     +--- net.sf.json-lib:json-lib:2.3
     |
  +--- commons-beanutils:commons-beanutils:1.8.0
     |
  |
  \--- commons-logging:commons-logging:1.1.1
     |
  +--- commons-collections:commons-collections:3.2.1
     |
  +--- commons-lang:commons-lang:2.4
     |
  +--- commons-logging:commons-logging:1.1.1
     |
  \--- net.sf.ezmorph:ezmorph:1.0.6
     |
       \--- commons-lang:commons-lang:2.3 -> 2.4
     +--- org.codehaus.groovy:groovy:1.8.8
     |
  +--- antlr:antlr:2.7.7
     |
  +--- asm:asm:3.2
     |
  +--- asm:asm-commons:3.2
     |
  |
  \--- asm:asm-tree:3.2
     |
  |
       \--- asm:asm:3.2
     |
  +--- asm:asm-util:3.2
     |
  |
  \--- asm:asm-tree:3.2 (*)
     |
  +--- asm:asm-analysis:3.2
     |
  |
  \--- asm:asm-tree:3.2 (*)
     |
  \--- asm:asm-tree:3.2 (*)
     +--- net.sourceforge.nekohtml:nekohtml:1.9.16
     |
  \--- xerces:xercesImpl:2.9.1
     |
       \--- xml-apis:xml-apis:1.3.04
     \--- xml-resolver:xml-resolver:1.2

Next I tried that code on another machine and it worked! I checked that I have the same versions for groovy, gradle, IntellijIdea, but that simple test won’t compile.

Did anyone have had such a strange problem?

Thanks a lot for any pointer!

Regards, Leif


(René Groeschke) #2

The first thing I would check is, if it’s working on a clean cache. try building with “-g .” to relocate the cache for the build


(strug) #3

Thanks Rene, unfortunately it doesn’t helped.


(René Groeschke) #4

hmm. hard to say what’s going wrong in your code. just double checked in on my machine and it works fine here. can you double check the compile classpath by adding

compileTestGroovy{
 doFirst{
  println classpath.asPath
 }
}

and checking if http-builder is listed?


(strug) #5

Mmmh?!

:/Users/leif.hanack/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy.modules.http-builder/http-builder/0.6/ca89dfdfdb9ef1d2c3eb4a7d6a96985f0d656fb9/http-builder-0.6.jar:

Weired!


(René Groeschke) #6

really weired. Have you tested if it makes a different to build it “with daemon” / “without daemon”? Do you have any other buildlogic (maybe injected by a parent project or auto applied init scripts) that might interfer here? really hard to say at this point what’s going on here


(strug) #7

I’ll retry it tonight with a striped down version and will let you know the results.

Thanks so far!


(strug) #8

Alrighty, I found the problem!

repositories {
    mavenLocal()
    maven {
      url project["nexus.public.url"]
      credentials {
        username project["nexus.username"]
        password project["nexus.password"]
      }
    }
    mavenCentral()
  }

The 2nd repository (“nexus.public.url”) points to our corporate network. If that is not reachable it seems as if the 3rd (mavenCentral) is not taken to resolve the dependencies.

If I comment out the corporate repository everything works as expected.

I have sent you a sample project which should help to reproduce it.

Regards, Leif