From 93d2d28af68c932e1bdd931fcb4a62943c45e14d Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 2 Jul 2019 23:43:05 -0700 Subject: Test install task --- app/build.gradle | 1 + buildSrc/build.gradle.kts | 9 +++++++++ buildSrc/src/main/kotlin/FrostPlugin.kt | 1 + buildSrc/src/main/kotlin/WebGenInstallTask.kt | 5 +++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4efd7930..0f5188b7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,6 +5,7 @@ apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'com.getkeepsafe.dexcount' apply plugin: 'com.gladed.androidgitversion' +apply plugin: FrostPlugin apply from: '../spotless.gradle' group = APP_GROUP diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 4397bae9..d9ff7951 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -22,6 +22,15 @@ val kau = rootProps.useLines { println("Using kau $kau") +gradlePlugin { + plugins { + register("frost-web-gen") { + id = "frost" + implementationClass = "FrostPlugin" + } + } +} + dependencies { implementation("ca.allanwang.kau:gradle-plugin:$kau") implementation("com.moowork.gradle:gradle-node-plugin:1.3.1") diff --git a/buildSrc/src/main/kotlin/FrostPlugin.kt b/buildSrc/src/main/kotlin/FrostPlugin.kt index 0fd4ea9d..7b5075f8 100644 --- a/buildSrc/src/main/kotlin/FrostPlugin.kt +++ b/buildSrc/src/main/kotlin/FrostPlugin.kt @@ -12,6 +12,7 @@ class FrostPlugin : Plugin { } override fun apply(project: Project) { + println("Applying Frost Plugin") project.plugins.withId("java-base") { project.applyWebGenPlugin() } diff --git a/buildSrc/src/main/kotlin/WebGenInstallTask.kt b/buildSrc/src/main/kotlin/WebGenInstallTask.kt index 2076ee84..a185a7f0 100644 --- a/buildSrc/src/main/kotlin/WebGenInstallTask.kt +++ b/buildSrc/src/main/kotlin/WebGenInstallTask.kt @@ -1,6 +1,7 @@ import com.moowork.gradle.node.npm.NpmTask import org.gradle.api.DefaultTask import org.gradle.api.logging.LogLevel +import org.gradle.api.tasks.CacheableTask import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction @@ -9,7 +10,8 @@ import java.io.File /** * Based on https://github.com/apollographql/apollo-android/blob/master/apollo-gradle-plugin/src/main/groovy/com/apollographql/apollo/gradle/ApolloCodegenInstallTask.groovy */ -class WebGenInstallTask : DefaultTask() { +@CacheableTask +open class WebGenInstallTask : DefaultTask() { companion object { const val TAG = "frost-web-gen" @@ -34,7 +36,6 @@ class WebGenInstallTask : DefaultTask() { installDir.set(project.file(File(project.buildDir, INSTALLATION_PATH))) packageFile.set(project.file(File(project.buildDir, PACKAGE_FILE_PATH))) - npmTask.setWorkingDir(File(project.buildDir, TAG)) } -- cgit v1.2.3