2020-10-16 17:18:11 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import com.android.build.gradle.TestedExtension
|
2020-11-15 09:34:14 +01:00
|
|
|
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
2020-10-16 17:18:11 +02:00
|
|
|
import com.android.build.gradle.internal.plugins.AppPlugin
|
|
|
|
|
import com.android.build.gradle.internal.plugins.LibraryPlugin
|
2021-03-09 10:11:51 +01:00
|
|
|
import com.ncorti.ktfmt.gradle.KtfmtExtension
|
|
|
|
|
import com.ncorti.ktfmt.gradle.KtfmtPlugin
|
2020-10-16 17:18:11 +02:00
|
|
|
import org.gradle.api.Plugin
|
|
|
|
|
import org.gradle.api.Project
|
|
|
|
|
import org.gradle.api.plugins.JavaLibraryPlugin
|
|
|
|
|
import org.gradle.api.plugins.JavaPlugin
|
|
|
|
|
import org.gradle.api.tasks.compile.JavaCompile
|
|
|
|
|
import org.gradle.kotlin.dsl.getByType
|
|
|
|
|
import org.gradle.kotlin.dsl.withType
|
|
|
|
|
|
|
|
|
|
class PasswordStorePlugin : Plugin<Project> {
|
|
|
|
|
|
|
|
|
|
override fun apply(project: Project) {
|
|
|
|
|
project.configureForAllProjects()
|
|
|
|
|
|
|
|
|
|
if (project.isRoot) {
|
|
|
|
|
project.configureForRootProject()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
project.plugins.all {
|
|
|
|
|
when (this) {
|
|
|
|
|
is JavaPlugin,
|
|
|
|
|
is JavaLibraryPlugin -> {
|
|
|
|
|
project.tasks.withType<JavaCompile> {
|
|
|
|
|
options.compilerArgs.add("-Xlint:unchecked")
|
|
|
|
|
options.isDeprecation = true
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-15 09:34:14 +01:00
|
|
|
is LibraryPlugin -> {
|
|
|
|
|
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
|
|
|
|
|
}
|
2020-10-16 17:18:11 +02:00
|
|
|
is AppPlugin -> {
|
2020-11-15 09:34:14 +01:00
|
|
|
project.extensions.getByType<BaseAppModuleExtension>().configureAndroidApplicationOptions(project)
|
|
|
|
|
project.extensions.getByType<BaseAppModuleExtension>().configureBuildSigning(project)
|
2020-10-16 17:18:11 +02:00
|
|
|
project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
|
|
|
|
|
}
|
2021-03-09 10:11:51 +01:00
|
|
|
is KtfmtPlugin -> {
|
|
|
|
|
project.extensions.getByType<KtfmtExtension>().configureKtfmt()
|
|
|
|
|
}
|
2020-10-16 17:18:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val Project.isRoot get() = this == this.rootProject
|