How to reference another sourceDirectorySet from a sourceDirectorySet?


(now_feel) #1

I’m using gradle 1.11

sourceSets {
    sourceSetA {
         java {
            srcDir 'src/ui/src'
            exclude 'org/test/ui/testUiColor.java'
            exclude 'org/test/ui/autoMatch.java'
            exclude 'org/test/ui/core/testUiCore.java'
        }
    }
    main {
        manifest.srcFile 'src/myPackage/app/AndroidManifest.xml'
        java {
            srcDir 'src/myPackage/app/src'
            srcDir 'src/myPackage/content/java'
            srcDir 'src/myPackage/base/ui/java'
            srcDir 'src/myPackage/components/java'
            // I want to reference sourceDirectorySet in sourceSet A
            source sourceSets.sourceSetA.java
        }
    }
}

I saw http://www.gradle.org/docs/1.11/javadoc/org/gradle/api/file/SourceDirectorySet.html

source SourceDirectorySet source(SourceDirectorySet source)

Adds the given source to this set. Parameters:source - The source to add.Returns:this

when i build by ‘gradle build’ i got an error like below

  • Where: Build file ‘/home/myaccout/myPackage/build.gradle’ line: xxx

  • What went wrong: A problem occurred evaluating root project ‘myPackage’. > Could not find method source() for arguments on source set main.