diff --git a/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitPlugin.kt b/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitPlugin.kt index bcde323..18a8bd7 100644 --- a/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitPlugin.kt +++ b/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitPlugin.kt @@ -12,6 +12,8 @@ internal class CockpitPlugin : Plugin { val android = project.extensions.getByType(AppExtension::class.java) android.applicationVariants.all { variant: BaseVariant -> + + print(project.tasks) val task = project.tasks.create("generate${variant.name.capitalize()}Cockpit", CockpitTask::class.java) { it.variantName = variant.name it.variantDirName = variant.dirName @@ -21,6 +23,10 @@ internal class CockpitPlugin : Plugin { it.buildTypeList = android.buildTypes.map { it.name } ?: emptyList() } + val assembleTask = project.tasks.find { it.name.contains("assemble") && it.name.contains(variant.buildType.name) } + assembleTask?.dependsOn(task) + + variant.registerJavaGeneratingTask(task, task.getCockpitOutputDirectory()) android.sourceSets.first { variant.name == it.name } .apply { diff --git a/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitTask.kt b/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitTask.kt index 17e732e..fda8f8b 100644 --- a/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitTask.kt +++ b/CockpitPlugin/src/main/java/com/polidea/cockpitplugin/CockpitTask.kt @@ -58,6 +58,8 @@ internal open class CockpitTask : DefaultTask() { yamlReaderAndWriter.saveParamsToYaml(mergedParametersList, mergedCockpitFile) + if (!mergedCockpitFile.exists()) throw IllegalStateException("mergedCockpit.yml has not been created") + val generator = if (buildTypeName.isRelease()) ReleaseCockpitGenerator() else DebugCockpitGenerator() generator.generate(mergedParametersList, getCockpitOutputDirectory()) } else {