[Gradle, JS] Make Dukat tasks really compatible with conf cache
Related to #KT-42911
This commit is contained in:
+27
-1
@@ -5,8 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.jetbrains.kotlin.gradle.util.findFileByName
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dukat.ExternalsOutputFormat
|
||||
import org.jetbrains.kotlin.gradle.util.createTempDir
|
||||
import org.jetbrains.kotlin.gradle.util.findFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
@@ -85,6 +86,31 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() {
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConfigurationCacheDukatSrc() = testConfigurationCacheDukat()
|
||||
|
||||
@Test
|
||||
fun testConfigurationCacheDukatBinaries() = testConfigurationCacheDukat {
|
||||
gradleProperties().modify {
|
||||
"""
|
||||
${ExternalsOutputFormat.externalsOutputFormatProperty}=${ExternalsOutputFormat.BINARY}
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun testConfigurationCacheDukat(configure: Project.() -> Unit = {}) =
|
||||
with(Project("both", directoryPrefix = "dukat-integration")) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
configure(this)
|
||||
testConfigurationCacheOf(
|
||||
"irGenerateExternalsIntegrated", executedTaskNames = listOf(
|
||||
":irGenerateExternalsIntegrated"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractConfigurationCacheIT : BaseGradleIT() {
|
||||
|
||||
+5
-9
@@ -147,16 +147,12 @@ internal fun gradleModelPostProcess(
|
||||
when (externalsOutputFormat) {
|
||||
ExternalsOutputFormat.SOURCE -> compilation.defaultSourceSet.kotlin.srcDir(npmProject.externalsDir)
|
||||
ExternalsOutputFormat.BINARY -> {
|
||||
npmProject.externalsDir
|
||||
.listFiles()
|
||||
?.filter { it.isCompatibleArchive }
|
||||
?.forEach {
|
||||
project.dependencies.add(
|
||||
compilation.compileDependencyConfigurationName,
|
||||
project.files(it)
|
||||
)
|
||||
project.dependencies.add(
|
||||
compilation.compileDependencyConfigurationName,
|
||||
project.fileTree(npmProject.externalsDir).include {
|
||||
it.file.isCompatibleArchive
|
||||
}
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -49,7 +49,7 @@ class DukatExecutor(
|
||||
|
||||
npmProject.externalsDir.deleteRecursively()
|
||||
DukatRunner(
|
||||
npmProject.compilation,
|
||||
npmProject,
|
||||
typeDefinitions.map { it.file },
|
||||
externalsOutputFormat,
|
||||
npmProject.externalsDir,
|
||||
@@ -60,7 +60,5 @@ class DukatExecutor(
|
||||
}
|
||||
|
||||
versionFile.writeText(version)
|
||||
|
||||
gradleModelPostProcess(externalsOutputFormat, npmProject)
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -7,12 +7,11 @@ package org.jetbrains.kotlin.gradle.targets.js.dukat
|
||||
|
||||
import org.gradle.internal.service.ServiceRegistry
|
||||
import org.jetbrains.kotlin.gradle.internal.execWithProgress
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject
|
||||
import java.io.File
|
||||
|
||||
class DukatRunner(
|
||||
val compilation: KotlinJsCompilation,
|
||||
val npmProject: NpmProject,
|
||||
val dTsFiles: Collection<File>,
|
||||
val externalsOutputFormat: ExternalsOutputFormat,
|
||||
val destDir: File,
|
||||
@@ -45,7 +44,7 @@ class DukatRunner(
|
||||
|
||||
args.addAll(dTsFiles.map { it.absolutePath })
|
||||
|
||||
compilation.npmProject.useTool(
|
||||
npmProject.useTool(
|
||||
exec,
|
||||
"dukat/bin/dukat-cli.js",
|
||||
listOf(),
|
||||
|
||||
+4
-1
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency
|
||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import java.io.File
|
||||
|
||||
abstract class DukatTask(
|
||||
@@ -29,6 +30,8 @@ abstract class DukatTask(
|
||||
compilation.disambiguatedName
|
||||
}
|
||||
|
||||
private val npmProject by lazy { compilation.npmProject }
|
||||
|
||||
@get:Internal
|
||||
override val nodeModulesRequired: Boolean
|
||||
get() = true
|
||||
@@ -103,7 +106,7 @@ abstract class DukatTask(
|
||||
}
|
||||
|
||||
DukatRunner(
|
||||
compilation,
|
||||
npmProject,
|
||||
dTsFiles,
|
||||
externalsOutputFormat,
|
||||
destinationDir,
|
||||
|
||||
+5
-8
@@ -176,15 +176,12 @@ internal class KotlinCompilationNpmResolver(
|
||||
// We don't have `kotlin-js-test-runner` in NPM yet
|
||||
all.dependencies.add(nodeJs.versions.kotlinJsTestRunner.createDependency(project))
|
||||
|
||||
npmProject.externalsDir
|
||||
.listFiles()
|
||||
?.filter { it.isCompatibleArchive }
|
||||
?.forEach {
|
||||
project.dependencies.add(
|
||||
all.name,
|
||||
project.files(it)
|
||||
)
|
||||
project.dependencies.add(
|
||||
all.name,
|
||||
project.fileTree(npmProject.externalsDir).include {
|
||||
it.file.isCompatibleArchive
|
||||
}
|
||||
)
|
||||
|
||||
return all
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user