这里是我的解决方案:
apply plugin: 'java'
sourceSets {
main {
java {
srcDir = ['src']
exclude "main/*"
exclude "hello/*"
exclude "test/*"
}
}
}
我的文件夹布局:
$ ls -R src
Library.java hello main test
src/hello:
Application.java HelloController.java
src/main:
java
src/main/java:
Library.java hello
src/main/java/hello:
Application.java HelloController.java
src/test:
java
src/test/java:
LibraryTest.java
输出:
$ ./gradlew clean build -x test
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "srcDir" on "source set 'main'", value: "[src]".
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:check
:build
BUILD SUCCESSFUL
Total time: 2.935 secs
让我知道这是否正常工作。
'src/org/example/foo/barproject/ui'或'src/main/org/example/foo/barproject/ui'? – chenrui
@chenrui前者,如非标准'srcDirs' – user149408
所示,我认为这是Gradle 1.10,对不对? – chenrui