简体   繁体   中英

Gradle will cache an 8MB jar, but not a 32MB jar

I have a build I'm moving from Maven to Gradle. So far, things haven't been too bad, and honestly I'm likely Gradle a lot.

Here's the problem I'm running into and the docs haven't been much help. I have two internal jars that my code depends on. Let's call one 'core' and the other 'tests'. They are coming from another internal team, and the Maven repository is internal to us. They are mega-jars: 'core' is 8MB and 'tests' is 32MB in size. All the external jars I depend on are not a problem. And before you ask, my repository and dependency definitions are fine, gradle doesn't complain and can locate everything just fine. Here they are for posterity:

repositories {
    mavenCentral()
    maven {
      url { 'http://internal.host.com/path/to/repo/root/' }
    }
}

dependencies {
    compile group: 'io.dropwizard', name: 'dropwizard.core', version: dropwizardVersion
    // And so on

    // This is the 8MB jar that I need at compile and runtime
    compile group: 'corp.group.id', name: 'core', version: currentVersion

    // This is the 32MB jar that I need for my tests, and which Gradle insists on 
    // caching the pom.xml ONLY, and downloading the jar on demand.
    testCompile group: 'corp.group.id', name: 'tests', version: currentVersion
} 

At this point, I'm simply trying to get 'gradlew eclipse' to generate valid .classpath files that I can use to work on this codebase and massage it into compiling. Here's the kicker. The generated .classpath file doesn't have any reference to the tests-version.jar file. Gradle has downloaded the POM happily and cached it, but it keeps re-downloading the jar each and every time it feels it needs it. The core-version.jar file it's downloaded exactly once (as expected) and cached and it shows up in the generated .classpath file.

I can't seem to locate any documentation that will tell Gradle "just keep the darn jar in your cache, no matter what, please. No really, I don't care how big the damn thing is, it's better than downloading it every time."

It's probably bad form to answer your own question, but I'd like to leave a record for posterity in case anyone else comes across this problem.

The issue, which hasn't yet been resolved, is that the Nexus 2.3.0 server failed to completely send the entire jar. When requesting the jar (via curl, wget, Gradle, Maven) closer to the server and the download rate is significantly higher, everything works fine. But when I'm doing it from the remote location (Sunnyvale to Toronto) and the rate goes from 15M/s to 1.2M/s or less, then Nexus is failing to send the last bits for some reason. And it doesn't seem to matter how long the transfer takes. I've seen it vary between 18 to 35 seconds. And the amount of data cut off varies as well, from 5176 bytes to 34876 bytes.

The challenging thing here is that Gradle gave no indication that the download actually failed, in any form. Using --info or --debug didn't help. There was no error message saying that the server had prematurely terminated the connection.

When we get this fully resolved I'll update this answer.

Edit : Still haven't resolved this, although it's starting to look like a networking issue rather than a Nexus server error. As far as error messages go, this did fly by on a full rebuild of ~/.gradle (resource name obviously obscured):

Forcing close on abandoned resource: Http GET Resource: http://corp.server.com/nexus/content/repositories/repo-name/gid/aid/version-number/artifact.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM