How do I use files from a flat file repository?

Hi there

I’m trying to create and use a flat file repository for varoius dependencies. But for some reason, I cannot make it work when using … files, (such as in my example below)

It appears that Gradle finds the file, but the java compilation fails because it cannot find the relevant jar and class files.

apply plugin: 'java'
  def File artifactRepositoryRoot = new File('some local file path')
  repositories {
    flatDir dirs: [
         "${artifactRepositoryRoot}" // containing the file and commons-email-1.2.jar
  dependencies {
    compile name: 'apache-ant', version: '1.7.0', classifier: 'bin', ext: 'zip'
    compile name: 'commons-email', version: '1.2'
  task listJars << { // Does list both and commons-email-1.2.jar with correct path
    println '-------
Jars for compile time: -------------'
    configurations.compile.each { file -> println file.absolutePath }
    println '---------------------------------------------'

Help urgently needed - thank you in advance!

// Povl

You need to put the Jar(s) on the class path, not the zip that contains them. Best put the Jars into the flat dir repository to begin with.

Thank you for your quick reply, Peter. It’s highly appreciated!

I can see that it works if I unzip the -file myself and point to its lib directory. It’s certainly also an easy way to “harvest” various libraries.

Still, shouldn’t the classifier: ‘bin’, ext: ‘zip’ work in the above, or does these parameters serve another purpose? (I’m new to Gradle and Groovy, so pardon my lack of knowledge her)

Thanks again.

// Povl

‘classifier’ and ‘ext’ are just for telling Gradle which artifact you want. There are no further semantics associated with them.