Hi all,
I have this issue where I’m trying to create the srcDirs using fileTree. This same code works with gradle plugin 1.5 but with gradle plugin 2.0+, it started giving out the following problem:
Error:Cannot convert the provided notation to a File or URI: directory 'src/A/java'.
The following types/formats are supported:
- A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
- A String or CharSequence URI, for example 'file:/usr/include'.
- A File instance.
- A URI or URL instance.
Here’s my gradle config snippet:
android {
buildToolsVersion 23.0.2
compileSdkVersion 23
defaultConfig {
...
}
buildTypes {
release {
minifyEnabled true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
flavorDimensions(FLAVOR_DIMEN_FEATURES, FLAVOR_DIMEN_ENV)
productFlavors {
nonprod {
dimension = FLAVOR_DIMEN_ENV
...
}
production {
dimension = FLAVOR_DIMEN_ENV
...
}
base {
dimension = FLAVOR_DIMEN_FEATURES
}
A {
dimension = FLAVOR_DIMEN_FEATURES
minSdkVersion 19
}
B {
dimension = FLAVOR_DIMEN_FEATURES
}
aB {
dimension = FLAVOR_DIMEN_FEATURES
minSdkVersion 19
}
}
sourceSets {
.
.
.
.
aB {
FileTree treeB = fileTree(dir: 'src/B/java',
include: '**/*',
excludes: ['**/A*', '**/X*', '**/Z/**'])
if (treeB != null) {
treeB.each {File file ->
println "treeB - " + file.getCanonicalPath()
}
}
FileTree treeA = fileTree(dir: 'src/A/java',
include: '**/*',
excludes: ['**/B*', '**/C*', '**/D/**'])
if (treeA != null) {
treeA.each {File file ->
println "treeA - " + file.getCanonicalPath()
}
}
java {
srcDirs = [treeA,treeB]
}
res.srcDirs = ['src/A/res', 'src/B/res']
}
}
}
The problem I’m trying to achieve here is combining features “A” and “B” and excluding duplicate classes which are existing in each other.
Please advise the best way to achieve this if the above is not an elegant solution. I was able to get this working in plugin 1.5 but after updating to 2.0 it started failing.
Thanks