Yarn manipulation in build script

- Remove yarn folder in task inside build script to not import GradleUserHomeLookup
- Check yarn folder existence in task inside build script
This commit is contained in:
Ilya Goncharov
2019-09-06 14:56:50 +03:00
parent 48c06aeeba
commit 8a6ee66f81
2 changed files with 24 additions and 9 deletions
@@ -1,7 +1,6 @@
package org.jetbrains.kotlin.gradle
import org.gradle.api.logging.LogLevel
import org.gradle.wrapper.GradleUserHomeLookup
import org.jetbrains.kotlin.gradle.tasks.USING_JS_INCREMENTAL_COMPILATION_MESSAGE
import org.jetbrains.kotlin.gradle.util.getFileByName
import org.jetbrains.kotlin.gradle.util.getFilesByNames
@@ -421,18 +420,16 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)
GradleUserHomeLookup.gradleUserHome().resolve("yarn").deleteRecursively()
build("yarnFolderRemove") {
assertSuccessful()
}
build("kotlinYarnSetup") {
build("kotlinYarnSetup", "yarnFolderCheck") {
assertSuccessful()
assertTasksExecuted(
":kotlinYarnSetup"
)
assertFileExists(
path = GradleUserHomeLookup.gradleUserHome().resolve("yarn").canonicalPath,
inWorkingDir = false
":kotlinYarnSetup",
":yarnFolderCheck"
)
}
}
@@ -14,6 +14,24 @@ repositories {
yarn
tasks {
val yarnFolderRemove by registering {
doLast {
yarn.installationDir.deleteRecursively()
}
}
val yarnFolderCheck by registering {
dependsOn(getByName("kotlinYarnSetup"))
doLast {
if (!yarn.installationDir.exists()) {
throw GradleException()
}
}
}
}
kotlin.sourceSets {
getByName("main") {
dependencies {