[Gradle, JS] KT-36784 Add additional args for npm install
#KT-32466 fixed #KT-36784 fixed #KT-36864 fixed
This commit is contained in:
+14
@@ -13,6 +13,20 @@ kotlin.js {
|
|||||||
nodejs()
|
nodejs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootProject.tasks
|
||||||
|
.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java)
|
||||||
|
.named("kotlinNpmInstall")
|
||||||
|
.configure {
|
||||||
|
args.addAll(
|
||||||
|
listOf(
|
||||||
|
"--network-concurrency",
|
||||||
|
"1",
|
||||||
|
"--mutex",
|
||||||
|
"network"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib-js"))
|
implementation(kotlin("stdlib-js"))
|
||||||
implementation("com.example:lib2")
|
implementation("com.example:lib2")
|
||||||
|
|||||||
+14
@@ -12,6 +12,20 @@ repositories {
|
|||||||
|
|
||||||
kotlin.target.nodejs()
|
kotlin.target.nodejs()
|
||||||
|
|
||||||
|
rootProject.tasks
|
||||||
|
.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java)
|
||||||
|
.named("kotlinNpmInstall")
|
||||||
|
.configure {
|
||||||
|
args.addAll(
|
||||||
|
listOf(
|
||||||
|
"--network-concurrency",
|
||||||
|
"1",
|
||||||
|
"--mutex",
|
||||||
|
"network"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib-js"))
|
implementation(kotlin("stdlib-js"))
|
||||||
implementation(npm("async", "2.6.2"))
|
implementation(npm("async", "2.6.2"))
|
||||||
|
|||||||
+2
-1
@@ -20,7 +20,8 @@ interface NpmApi {
|
|||||||
fun resolveRootProject(
|
fun resolveRootProject(
|
||||||
rootProject: Project,
|
rootProject: Project,
|
||||||
subProjects: Collection<KotlinCompilationNpmResolution>,
|
subProjects: Collection<KotlinCompilationNpmResolution>,
|
||||||
skipExecution: Boolean
|
skipExecution: Boolean,
|
||||||
|
vararg cliArgs: String
|
||||||
)
|
)
|
||||||
|
|
||||||
fun resolveDependency(
|
fun resolveDependency(
|
||||||
|
|||||||
+6
-1
@@ -110,7 +110,12 @@ internal class KotlinRootNpmResolver internal constructor(
|
|||||||
|
|
||||||
val hasNodeModulesDependentTasks = projectResolvers.values.any { it.taskRequirements.hasNodeModulesDependentTasks }
|
val hasNodeModulesDependentTasks = projectResolvers.values.any { it.taskRequirements.hasNodeModulesDependentTasks }
|
||||||
if (hasNodeModulesDependentTasks) {
|
if (hasNodeModulesDependentTasks) {
|
||||||
nodeJs.packageManager.resolveRootProject(rootProject, allNpmPackages, upToDate)
|
nodeJs.packageManager.resolveRootProject(
|
||||||
|
rootProject,
|
||||||
|
allNpmPackages,
|
||||||
|
upToDate,
|
||||||
|
*nodeJs.npmInstallTask.args.toTypedArray()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeJs.rootNodeModulesStateFile.writeText(System.currentTimeMillis().toString())
|
nodeJs.rootNodeModulesStateFile.writeText(System.currentTimeMillis().toString())
|
||||||
|
|||||||
+4
-1
@@ -6,11 +6,11 @@
|
|||||||
package org.jetbrains.kotlin.gradle.targets.js.npm.tasks
|
package org.jetbrains.kotlin.gradle.targets.js.npm.tasks
|
||||||
|
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.InputFiles
|
import org.gradle.api.tasks.InputFiles
|
||||||
import org.gradle.api.tasks.OutputFile
|
import org.gradle.api.tasks.OutputFile
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
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.npmProject
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class KotlinNpmInstallTask : DefaultTask() {
|
open class KotlinNpmInstallTask : DefaultTask() {
|
||||||
@@ -21,6 +21,9 @@ open class KotlinNpmInstallTask : DefaultTask() {
|
|||||||
private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject)
|
private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject)
|
||||||
private val resolutionManager get() = nodeJs.npmResolutionManager
|
private val resolutionManager get() = nodeJs.npmResolutionManager
|
||||||
|
|
||||||
|
@Input
|
||||||
|
val args: MutableList<String> = mutableListOf()
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
@get:InputFiles
|
@get:InputFiles
|
||||||
val packageJsonFiles: Collection<File>
|
val packageJsonFiles: Collection<File>
|
||||||
|
|||||||
+9
-2
@@ -38,6 +38,13 @@ class Yarn : NpmApi {
|
|||||||
override fun resolveRootProject(
|
override fun resolveRootProject(
|
||||||
rootProject: Project,
|
rootProject: Project,
|
||||||
subProjects: Collection<KotlinCompilationNpmResolution>,
|
subProjects: Collection<KotlinCompilationNpmResolution>,
|
||||||
skipExecution: Boolean
|
skipExecution: Boolean,
|
||||||
) = getDelegate(rootProject.project).resolveRootProject(rootProject, subProjects, skipExecution)
|
vararg cliArgs: String
|
||||||
|
) = getDelegate(rootProject.project)
|
||||||
|
.resolveRootProject(
|
||||||
|
rootProject,
|
||||||
|
subProjects,
|
||||||
|
skipExecution,
|
||||||
|
*cliArgs
|
||||||
|
)
|
||||||
}
|
}
|
||||||
+2
-1
@@ -25,6 +25,7 @@ class YarnSimple : YarnBasics() {
|
|||||||
override fun resolveRootProject(
|
override fun resolveRootProject(
|
||||||
rootProject: Project,
|
rootProject: Project,
|
||||||
subProjects: Collection<KotlinCompilationNpmResolution>,
|
subProjects: Collection<KotlinCompilationNpmResolution>,
|
||||||
skipExecution: Boolean
|
skipExecution: Boolean,
|
||||||
|
vararg cliArgs: String
|
||||||
) = Unit
|
) = Unit
|
||||||
}
|
}
|
||||||
+2
-1
@@ -19,7 +19,8 @@ class YarnWorkspaces : YarnBasics() {
|
|||||||
override fun resolveRootProject(
|
override fun resolveRootProject(
|
||||||
rootProject: Project,
|
rootProject: Project,
|
||||||
subProjects: Collection<KotlinCompilationNpmResolution>,
|
subProjects: Collection<KotlinCompilationNpmResolution>,
|
||||||
skipExecution: Boolean
|
skipExecution: Boolean,
|
||||||
|
vararg cliArgs: String
|
||||||
) {
|
) {
|
||||||
check(rootProject == rootProject.rootProject)
|
check(rootProject == rootProject.rootProject)
|
||||||
if (!skipExecution) setup(rootProject)
|
if (!skipExecution) setup(rootProject)
|
||||||
|
|||||||
Reference in New Issue
Block a user