Gradle Add Sub-Module Src path under weaving AspectJ [ant:iajc] [error] build config error: bad sourceroot: /Users/abcd/mainApp/src/main/java

Gradle Add Sub-Module Src path under weaving AspectJ [ant:iajc] [error] build config error: bad sourceroot: /Users/abcd/mainApp/src/main/java

我有一个 Java 项目的多模块设置,结构如下。

mainApp
|--> core-module
|       |--> src
|       |--> build.gradle
|       
|--> lib-module
|       |--> src
|       |--> build.gradle
|--> lib-another-module
|       |--> src
|       |--> build.gradle
| 
|--> settings.gradle
|--> build.gradle
|--> gradle.properties

我在 mainApp/build.gradle 中提到过

compileJava {
    //dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileJava")

    doLast{
        ant.taskdef( resource:"org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: configurations.ajc.asPath)

        ant.iajc(
                maxmem: "1024m", fork: "true", Xlint: "ignore",
                destDir: sourceSets.main.output.classesDirs.asPath,
                aspectPath: configurations.aspects.asPath,
                sourceRootCopyFilter: "**/.svn/*,**/*.java",
                classpath: configurations.compile.asPath,
                source: project.sourceCompatibility,
                target: project.targetCompatibility
        ){
            sourceroots{
                sourceSets.main.java.srcDirs.each{
                    pathelement(location:it.absolutePath)
                }
            }
        }
    }
}

我遇到错误 [ant:iajc] [error] build config error: bad sourceroot: /Users/abcd/mainApp/src/main/java

如何将 sub-module src 指向 sourceroots{}

我可以解决这个问题。基本上我的 root-project 没有任何 source-code(它只是一个父 Gradle 模块容器)所以,它需要从 sourceRoots

中省略
sourceroots{
    sourceSets.main.java.srcDirs.each{
        if(!it.absolutePath.contains("/src/main/java")) {
             pathelement(location: it.absolutePath)
    }
}