[Gradle, JS] Add yarn resolution gradle integration test
^KT-41054 fixed
This commit is contained in:
+30
@@ -748,4 +748,34 @@ abstract class AbstractKotlin2JsGradlePluginIT(private val irBackend: Boolean) :
|
|||||||
assertFileVersion(libPackageJson, dependency)
|
assertFileVersion(libPackageJson, dependency)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testYarnResolution() = with(Project("kotlin-js-yarn-resolutions")) {
|
||||||
|
setupWorkingDir()
|
||||||
|
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||||
|
|
||||||
|
fun assertYarnResolutions(
|
||||||
|
packageJson: PackageJson
|
||||||
|
) {
|
||||||
|
val name = "lodash"
|
||||||
|
val version = packageJson.resolutions?.get(name)
|
||||||
|
val requiredVersion = ">=1.0.0 <1.2.1 || >1.4.0 <2.0.0"
|
||||||
|
assertTrue("Root package.json must have resolution $name with version $requiredVersion, but $version found") {
|
||||||
|
version == requiredVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
build("packageJson", "rootPackageJson", "kotlinNpmInstall") {
|
||||||
|
assertSuccessful()
|
||||||
|
|
||||||
|
fun getPackageJson() =
|
||||||
|
fileInWorkingDir("build/js")
|
||||||
|
.resolve(NpmProject.PACKAGE_JSON)
|
||||||
|
.let {
|
||||||
|
Gson().fromJson(it.readText(), PackageJson::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
|
assertYarnResolutions(getPackageJson())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("js").version("<pluginMarkerVersion>")
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "com.example"
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
constraints {
|
||||||
|
implementation(org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependencyConstraint(project, "lodash", "^1.0.0")) {
|
||||||
|
version {
|
||||||
|
reject("~1.2.1", "1.3.0 - 1.4.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
js {
|
||||||
|
useCommonJs()
|
||||||
|
nodejs {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "kotlin-js-dependencies-clash"
|
||||||
|
|
||||||
|
include("base")
|
||||||
|
include("lib")
|
||||||
Reference in New Issue
Block a user