[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
|
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.createTempDir
|
||||||
|
import org.jetbrains.kotlin.gradle.util.findFileByName
|
||||||
import org.jetbrains.kotlin.gradle.util.modify
|
import org.jetbrains.kotlin.gradle.util.modify
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
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() {
|
abstract class AbstractConfigurationCacheIT : BaseGradleIT() {
|
||||||
|
|||||||
+5
-9
@@ -147,16 +147,12 @@ internal fun gradleModelPostProcess(
|
|||||||
when (externalsOutputFormat) {
|
when (externalsOutputFormat) {
|
||||||
ExternalsOutputFormat.SOURCE -> compilation.defaultSourceSet.kotlin.srcDir(npmProject.externalsDir)
|
ExternalsOutputFormat.SOURCE -> compilation.defaultSourceSet.kotlin.srcDir(npmProject.externalsDir)
|
||||||
ExternalsOutputFormat.BINARY -> {
|
ExternalsOutputFormat.BINARY -> {
|
||||||
npmProject.externalsDir
|
project.dependencies.add(
|
||||||
.listFiles()
|
compilation.compileDependencyConfigurationName,
|
||||||
?.filter { it.isCompatibleArchive }
|
project.fileTree(npmProject.externalsDir).include {
|
||||||
?.forEach {
|
it.file.isCompatibleArchive
|
||||||
project.dependencies.add(
|
|
||||||
compilation.compileDependencyConfigurationName,
|
|
||||||
project.files(it)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-3
@@ -49,7 +49,7 @@ class DukatExecutor(
|
|||||||
|
|
||||||
npmProject.externalsDir.deleteRecursively()
|
npmProject.externalsDir.deleteRecursively()
|
||||||
DukatRunner(
|
DukatRunner(
|
||||||
npmProject.compilation,
|
npmProject,
|
||||||
typeDefinitions.map { it.file },
|
typeDefinitions.map { it.file },
|
||||||
externalsOutputFormat,
|
externalsOutputFormat,
|
||||||
npmProject.externalsDir,
|
npmProject.externalsDir,
|
||||||
@@ -60,7 +60,5 @@ class DukatExecutor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
versionFile.writeText(version)
|
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.gradle.internal.service.ServiceRegistry
|
||||||
import org.jetbrains.kotlin.gradle.internal.execWithProgress
|
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
|
import java.io.File
|
||||||
|
|
||||||
class DukatRunner(
|
class DukatRunner(
|
||||||
val compilation: KotlinJsCompilation,
|
val npmProject: NpmProject,
|
||||||
val dTsFiles: Collection<File>,
|
val dTsFiles: Collection<File>,
|
||||||
val externalsOutputFormat: ExternalsOutputFormat,
|
val externalsOutputFormat: ExternalsOutputFormat,
|
||||||
val destDir: File,
|
val destDir: File,
|
||||||
@@ -45,7 +44,7 @@ class DukatRunner(
|
|||||||
|
|
||||||
args.addAll(dTsFiles.map { it.absolutePath })
|
args.addAll(dTsFiles.map { it.absolutePath })
|
||||||
|
|
||||||
compilation.npmProject.useTool(
|
npmProject.useTool(
|
||||||
exec,
|
exec,
|
||||||
"dukat/bin/dukat-cli.js",
|
"dukat/bin/dukat-cli.js",
|
||||||
listOf(),
|
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.RequiredKotlinJsDependency
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
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.RequiresNpmDependencies
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class DukatTask(
|
abstract class DukatTask(
|
||||||
@@ -29,6 +30,8 @@ abstract class DukatTask(
|
|||||||
compilation.disambiguatedName
|
compilation.disambiguatedName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val npmProject by lazy { compilation.npmProject }
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
override val nodeModulesRequired: Boolean
|
override val nodeModulesRequired: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
@@ -103,7 +106,7 @@ abstract class DukatTask(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DukatRunner(
|
DukatRunner(
|
||||||
compilation,
|
npmProject,
|
||||||
dTsFiles,
|
dTsFiles,
|
||||||
externalsOutputFormat,
|
externalsOutputFormat,
|
||||||
destinationDir,
|
destinationDir,
|
||||||
|
|||||||
+5
-8
@@ -176,15 +176,12 @@ internal class KotlinCompilationNpmResolver(
|
|||||||
// We don't have `kotlin-js-test-runner` in NPM yet
|
// We don't have `kotlin-js-test-runner` in NPM yet
|
||||||
all.dependencies.add(nodeJs.versions.kotlinJsTestRunner.createDependency(project))
|
all.dependencies.add(nodeJs.versions.kotlinJsTestRunner.createDependency(project))
|
||||||
|
|
||||||
npmProject.externalsDir
|
project.dependencies.add(
|
||||||
.listFiles()
|
all.name,
|
||||||
?.filter { it.isCompatibleArchive }
|
project.fileTree(npmProject.externalsDir).include {
|
||||||
?.forEach {
|
it.file.isCompatibleArchive
|
||||||
project.dependencies.add(
|
|
||||||
all.name,
|
|
||||||
project.files(it)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return all
|
return all
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user