diff --git a/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksManifestConfiguratorTask.kt b/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksManifestConfiguratorTask.kt index 121c05663..be5f0f257 100644 --- a/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksManifestConfiguratorTask.kt +++ b/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksManifestConfiguratorTask.kt @@ -9,7 +9,7 @@ import org.gradle.api.tasks.TaskAction public abstract class DeeplinksManifestConfiguratorTask : DefaultTask() { @get:InputFile - public abstract val deeplinksConfigurationFile: RegularFileProperty + public abstract val deepLinkDefinitionsFile: RegularFileProperty @get:InputFile public abstract val mergedManifest: RegularFileProperty @@ -19,7 +19,7 @@ public abstract class DeeplinksManifestConfiguratorTask : DefaultTask() { @TaskAction public fun taskAction() { - val configurationFile = deeplinksConfigurationFile.get().asFile + val configurationFile = deepLinkDefinitionsFile.get().asFile val inputManifest = mergedManifest.get().asFile val outputManifest = updatedManifest.get().asFile diff --git a/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksPlugin.kt b/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksPlugin.kt index 5f1efc5ee..d1c5b143a 100644 --- a/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksPlugin.kt +++ b/deeplinks-plugin/src/main/kotlin/com/freeletics/khonshu/deeplinks/plugin/DeeplinksPlugin.kt @@ -2,7 +2,6 @@ package com.freeletics.khonshu.deeplinks.plugin import com.android.build.api.artifact.SingleArtifact import com.android.build.api.variant.AndroidComponentsExtension -import java.io.File import org.gradle.api.Plugin import org.gradle.api.Project @@ -12,31 +11,24 @@ import org.gradle.api.Project */ public abstract class DeeplinksPlugin : Plugin { override fun apply(project: Project) { - val configurationFile = File(project.projectDir, "deeplinks.toml") - if (!configurationFile.exists()) { - // configuration file doesn't exist -> skipping - return - } + val extension = project.extensions.create("deepLinks", DeepLinksExtension::class.java) + extension.deepLinkDefinitionsFile.convention(project.layout.projectDirectory.file("deeplinks.toml")) project.plugins.withId("com.android.library") { - setupDeeplinksManifestConfigurator(project, configurationFile) + setupDeeplinksManifestConfigurator(project, extension) } project.plugins.withId("com.android.application") { - setupDeeplinksManifestConfigurator(project, configurationFile) + setupDeeplinksManifestConfigurator(project, extension) } } - private fun setupDeeplinksManifestConfigurator(project: Project, configurationFile: File) { + private fun setupDeeplinksManifestConfigurator(project: Project, extension: DeepLinksExtension) { val androidComponents = project.extensions.getByType(AndroidComponentsExtension::class.java) androidComponents.onVariants { variant -> - val manifestUpdater = project.tasks.register( - variant.name + "DeeplinksManifestConfigurator", - DeeplinksManifestConfiguratorTask::class.java, - ) { - it.deeplinksConfigurationFile.set( - configurationFile, - ) + val name = "${variant.name}DeeplinksManifestConfigurator" + val manifestUpdater = project.tasks.register(name, DeeplinksManifestConfiguratorTask::class.java) { + it.deepLinkDefinitionsFile.set(extension.deepLinkDefinitionsFile) } variant.artifacts.use(manifestUpdater).wiredWithFiles( DeeplinksManifestConfiguratorTask::mergedManifest,