[Gradle, JS] Compilation to compilationName
This commit is contained in:
committed by
Alexander Likhachev
parent
4566b7c6e5
commit
521b722c09
+13
-5
@@ -26,6 +26,16 @@ internal class DukatCompilationResolverPlugin(
|
|||||||
val nodeJs get() = resolver.nodeJs
|
val nodeJs get() = resolver.nodeJs
|
||||||
val npmProject get() = resolver.npmProject
|
val npmProject get() = resolver.npmProject
|
||||||
val compilation get() = npmProject.compilation
|
val compilation get() = npmProject.compilation
|
||||||
|
val compilationName by lazy {
|
||||||
|
compilation.name
|
||||||
|
}
|
||||||
|
val legacyTargetReuseIrTask by lazy {
|
||||||
|
val target = compilation.target
|
||||||
|
target is KotlinJsTarget && (target.irTarget != null && externalsOutputFormat == ExternalsOutputFormat.SOURCE)
|
||||||
|
}
|
||||||
|
val externalsOutputFormat by lazy {
|
||||||
|
compilation.externalsOutputFormat
|
||||||
|
}
|
||||||
val integratedTaskName = npmProject.compilation.disambiguateName("generateExternalsIntegrated")
|
val integratedTaskName = npmProject.compilation.disambiguateName("generateExternalsIntegrated")
|
||||||
val separateTaskName = npmProject.compilation.disambiguateName("generateExternals")
|
val separateTaskName = npmProject.compilation.disambiguateName("generateExternals")
|
||||||
|
|
||||||
@@ -86,12 +96,10 @@ internal class DukatCompilationResolverPlugin(
|
|||||||
packageJsonIsUpdated: Boolean,
|
packageJsonIsUpdated: Boolean,
|
||||||
resolution: KotlinRootNpmResolution
|
resolution: KotlinRootNpmResolution
|
||||||
) {
|
) {
|
||||||
val externalNpmDependencies = resolution[project.path][compilation].externalNpmDependencies
|
val externalNpmDependencies = resolution[project.path][compilationName].externalNpmDependencies
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val target = compilation.target
|
|
||||||
val externalsOutputFormat = compilation.externalsOutputFormat
|
|
||||||
val legacyTargetReuseIrTask =
|
|
||||||
target is KotlinJsTarget && (target.irTarget != null && externalsOutputFormat == ExternalsOutputFormat.SOURCE)
|
|
||||||
if (legacyTargetReuseIrTask) {
|
if (legacyTargetReuseIrTask) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-15
@@ -11,7 +11,6 @@ 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.utils.disableTaskOnConfigurationCacheBuild
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class DukatTask(
|
abstract class DukatTask(
|
||||||
@@ -20,11 +19,17 @@ abstract class DukatTask(
|
|||||||
override val compilation: KotlinJsCompilation
|
override val compilation: KotlinJsCompilation
|
||||||
) : DefaultTask(), RequiresNpmDependencies {
|
) : DefaultTask(), RequiresNpmDependencies {
|
||||||
@get:Internal
|
@get:Internal
|
||||||
|
@Transient
|
||||||
protected val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
protected val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
||||||
|
|
||||||
|
@get:Internal
|
||||||
|
val compilationName by lazy {
|
||||||
|
compilation.name
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// TODO: temporary workaround for configuration cache enabled builds
|
// TODO: temporary workaround for configuration cache enabled builds
|
||||||
disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() }
|
// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
@@ -41,19 +46,22 @@ abstract class DukatTask(
|
|||||||
@Input
|
@Input
|
||||||
var externalsOutputFormat: ExternalsOutputFormat = ExternalsOutputFormat.SOURCE
|
var externalsOutputFormat: ExternalsOutputFormat = ExternalsOutputFormat.SOURCE
|
||||||
|
|
||||||
|
private val compilationResolution
|
||||||
|
get() =
|
||||||
|
nodeJs.npmResolutionManager.requireInstalled(
|
||||||
|
services,
|
||||||
|
logger
|
||||||
|
)[project.path][compilationName]
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
@delegate:Transient
|
val dts: List<DtsResolver.Dts>
|
||||||
val dts by lazy {
|
get() {
|
||||||
val resolvedCompilation = nodeJs.npmResolutionManager.requireInstalled(
|
val dtsResolver = DtsResolver(compilationResolution.npmProject)
|
||||||
services,
|
return dtsResolver.getAllDts(
|
||||||
logger
|
compilationResolution.externalNpmDependencies,
|
||||||
)[project.path][compilation]
|
considerGeneratingFlag
|
||||||
val dtsResolver = DtsResolver(resolvedCompilation.npmProject)
|
)
|
||||||
dtsResolver.getAllDts(
|
}
|
||||||
resolvedCompilation.externalNpmDependencies,
|
|
||||||
considerGeneratingFlag
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package name for the generated file (by default filename.d.ts renamed to filename.d.kt)
|
* Package name for the generated file (by default filename.d.ts renamed to filename.d.kt)
|
||||||
@@ -87,7 +95,7 @@ abstract class DukatTask(
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
open fun run() {
|
open fun run() {
|
||||||
nodeJs.npmResolutionManager.checkRequiredDependencies(this)
|
// nodeJs.npmResolutionManager.checkRequiredDependencies(this)
|
||||||
|
|
||||||
destinationDir.deleteRecursively()
|
destinationDir.deleteRecursively()
|
||||||
|
|
||||||
|
|||||||
+2
@@ -25,6 +25,8 @@ val KotlinJsCompilation.npmProject: NpmProject
|
|||||||
* More info can be obtained from [KotlinCompilationNpmResolution], which is available after project resolution (after [KotlinNpmInstallTask] execution).
|
* More info can be obtained from [KotlinCompilationNpmResolution], which is available after project resolution (after [KotlinNpmInstallTask] execution).
|
||||||
*/
|
*/
|
||||||
open class NpmProject(@Transient val compilation: KotlinJsCompilation) {
|
open class NpmProject(@Transient val compilation: KotlinJsCompilation) {
|
||||||
|
val compilationName = compilation.name
|
||||||
|
|
||||||
val name: String by lazy {
|
val name: String by lazy {
|
||||||
buildNpmProjectName()
|
buildNpmProjectName()
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-14
@@ -26,27 +26,30 @@ constructor(
|
|||||||
private val npmProject = compilation.npmProject
|
private val npmProject = compilation.npmProject
|
||||||
private val nodeJs = npmProject.nodeJs
|
private val nodeJs = npmProject.nodeJs
|
||||||
|
|
||||||
private val compilationResolution
|
private val compilationName = compilation.name
|
||||||
get() = nodeJs.npmResolutionManager.requireInstalled(
|
|
||||||
|
private val compilationResolution by lazy {
|
||||||
|
nodeJs.npmResolutionManager.requireInstalled(
|
||||||
services,
|
services,
|
||||||
logger
|
logger
|
||||||
)[project.path][npmProject.compilation]
|
)[project.path][compilationName]
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// TODO: temporary workaround for configuration cache enabled builds
|
// TODO: temporary workaround for configuration cache enabled builds
|
||||||
disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() }
|
// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:Input
|
// @get:Input
|
||||||
val packageJsonCustomFields: Map<String, Any?>
|
// val packageJsonCustomFields: Map<String, Any?>
|
||||||
get() = PackageJson(fakePackageJsonValue, fakePackageJsonValue)
|
// get() = PackageJson(fakePackageJsonValue, fakePackageJsonValue)
|
||||||
.apply {
|
// .apply {
|
||||||
compilation.packageJsonHandlers.forEach { it() }
|
// compilation.packageJsonHandlers.forEach { it() }
|
||||||
}.customFields
|
// }.customFields
|
||||||
|
|
||||||
@get:Nested
|
@get:Nested
|
||||||
internal val externalDependencies: Collection<NpmDependencyDeclaration>
|
internal val externalDependencies: Collection<NpmDependencyDeclaration> by lazy {
|
||||||
get() = compilationResolution.externalNpmDependencies
|
compilationResolution.externalNpmDependencies
|
||||||
.map {
|
.map {
|
||||||
NpmDependencyDeclaration(
|
NpmDependencyDeclaration(
|
||||||
scope = it.scope,
|
scope = it.scope,
|
||||||
@@ -55,6 +58,7 @@ constructor(
|
|||||||
generateExternals = it.generateExternals
|
generateExternals = it.generateExternals
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val publicPackageJsonTaskName = npmProject.publicPackageJsonTaskName
|
private val publicPackageJsonTaskName = npmProject.publicPackageJsonTaskName
|
||||||
|
|
||||||
@@ -68,8 +72,8 @@ constructor(
|
|||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun resolve() {
|
fun resolve() {
|
||||||
val compilation = npmProject.compilation
|
// val compilation = npmProject.compilation
|
||||||
|
//
|
||||||
// packageJson(npmProject, realExternalDependencies).let { packageJson ->
|
// packageJson(npmProject, realExternalDependencies).let { packageJson ->
|
||||||
// packageJson.main = "${npmProject.name}.js"
|
// packageJson.main = "${npmProject.name}.js"
|
||||||
//
|
//
|
||||||
|
|||||||
+4
-4
@@ -30,11 +30,11 @@ class KotlinProjectNpmResolution(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val byCompilation by lazy { npmProjects.associateBy { it.npmProject.compilation.name } }
|
val byCompilation by lazy { npmProjects.associateBy { it.npmProject.compilationName } }
|
||||||
|
|
||||||
operator fun get(compilation: KotlinJsCompilation): KotlinCompilationNpmResolution {
|
operator fun get(compilationName: String): KotlinCompilationNpmResolution {
|
||||||
check(compilation.target.project.path == project)
|
// check(compilation.target.project.path == project)
|
||||||
return byCompilation.getValue(compilation.name)
|
return byCompilation.getValue(compilationName)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
Reference in New Issue
Block a user