diff options
Diffstat (limited to 'buildSrc')
-rw-r--r-- | buildSrc/build.gradle.kts | 1 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/FrostPlugin.kt | 37 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/WebGenInstallTask.kt | 69 |
3 files changed, 0 insertions, 107 deletions
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index d9ff7951..3afa0486 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -33,5 +33,4 @@ gradlePlugin { dependencies { implementation("ca.allanwang.kau:gradle-plugin:$kau") - implementation("com.moowork.gradle:gradle-node-plugin:1.3.1") }
\ No newline at end of file diff --git a/buildSrc/src/main/kotlin/FrostPlugin.kt b/buildSrc/src/main/kotlin/FrostPlugin.kt deleted file mode 100644 index 7b5075f8..00000000 --- a/buildSrc/src/main/kotlin/FrostPlugin.kt +++ /dev/null @@ -1,37 +0,0 @@ -import com.moowork.gradle.node.NodeExtension -import com.moowork.gradle.node.NodePlugin -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.create - -class FrostPlugin : Plugin<Project> { - - companion object { - private const val NODE_VERSION = "12.4.0" - } - - override fun apply(project: Project) { - println("Applying Frost Plugin") - project.plugins.withId("java-base") { - project.applyWebGenPlugin() - } - project.gradle.taskGraph.whenReady { - if (!project.plugins.hasPlugin("java-base")) { - throw IllegalArgumentException("Frost plugin can't be applied without Android or Java or Kotlin plugin.") - } - } - } - - private fun Project.applyWebGenPlugin() { - setupNode() - tasks.create(WebGenInstallTask.NAME, WebGenInstallTask::class) - } - - private fun Project.setupNode() { - plugins.apply(NodePlugin::class) - val nodeConfig = extensions.findByName("node") as NodeExtension - nodeConfig.download = true - nodeConfig.version = NODE_VERSION - } -}
\ No newline at end of file diff --git a/buildSrc/src/main/kotlin/WebGenInstallTask.kt b/buildSrc/src/main/kotlin/WebGenInstallTask.kt deleted file mode 100644 index a185a7f0..00000000 --- a/buildSrc/src/main/kotlin/WebGenInstallTask.kt +++ /dev/null @@ -1,69 +0,0 @@ -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 -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 - */ -@CacheableTask -open class WebGenInstallTask : DefaultTask() { - - companion object { - const val TAG = "frost-web-gen" - const val NAME = "installWebGen" - val INSTALLATION_PATH = TAG + File.separator + "node_modules" - val PACKAGE_FILE_PATH = TAG + File.separator + "package.json" - - const val TYPESCRIPT_VERSION = "3.3.1" - const val SASS_VERSION = "1.19.0" - } - - @OutputDirectory - val installDir = project.layout.directoryProperty() - @OutputFile - val packageFile = project.layout.fileProperty() - - val npmTask = NpmTask() - - init { - group = "frost" - description = "Runs npm install for $TAG" - - 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)) - } - - @TaskAction - fun exec() { - installDir.get().asFile.takeIf { it.isDirectory }?.deleteRecursively() - writePackageFile(packageFile.get().asFile) - npmTask.setArgs( - listOf( - "install", - "typescript@$TYPESCRIPT_VERSION", - "sass@$SASS_VERSION", - "--save", - "--save-exact" - ) - ) - npmTask.logging.captureStandardOutput(LogLevel.INFO) - npmTask.exec() - } - - private fun writePackageFile(packageFile: File) { - packageFile.writeText( - """ - { - "name": "$TAG", - "version": "1.0" - } - """.trimIndent() - ) - } -}
\ No newline at end of file |