Groovy dependency configuration does not appear to support files or fileTree dependency notations

Hi,

I am trying to use a Groovy installation as the provider of the groovy library for my builds.

This requires specifying the groovy library to the build without using the normal repository.

This snippet will work, and Gradle will pick up the groovy-1.8.4.jar and use it for compiling etc:

repositories {
    flatDir { dirs 'C:/Groovy/Groovy/lib' }
}
dependencies {
    groovy module( ':groovy:1.8.4' )
}

but this snippet:

dependencies {
    groovy files( 'C:/Groovy/Groovy/lib/groovy-1.8.4.jar' )
}

does not appear to work, despite the documentation suggesting it should:

“File dependencies allow you to directly add a set of files to a configuration, without first adding them to a repository”.

Have I misunderstood something here?

I’d like to avoid using a flat dir repository to the Groovy installation’s lib directory as this provides access to the other libraries that come with Groovy.

Thanks, Richard

I am using gradle-1.0-rc-1, by the way.

What exactly do you mean by ‘does not appear to work’? Please post the full error message and stack trace (’-s’). The ‘groovy’ Jar (without dependencies) isn’t enough; you’ll need ‘groovy-all’.

There is no stack trace - it just does not set up the dependency.

Simple build.gradle:

apply plugin: 'groovy'
  repositories {
    flatDir { dirs 'C:/Groovy/Groovy/embeddable' }
}
dependencies {
    groovy module( ':groovy-all:1.8.4' )
}

Output from above:

C:\mytemp\test for gradle>gradle dependencies
:dependencies
  ------------------------------------------------------------
Root project
------------------------------------------------------------
  archives - Configuration for archive artifacts.
No dependencies
  compile - Classpath for compiling the main sources.
\--- :groovy-all:1.8.4 [default]
  default - Configuration for default artifacts.
\--- :groovy-all:1.8.4 [default]
  groovy - The groovy libraries to be used for this Groovy project.
\--- :groovy-all:1.8.4 [default]
  runtime - Classpath for running the compiled main classes.
\--- :groovy-all:1.8.4 [default]
  testCompile - Classpath for compiling the test sources.
\--- :groovy-all:1.8.4 [default]
  testRuntime - Classpath for running the compiled test classes.
\--- :groovy-all:1.8.4 [default]
  BUILD SUCCESSFUL
  Total time: 3.651 secs

Change to:

apply plugin: 'groovy'
  dependencies {
    groovy files( 'C:/Groovy/Groovy/embeddable/groovy-all-1.8.4.jar' )
}

Output now:

C:\mytemp\test for gradle>gradle dependencies
:dependencies
  ------------------------------------------------------------
Root project
------------------------------------------------------------
  archives - Configuration for archive artifacts.
No dependencies
  compile - Classpath for compiling the main sources.
No dependencies
  default - Configuration for default artifacts.
No dependencies
  groovy - The groovy libraries to be used for this Groovy project.
No dependencies
  runtime - Classpath for running the compiled main classes.
No dependencies
  testCompile - Classpath for compiling the test sources.
No dependencies
  testRuntime - Classpath for running the compiled test classes.
No dependencies
  BUILD SUCCESSFUL
  Total time: 3.488 secs

And yes, you are right, it should be groovy-all-1.8.4.jar, which is in embeddable and not lib directory…

‘gradle dependencies’ doesn’t currently show non-repository dependencies. However, it’s just a display problem, and Groovy compilation/execution should work fine.