1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 08:38:13 -07:00

Only generate BuildConfig if at least one buildConfig{} was found.

This commit is contained in:
Cedric Beust 2015-11-24 23:17:09 -08:00
parent 92922f7e07
commit 9f00303e9d

View file

@ -96,7 +96,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
} }
/** /**
* Generate BuildConfig.java. Also look up if any BuildConfig is defined on the current build type, * Generate BuildConfig.java if requested. Also look up if any BuildConfig is defined on the current build type,
* product flavor or main project, and use them to generate any additional field (in that order to * product flavor or main project, and use them to generate any additional field (in that order to
* respect the priorities). * respect the priorities).
*/ */
@ -105,6 +105,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
val buildConfigs = findBuildConfigs(project, context.variant) val buildConfigs = findBuildConfigs(project, context.variant)
if (buildConfigs.size > 0) {
val androidConfig = (Kobalt.findPlugin("android") as AndroidPlugin).configurationFor(project) val androidConfig = (Kobalt.findPlugin("android") as AndroidPlugin).configurationFor(project)
val pkg = androidConfig?.applicationId ?: project.packageName ?: project.group val pkg = androidConfig?.applicationId ?: project.packageName ?: project.group
?: throw KobaltException( ?: throw KobaltException(
@ -116,6 +117,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
KFiles.saveFile(outputFile, code) KFiles.saveFile(outputFile, code)
log(2, "Generated ${outputFile.path}") log(2, "Generated ${outputFile.path}")
} }
}
override fun toString() = toTask("") override fun toString() = toTask("")