Gradle uses a stale cached ivy.xml file instead of most recent pom from repository


(Paudi Moriarty) #1

I’m having a problem where Gradle (1.9) seems to be using an ivy.xml file from .gradle/caches/modules-2/metadata-2.1/descriptors/… for a changing dependency instead of the latest pom from the repository. The ivy.xml file in the cache is a couple of weeks old and doesn’t include recently added dependencies (which is how I know it’s being used and how I discovered this).

I’m not using Ivy with Gradle. Instead we run our own Nexus repository which is the only repository configured for this build.

I’ve run with --refresh-dependencies but still the old ivy.xml file is used.

I have no ivy configuration for the main project of the stale dependency (which I also manage) so I imagine Gradle is creating the ivy.xml file for it’s own purposes but I can’t find any documentation to confirm this. There are no ivy.xml files in my repository. Still, gradle claims “Ivy file found for module ‘io.aviso#core-services;1.2-SNAPSHOT’ in repository ‘annadale’.”

What am I missing here?

Here is the relevant debug output: 15:28:38.286 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Sending request: HEAD /nexus/content/groups/public/io/aviso/core-services/1.2-SNAPSHOT/core-services-1.2-20131218.115939-38.pom HTTP/1.1 15:28:38.286 [DEBUG] [org.apache.http.headers] >> HEAD /nexus/content/groups/public/io/aviso/core-services/1.2-SNAPSHOT/core-services-1.2-20131218.115939-38.pom HTTP/1.1 15:28:38.287 [DEBUG] [org.apache.http.headers] >> Accept-Encoding: gzip,deflate 15:28:38.287 [DEBUG] [org.apache.http.headers] >> Host: mvn.annadaletech.com 15:28:38.287 [DEBUG] [org.apache.http.headers] >> Connection: Keep-Alive 15:28:38.287 [DEBUG] [org.apache.http.headers] >> User-Agent: Gradle/1.9 (Linux;3.2.0-39-generic;amd64) (Oracle Corporation;1.7.0_17;23.7-b01) 15:28:38.292 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 200 OK 15:28:38.293 [DEBUG] [org.apache.http.headers] << HTTP/1.1 200 OK 15:28:38.293 [DEBUG] [org.apache.http.headers] << Date: Wed, 18 Dec 2013 15:28:38 GMT 15:28:38.293 [DEBUG] [org.apache.http.headers] << Server: Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V8 15:28:38.293 [DEBUG] [org.apache.http.headers] << Content-Type: application/xml 15:28:38.293 [DEBUG] [org.apache.http.headers] << Last-Modified: Wed, 18 Dec 2013 11:59:39 GMT 15:28:38.294 [DEBUG] [org.apache.http.headers] << ETag: “{SHA1{8c08a5145a425b6fbe045f6bd211e547d5fec078}}” 15:28:38.294 [DEBUG] [org.apache.http.headers] << Vary: Accept-Charset,Accept-Encoding,Accept-Language,Accept 15:28:38.294 [DEBUG] [org.apache.http.headers] << X-Content-Type-Options: nosniff 15:28:38.294 [DEBUG] [org.apache.http.headers] << Content-Length: 1325 15:28:38.295 [DEBUG] [org.apache.http.headers] << Set-Cookie: rememberMe=deleteMe; Path=/nexus; Max-Age=0; Expires=Tue, 17-Dec-2013 15:28:38 GMT 15:28:38.295 [DEBUG] [org.apache.http.headers] << Keep-Alive: timeout=5, max=60 15:28:38.295 [DEBUG] [org.apache.http.headers] << Connection: Keep-Alive 15:28:38.296 [DEBUG] [org.apache.http.client.protocol.ResponseProcessCookies] Cookie accepted: “[version: 0][name: rememberMe][value: deleteMe][domain: mvn.annadaletech.com][path: /nexus][expiry: Wed Dec 18 15: 28:38 GMT 2013]”. 15:28:38.296 [DEBUG] [org.apache.http.impl.client.SystemDefaultHttpClient] Connection can be kept alive for 5000 MILLISECONDS 15:28:38.296 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection [id: 1][route: {s}->https://mvn.annadaletech.com] can be kept alive for 5000 MILLISECONDS 15:28:38.297 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection released: [id: 1][route: {s}->https://mvn.annadaletech.com][total kept alive: 1; route allocated: 1 of 5; total allocat ed: 1 of 10] 15:28:38.297 [INFO] [org.gradle.api.internal.externalresource.transfer.DefaultCacheAwareExternalResourceAccessor] Cached resource is up-to-date (lastModified: Wed Dec 18 11:59:39 GMT 2013). [HTTP: https://mvn.a nnadaletech.com/nexus/content/groups/public/io/aviso/core-services/1.2-SNAPSHOT/core-services-1.2-20131218.115939-38.pom] 15:28:38.298 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Downloading https://mvn.annadaletech.com/nexus/content/groups/public/io/aviso/core-services/1.2-SNAPSHOT/c ore-services-1.2-20131218.115939-38.pom to /tmp/gradle_download2352952749938498612bin 15:28:38.303 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Ivy file found for module ‘io.aviso#core-services;1.2-SNAPSHOT’ in repository ‘annadale’. 15:28:38.303 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.DefaultModuleMetaDataCache] Recording module descriptor in cache: io.aviso#core-services;1.2-SNAPSHOT [changing = true] 15:28:38.304 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Using module ‘io.aviso:core-services:1.2-SNAPSHOT’ from repository ‘annadale’


(Peter Niederwieser) #2

Please show how the relevant repository and dependency declarations, along with output of ‘gradle -v’.


(Paudi Moriarty) #3

Hi,

The configuration is pretty straight-forward. One thing I forgot to mention is that we use maven-publish plugin.

The offending ivy.xml file (in …/modules-2/metadata-2.1/…) appears to be created by ‘gradle build’ but ‘gradle --refresh-dependencies build’ is not updating the file.

Interestingly, the ivy.xml file has the following info section:

<info organisation="io.aviso"
        module="core-services"
        revision="1.2-SNAPSHOT"
        status="integration"
        publication="19700101005959"
    >

The publication date looks curious and is always the same. Could this explain why it’s not being updated?

repositories {
    maven {
      name "annadale"
      url "https://mvn.annadaletech.com/nexus/content/groups/public"
    }
  }
    dependencies {
    // This has a transitive dependency on io.aviso:core-services:1.2-SNAPSHOT
    compile "io.aviso:harness:1.2-SNAPSHOT"
  }
      apply plugin: "maven-publish"
    task("sourceJar", type : Jar) {
     classifier = 'sources'
     from p.sourceSets.main.allSource
  }
    publishing {
    publications {
      jar(MavenPublication) {
        from components.java
          artifact (sourceJar) {
            classifier = 'sources'
          }
        }
      }
      repositories {
        maven {
          url "https://mvn.annadaletech.com/nexus/content/repositories/${version.endsWith('-SNAPSHOT') ? 'snapshots' : 'releases'}"
          credentials {
            username = mavenUser
            password = mavenPassword
          }
        }
      }
    }
------------------------------------------------------------
Gradle 1.9
------------------------------------------------------------
  Build time:
 2013-11-19 08:20:02 UTC
Build number: none
Revision:
   7970ec3503b4f5767ee1c1c69f8b4186c4763e3d
  Groovy:
     1.8.6
Ant:
        Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
        2.2.0
JVM:
        1.7.0_17 (Oracle Corporation 23.7-b01)
OS:
         Linux 3.2.0-39-generic amd64

(Paudi Moriarty) #4

The ivy.xml file seems to be created in the cache while building the project that depends on it and not when building or publishing the dependency.


#5

Gradle thinks that the cached version of your POM is the same as the one it would download, so it avoids downloading and uses the cached version. Gradle does this to avoid downloading the actual file if it actually hasn’t changed since last time.

The detection will assume the remote file is unchanged if:

  1. The server timestamp and content-length haven’t changed since last downloading, OR
  2. The HTTP etag hasn’t changed since last downloading.
Maybe there is something in your nexus configuration that makes Gradle think the remote POM file is the same as the one previously downloaded?

(You can ignore the ivy.xml file under ‘metadata-2.1/descriptors’. This is Gradle’s internal meta-data cache, which still uses the ivy format for persistence.)