Buildscript classpath used in buildSrc plugin no longer working with latest 1.12 2014-03-01

(x1000) #1

I just updated from 1.12 2014-02-05 to 2014-03-01 and got a problem with the buildscript classpath:


buildscript {
  dependencies {
    classpath files('Extern/gradle/ant.lib/p4java.jar')

it seems that our plugins built in buildSrc/… can no longer find the classes defined in the buildscript classpath.

It worked in 1.12 2014-02-05.

Anyone knows how to fix this ?

(Luke Daley) #2

Can you explain this a little more?

It sounds like you have classes in buildSrc, that depend on classes that you add to the build’s build.gradle file. Is that it?

(x1000) #3

I have a plugin that calls

public void apply(Project project) {
   project.apply from: ...some script....

In this script I do

buildscript {
  dependencies {
    classpath files('Extern/gradle/ant.lib/ivyp4.jar')
repositories {
   add(new com.orga.ivy.plugins.p4resolver.P4Resolver()) {

With the latest 1.12 it complains that it cannot find class com.orga.ivy.plugins.p4resolver.P4Resolver (which is in the jar defined before).

(Luke Daley) #4

I’m having trouble reproducing your problem.

Would you be able to supply a small project that I can run to experience the problem?

(x1000) #5

While trying to get a small repo running I tracked down the problem to the classpath files(…).

Using an absolute path seems to work:

buildscript {
  dependencies {
    classpath fileTree(dir: rootDir.absolutePath + '/Extern/gradle/ant.lib', includes:['ivyp4.jar','p4java.jar'])
    // worked for 1.7, but not with 1.12: classpath files('Extern/gradle/ant.lib/ivyp4.jar')

(Luke Daley) #6

Where is this ‘Extern’ directory in relation to the project root?

(x1000) #7

Its like this


The buildSrc plugin is also applied it the rootProject. Applying it in the SubProject fails with files(…) .

Is there a way to define a repository only once and have all projects inherit this ? Currently it looks like every sub-project will instantiate its own resolver.

(Luke Daley) #8

I actually don’t understand why this ever worked, it shouldn’t have.

Can you please try:

buildscript {
  dependencies {
    classpath rootProject.files('Extern/gradle/ant.lib/ivyp4.jar')