How can I use the contents of a zip file in our repository as a dependency?

I have a (3rd party) zip file uploaded to our nexus repository. This zip file contains a number of jar files we use as a dependency for our project. I have the following code to add the jar files as a dependency, but I cannot get it working correctly.

configurations {
 birtRuntime {
  transitive = false
  dependencies {
 birtRuntime group:"org.eclipse.birt", name: "birt-runtime", version:"3.7.1", ext: "zip"
 compile zipTree(configurations.birtRuntime.getSingleFile()).matching({ include 'birt-runtime*/ReportEngine/lib/*'})

The error I get is: “Expected configuration ‘:birtRuntime’ to contain exactly one file, however, it contains no files.”

I have no clue where this message comes from. When using the zipTree functionality to add the files manually to our lib folder when executing the dist task, it works perfect.

I have tried multiple ways to solve this problem, but ran out of Ideas. Started using gradle like 2 weeks ago, so I don’t have much knowledge about it.


Couple of hints:

  • you can run gradle with -s and that will show you the stack trace * the exception you notice comes from the getSingleFile() method that makes an assertion that the file collection has exactly one file (and returns it obviously) * FYI: your declaration of the dependencies will trigger the birtRuntime configuration to get resolved at evaluation time because zipTree will need the file. * I suspect the problem is that your birtRuntime configuration does not resolve to any files. You can debug such problems by interrogating the dependencies of specific configuration, for example:
task showDeps << {
  println configurations.birtRuntime.files

First, though you need to remove the compile dependency to avoid the exception.

Hope that helps!