Support Android flavors
This commit is contained in:
+9
-7
@@ -33,20 +33,22 @@ public class AndroidSubplugin : KotlinGradleSubplugin {
|
||||
val sourceSets = androidExtension.getSourceSets()
|
||||
val mainSourceSet = sourceSets.getByName("main")
|
||||
|
||||
val resourceDir = mainSourceSet.getRes().getSrcDirs().firstOrNull()
|
||||
val resourceDirs = mainSourceSet.getRes().getSrcDirs()
|
||||
val manifestFile = mainSourceSet.getManifest().getSrcFile()
|
||||
|
||||
val compileDependencies = project.getConfigurations().getByName("compile").getFiles()
|
||||
val supportV4 = compileDependencies?.filter { it.name.startsWith("support-v4-") }?.isNotEmpty() ?: false
|
||||
val supportV4Property = if (supportV4) "true" else "false"
|
||||
|
||||
if (resourceDir != null) {
|
||||
resourceDir.listFiles { it.isDirectory() && it.name.startsWith("layout") }?.forEach { task.source(it) }
|
||||
if (resourceDirs.isNotEmpty()) {
|
||||
val resourceDirOptions = resourceDirs.map { resourceDir ->
|
||||
resourceDir.listFiles { it.isDirectory() && it.name.startsWith("layout") }?.forEach { task.source(it) }
|
||||
SubpluginOption("androidRes", resourceDir.getAbsolutePath())
|
||||
}
|
||||
return listOf(
|
||||
SubpluginOption("androidRes", resourceDir.getAbsolutePath()),
|
||||
SubpluginOption("androidManifest", manifestFile.getAbsolutePath()),
|
||||
SubpluginOption("supportV4", supportV4Property)
|
||||
)
|
||||
SubpluginOption("androidManifest", manifestFile.getAbsolutePath()),
|
||||
SubpluginOption("supportV4", supportV4Property)
|
||||
) + resourceDirOptions
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user