ExternalResourceResolver uses wrongly built url to resolve Ivy dependencies on Windows


(mb) #1

Hello there.

Gradle v1.5 I’m using the following to hook up my local ivy repository:

repositories {
    ivy {
        url "file:///foo/bar/ivyrepo/"
    }
}
  uploadArchives {
    repositories {
        ivy {
            url "file:///foo/bar/ivyrepo/"
        }
    }
}

This works ok on OSX. Dependencies are resolved ok.

On Windows I use the repo URL:“file:///z:/foo/bar/ivyrepo/” there however the ivy URL is somehow concatenated to the project folder which of course results in dependencies cannot be resolved. 08:27:29.991 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Loading Z:\path\to\project"file:\z:\foo\bar\ivyrepo"/commons-io/commons-io/2.4/ivy-2.4.xml

This doesn’t seen correct to me. Is there something I’m missing here?

Regards, Manfred


(mb) #2

Ahh, I forgot.

On OSX the resolver lookup path is this:

21:20:19.036 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Loading /foo/bar/ivyrepo/commons-io/commons-io/2.4/ivy-2.4.xml

This is correct. Why is the project path prefixed on Windows?

Regards, Manfred


(Luke Daley) #3

Can you post the actual code you use on Windows please.


(mb) #4

That’s my build.gradle script:

apply plugin: 'scala'
apply from: '../../../Libs/Gradle/scripts/release.gradle'
apply from: '../../../Libs/Gradle/scripts/ivyrepo.gradle'
apply from: '../../../Libs/Gradle/scripts/buildnumber.gradle'
apply from: '../../../Libs/Gradle/scripts/integTest.gradle'
apply from: '../../../Libs/Gradle/scripts/emma.gradle'
  archivesBaseName = 'foo-bar'
  sourceCompatibility = '1.6'
targetCompatibility = '1.6'
  group = 'com.nps'
  def depLog4j = 'log4j:log4j:1.2.17'
def depSlf4j = ['org.slf4j:slf4j-api:1.7.2', 'org.slf4j:slf4j-log4j12:1.7.2']
def depCommonsIo = 'commons-io:commons-io:2.4'
def depScala = ['org.scala-lang:scala-library:2.9.2']
def depDeMabeScalaUtils = [group:'de.mabe', name:'scala-utils', version:'0.1.3', transitive:false]
def depDeMabeScalaUtilsTest = [group:'de.mabe', name:'scala-utils', version:'0.1.3', classifier:'test', transitive:false]
  def depJUnit = 'junit:junit:4.11'
  dependencies {
    scalaTools 'org.scala-lang:scala-compiler:2.9.2'
      compile depCommonsIo, depLog4j, depSlf4j, depScala, depDeMabeScalaUtils
    testCompile depJUnit, depDeMabeScalaUtilsTest
}
  // this is necessary to have the correct version when jar is created
gradle.taskGraph.whenReady {taskGraph ->
    ext.sharedManifest.attributes['Implementation-Version'] = version+'.'+buildNumber()+'.'+new Date().getTime()
}
  ext.sharedManifest = manifest {
    attributes("Implementation-Title": project.name)
}
  jar {
    enabled = true
    manifest = project.manifest {
        from sharedManifest
    }
}
  task testJar(type: Jar) {
    dependsOn testClasses
    from sourceSets.test.output.classesDir
    classifier = 'test'
    manifest = project.manifest {
        from sharedManifest
    }
}
  artifacts {
    archives jar
    archives testJar
}

In gradle.properties I’ve got:

version = 0.7.0
ivyRepoUrl = "file:///z:/foo/bar/ivyrepo/"

In ivyrepo.gradle there is:

repositories {
    ivy {
        url ivyRepoUrl
    }
}
  uploadArchives {
    repositories {
        ivy {
            url ivyRepoUrl
        }
    }
}

(mb) #5

Code is the same on OSX and Windows except for the ivyRepoUrl property which is to be changed when run on Windows and OSX respectively.

Manfred


(Luke Daley) #6

This is really strange.

Do you get the right file if you do this?

println new File(new URI("file:///z:/foo/bar/ivyrepo/")).absolutePath

(mb) #7

That’s what I get: “z:\foo\bar\ivyrepo” which looks ok.

Manfred


(Luke Daley) #8

As a workaround, try:

ivyRepoUrl = new URI("file:///z:/foo/bar/ivyrepo/")

I’ll investigate into what’s going on in a little bit.


(mb) #9

This works as a workaround, thanks. If you find this is a bug and got a Jira id, please let me know.

regards, Manfred


(Luke Daley) #10

Raised as GRADLE-2757.


(René Groeschke) #11

Hello Manfred, I’m currently trying to reproduce GRADLE-2757 with gradle from the latest nightly with the following script:

apply plugin:'java'
  repositories {
    ivy {
        url "file:///c:/tmp/gradle-2757/ivyrepo/"
    }
}
  uploadArchives {
    repositories {
        ivy {
            url "file:///c:/tmp/gradle-2757/ivyrepo/"
        }
    }
}
  configurations{
 acme
}
  dependencies{
 acme "group:project:1.0-SNAPSHOT"
}
  task resolve << {
 println configurations.acme.asPath
}

this code works fine for me on windows 7 professional. Can you reproduce this problem with the latest gradle version?

cheers, René


(bergmannmd) #12

Hello, I’ve tried with “gradle-1.9-20130904230915+0000-bin” where the problem still persists. If this is not aversion where this should be fixed in, could you please paste a download link.

Thanks, Manfred


(René Groeschke) #13

could you change your version properties to remove the quotes from the file uri

ivyRepoUrl = file:///z:/foo/bar/ivyrepo/

(bergmannmd) #14

Are quotes not allowed here?


(René Groeschke) #15

no you shoud get rid of the quotes, then it should work