Gradle, npm: use state file as fake output for :kotlinNpmInstall task

This is required in case when NpmSimpleLinker works (instead of yarn).
NpmSimpleLinker will not produce yarn.lock file, so :kotlinNpmInstall
was always up-to-date. Adding fake state file fixes the problem.

#KT-32874 Fixed
This commit is contained in:
Sergey Rostov
2019-08-12 10:24:27 +03:00
parent 6b5739bd6a
commit ba9c632f15
3 changed files with 10 additions and 0 deletions
@@ -58,6 +58,9 @@ open class NodeJsRootExtension(val rootProject: Project) {
val rootPackageDir: File
get() = rootProject.buildDir.resolve("js")
internal val rootNodeModulesStateFile: File
get() = rootPackageDir.resolve("node_modules.state")
val projectPackagesDir: File
get() = rootPackageDir.resolve("packages")
@@ -98,6 +98,8 @@ internal class KotlinRootNpmResolver internal constructor(
}
}
nodeJs.rootNodeModulesStateFile.writeText(System.currentTimeMillis().toString())
upToDateChecks.forEach { it.commit() }
return KotlinRootNpmResolution(rootProject, projectResolutions)
@@ -26,6 +26,11 @@ open class KotlinNpmInstallTask : DefaultTask() {
val packageJsonFiles: Collection<File>
get() = resolutionManager.packageJsonFiles
// avoid using node_modules as output directory, as it is significantly slows down build
@get:OutputFile
val nodeModulesState: File
get() = nodeJs.rootNodeModulesStateFile
@get:OutputFile
val yarnLock: File
get() = nodeJs.rootPackageDir.resolve("yarn.lock")