获取SourceSet完整路径字符串或路径目录

时间:2016-01-12 11:17:32

标签: gradle gradle-plugin source-sets

我想知道是否有一个属性返回SourceSet完整路径字符串或文件目录,如${project.projectDir}/src/${sourceSet.name}

apply plugin: 'java'

sourceSets {
    foo {
        java {
            srcDir 'example/dir/java'
        }
    }
}

// For example, this could return pathToProject/src/example/dir
println sourceSets.foo.srcDir

1 个答案:

答案 0 :(得分:2)

尝试一下:

productFlavors {
    admin { }
    customer { }
}

sourceSets {
    main {
        java.srcDirs = ['src/main']
        //other typical sourceSets stuff
    }

    admin.java.srcDirs = ['src/admin']
    customer.java.srcDirs = ['src/customer']
}