In gradle 2.4 release notes, under section Potential breaking changes : Changes to default value for Java compilation sourcepath It is mentioned the the default value of ‘sourcepath’ is changed (from analysis, it seems like it is set to an empty folder).
Unfortunately in my case, this change actually broke the build, so the question is
Question:
How to configure the value of ‘sourcepath’ in case of a sourceSet?
You currently have to do this on the compile task. This test in the Gradle codebase shows this:
settingsFile << "include 'a', 'b'"
buildFile << """
subprojects {
apply plugin: 'java'
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:all' << '-Werror'
}
}
project(':b') {
dependencies {
compile project(':a')
}
}
"""
file("a/src/main/resources/Foo.java") << "public class Foo {}"
file("b/src/main/java/Bar.java") << "public class Bar extends Foo {}"
expect:
fails("compileJava")
Specifically…
run("compileJava")
then:
file("b/build/classes/java/main/Bar.class").exists()
file("b/build/classes/java/main/Foo.class").exists()
}
@Issue("https://issues.gradle.org/browse/GRADLE-3508")
def "detects change in classpath order"() {
jarWithClasses(file("lib1.jar"), Thing: "class Thing {}")
jarWithClasses(file("lib2.jar"), Thing2: "class Thing2 {}")
file("src/main/java/Foo.java") << "public class Foo {}"
buildFile << buildScriptWithClasspath("lib1.jar", "lib2.jar")
when:
run "compile"
then:
nonSkippedTasks.contains ":compile"
when:
run "compile"
Hi Luke,
I will check it out and let you know.
Thank You
Hi Luke,
I have tried it out and it is working.
Question:
Is there a way to specify the ‘sourcepath’ in the ‘sourceSet’, instead of adding it to the task?
Thank You
Not at the moment. There’s nothing scheduled to do this.
Hi Luke,
Thank you for getting back.