src
main/java
test/java
The test does not depend on main for compiling. Tying to compile and run test on another library replacing main.
sourceSets {
remove main
}
gradle test
It will always compile the main source set.
src
main/java
test/java
The test does not depend on main for compiling. Tying to compile and run test on another library replacing main.
sourceSets {
remove main
}
gradle test
It will always compile the main source set.
你可以试试sourceSets.remove(sourceSets.main)
作为https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/SourceSetContainer.htmlsourcesets {}
的代表