1
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.

4

1 回答 1

2

你可以试试sourceSets.remove(sourceSets.main)

作为https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/SourceSetContainer.htmlsourcesets {}的代表

于 2017-10-24T05:14:46.877 回答