Java – Gradle 1.1 vs 2.0: Could not determine the dependencies of task ‘:compileAcctJava’

gradlejava

Gradle 1.11 gives me a deprecation warning:

robert@pferdeapfel:~/prj> gradle --version | grep Gradle
Gradle 1.11

robert@pferdeapfel:~/prj> gradle compileJava
Converting class org.gradle.api.internal.file.DefaultSourceDirectorySet to File using
toString() method has been deprecated and is scheduled to be removed in Gradle 2.0.
Please use java.io.File, java.lang.String, java.net.URL, or java.net.URI instead.
:compileAcctJava
:processAcctResources UP-TO-DATE
:acctClasses
:resources
:acct UP-TO-DATE
:beans UP-TO-DATE
:svninfo UP-TO-DATE
:settings UP-TO-DATE
:compileJava UP-TO-DATE

BUILD SUCCESSFUL
Total time: 10.865 secs

and Gradle 2.0 fails the build:

robert@pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle --version | grep Gradle
Gradle 2.0

robert@pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle -i compileJava

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileAcctJava'.
> Cannot convert the provided notation to a File or URI: acct Java source.
  The following types/formats are supported:
    - A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
    - A String or CharSequence URI, e.g 'file:/usr/include'
    - A File instance.
    - A URI or URL instance.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option
to get more log output.

BUILD FAILED

Total time: 3.676 secs

However, I have no idea why and where in my build script the problem is.

I have defined source sets as described in http://www.gradle.org/docs/current/userguide/java_plugin.html#sec%3asource_sets like this cause my project does not follow the default project layout.

sourceSets {
    ...
    acct {
        java {
            srcDir "src"
            srcDirs("src") {
                include "my/program/some/package/Acct.java"
            }
        }
    }
    ...
}

I do have some dependencies defined, but not for acct; this is just a simple enum that's used as a base for code generation. It has no dependencies. Even if I add a dummy dependency like below, I get the same error.

dependencies {
    ...
    acctCompile junit
    ...
}

How can I fix this or how can I find out more about what exactly went wrong?

I don't find the output of Gradle's --debug and --stacktrace helpful at all.

Best Answer

There is no such notation as srcDirs("src") { include "my/program/some/package/Acct.java" }. Try:

sourceSets {
    acct {
        java {
            srcDirs = ["src"] // replaces default rather than adding another dir
            include "my/program/some/package/Acct.java"
        }
    }
}