Transitive dependencies from plugins


(detlef.brendle) #1

Hello,

I have written a plugin that has got dependencies to some external libraries like commons-io, jacoco… When I apply this plugin inside of a build script the external (transitive) dependencies are not part of the runtime classpath. Thats how it looks to me. I have written a small script and a plugin that shows the issue. The plugin is installed into my local maven repository with gradle install.

Maybe Im doing something wrong here, but I cant spot the error at the moment.

Thanks, detlef

Plugin build.gradle:

apply plugin: 'groovy'
apply plugin: 'maven'
  repositories {
  mavenCentral()
}
dependencies {
  compile gradleApi()
  groovy localGroovy()
  compile group: 'commons-io', name: 'commons-io', version: '2.1', ext: 'jar'
}
  group = 'com.xy'
version = '1.0.0'

Buildscript that applies this plugin:

apply plugin: 'test'
  buildscript {
  repositories {
    mavenLocal()
  }
  dependencies {
    classpath group: 'com.xy', name: 'myPlugin', version: '1.0.0', ext: 'jar'
  }
}

When I execute ‘gradle tasks’ for this buildscript the following error occurs:

ET22 C:\temp\gradlePlugin> call C:\Apps\gradle-1.0\bin\gradle tasks -i
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file 'C:\temp\gradlePlugin\build.gradle'.
Included projects: [root project 'gradlePlugin']
Evaluating root project 'gradlePlugin' using build file 'C:\temp\gradlePlugin\build.gradle'.
  FAILURE: Build failed with an exception.
  * Where:
Build file 'C:\temp\gradlePlugin\build.gradle' line: 1
  * What went wrong:
A problem occurred evaluating root project 'gradlePlugin'.
> org.apache.commons.io.FileUtils
  * Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

(René Groeschke) #2

Can you please publish the complete stacktrace by running your gradle build with ‘–stacktrace’ ? Maybe you run into a version conflict with commons io.

cheers, René


(Peter Niederwieser) #3

‘ext: ‘jar’’ is telling Gradle to just get that Jar, without any transitive dependencies. Leave it off and you should be fine.

PS: I much prefer the short dependency notation ‘“commons-io:commons-io:2.1”’.


(detlef.brendle) #4

THANKS Peter and Rene, I was completely blind on that eye. Now it works.

Thanks, detlef


Custom Gradle Plugin Transitive Dependencies