Not all dependencies can be pulled from a local flatDir repo


#1

I need to work completely off-line. The reason is I have hundreds of parallel gradle builds that collide with eachother (many cache lock timeouts) if they use the same cache dir. So, to work around this, I use a separate cache dir for each build, which would require every build re-download all dependencies unless they are local.

I’ve been able to get this mostly working using this task to aggregate my dependencies into a local folder and including them in the distribution:

task archiveDependencies(type: Sync) {
    from configurations
    into "$buildDir/dependencyArchive"
}

I won’t get into the packaging, but the above dependencyArchive folder ends on on the target machine in the flatDir below.

repositories {
    flatDir(name: 'fileRepo', dirs: "/opt/nim/parserV4/lib/dependencyArchive")
}

It’s not ideal as I have to edit the script during installation to replace the actual maven repos with the above flatDir repo.

This works for everything except cobertura. I’m using the salisman cobertura fork as described here:

The error I get is:

07:48:40.468 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
07:48:40.468 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred configuring root project 'parserV4'.
07:48:40.469 [ERROR] [org.gradle.BuildExceptionReporter] > Could not resolve all dependencies for configuration ':classpath'.
07:48:40.469 [ERROR] [org.gradle.BuildExceptionReporter]
  > Could not find net.saliman:gradle-cobertura-plugin:2.1.0.

I have the gradle-cobertura-plugin-2.1.0.jar in the above flatDir.

Any idea why gradle is not finding it there?

If I remove cobertura from my build completely, the above solution works. However I’d like to leave it in there and avoid having to hack the script to bits on deployment just to satisfy some dependency requirements.


(Peter Niederwieser) #2

Perhaps you forgot to declare the ‘flatDir’ repo also inside ‘buildscript {}’?


#3

I have this in build.gradle when I’m building the dependencyArchive and constructing the deployable package

buildscript {
 repositories {
     mavenCentral()
 }
 dependencies {
     classpath "net.saliman:gradle-cobertura-plugin:2.1.0"
 }
}

Once deployed on the target this is updated to only use the flatDir:

buildscript {
 repositories {
                flatDir(name: 'fileRepo', dirs: "/opt/nim/parserV4/lib/dependencyArchive")
 }
 dependencies {
  classpath "net.saliman:gradle-cobertura-plugin:2.1.0"
 }
}

This is in the flatDir folder: -rwxrwxr-x 1 jetty adm 78506 Apr 30 08:34 /opt/nim/parserV4/lib/dependencyArchive/gradle-cobertura-plugin-2.1.0.jar <.code>


(Peter Niederwieser) #4

I don’t see why your ‘Sync’ task would copy ‘buildscript’ dependencies. I also don’t see why what you showed in your last post wouldn’t work.