KT-62004 Drop legacy JS build of kotlin-test

This commit is contained in:
Ilya Gorbunov
2023-09-16 06:24:51 +02:00
committed by Space Team
parent 291d52820c
commit eb813b7837
13 changed files with 44 additions and 8243 deletions
-2
View File
@@ -354,7 +354,6 @@ val coreLibProjects by extra {
":kotlin-test:kotlin-test-junit",
":kotlin-test:kotlin-test-junit5",
":kotlin-test:kotlin-test-testng",
":kotlin-test:kotlin-test-js".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
":kotlin-reflect"
)
}
@@ -608,7 +607,6 @@ tasks {
(coreLibProjects + listOfNotNull(
":kotlin-stdlib:samples",
":kotlin-test:kotlin-test-js-ir".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
":kotlin-test:kotlin-test-js:kotlin-test-js-it".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
":kotlin-test:kotlin-test-js-ir:kotlin-test-js-ir-it".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
":kotlinx-metadata-jvm",
":tools:binary-compatibility-validator",
+2 -2
View File
@@ -28,7 +28,7 @@ val testJsRuntime by configurations.creating {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_RUNTIME))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir)
}
}
@@ -73,7 +73,7 @@ dependencies {
testRuntimeOnly(kotlinStdlib())
testJsRuntime(kotlinStdlib())
if (!kotlinBuildProperties.isInJpsBuildIdeaSync) {
testJsRuntime(project(":kotlin-test:kotlin-test-js")) // to be sure that kotlin-test-js built before tests runned
testJsRuntime(project(":kotlin-test:kotlin-test-js-ir")) // to be sure that kotlin-test-js built before tests run
}
testRuntimeOnly(project(":kotlin-preloader")) // it's required for ant tests
testRuntimeOnly(project(":compiler:backend-common"))
+5 -25
View File
@@ -46,6 +46,7 @@ val jsApiVariant by configurations.creating {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("kotlin-api"))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir)
}
}
val jsRuntimeVariant by configurations.creating {
@@ -54,6 +55,7 @@ val jsRuntimeVariant by configurations.creating {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("kotlin-runtime"))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir)
}
extendsFrom(jsApiVariant)
}
@@ -293,30 +295,14 @@ val (jsApi, jsRuntime) = listOf("api", "runtime").map { usage ->
}
jsRuntime.extendsFrom(jsApi)
val (jsV1Api, jsV1Runtime) = listOf("api", "runtime").map { usage ->
configurations.create("jsV1${usage.capitalize()}") {
isCanBeConsumed = true
isCanBeResolved = true
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("kotlin-$usage"))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy)
}
}
}
jsV1Runtime.extendsFrom(jsV1Api)
dependencies {
jsApi(project(":kotlin-stdlib"))
jsV1Api(project(":kotlin-stdlib"))
}
artifacts {
val jsJar = tasks.getByPath(":kotlin-test:kotlin-test-js:libraryJarWithIr")
val jsJar = tasks.getByPath(":kotlin-test:kotlin-test-js-ir:jsJar")
add(jsApi.name, jsJar)
add(jsRuntime.name, jsJar)
add(jsV1Api.name, jsJar)
add(jsV1Runtime.name, jsJar)
}
val jsComponent = componentFactory.adhoc("js").apply {
@@ -326,12 +312,6 @@ val jsComponent = componentFactory.adhoc("js").apply {
addVariantsFromConfiguration(jsRuntime) {
mapToMavenScope("runtime")
}
addVariantsFromConfiguration(jsV1Api) {
mapToMavenScope("compile")
}
addVariantsFromConfiguration(jsV1Runtime) {
mapToMavenScope("runtime")
}
}
val (wasmJsApi, wasmJsRuntime) = listOf("api", "runtime").map { usage ->
@@ -479,9 +459,9 @@ publishing {
val kotlinTestJsPublication = register("js", MavenPublication::class) {
artifactId = "kotlin-test-js"
from(jsComponent)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-js-ir:jsLegacyJar") as Jar)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-js-ir:jsSourcesJar") as org.gradle.jvm.tasks.Jar)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-js:javadocJar") as Jar)
configureKotlinPomAttributes(project, "Kotlin Test for JS")
configureKotlinPomAttributes(project, "Kotlin Test for JS", packaging = "klib")
}
configureSbom(
"Js", "kotlin-test-js",
+31 -3
View File
@@ -1,13 +1,17 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import kotlin.io.path.copyTo
plugins {
kotlin("multiplatform")
}
description = "Kotlin Test for JS"
base.archivesName = "kotlin-test-js"
val commonMainSources by task<Sync> {
from(
"$rootDir/libraries/kotlin.test/common/src/main",
"$rootDir/libraries/kotlin.test/annotations-common/src/main"
"$rootDir/libraries/kotlin.test/common/src/main/kotlin",
"$rootDir/libraries/kotlin.test/annotations-common/src/main/kotlin"
)
into("$buildDir/commonMainSources")
}
@@ -18,7 +22,7 @@ val commonTestSources by task<Sync> {
}
val jsMainSources by task<Sync> {
from("$rootDir/libraries/kotlin.test/js/src/main")
from("$rootDir/libraries/kotlin.test/js/src/main/kotlin")
into("$buildDir/jsMainSources")
}
@@ -56,3 +60,27 @@ tasks.named("compileKotlinJs") {
(this as KotlinCompile<*>).kotlinOptions.freeCompilerArgs += "-Xir-module-name=kotlin-test"
}
val jsLegacyRuntimeElements by configurations.creating {
isCanBeResolved = false
}
@Suppress("UNUSED_VARIABLE")
tasks {
val jsJar by existing(Jar::class) {
archiveAppendix = null
manifestAttributes(manifest, "Test")
}
val jsLegacyJar by creating(Jar::class) {
val jsJarFile = jsJar.flatMap { it.archiveFile }
inputs.file(jsJarFile)
archiveAppendix = null
doLast {
jsJarFile.get().asFile.toPath().copyTo(archiveFile.get().asFile.toPath(), overwrite = true)
}
}
artifacts {
add(jsLegacyRuntimeElements.name, jsLegacyJar)
}
val jsSourcesJar by existing(org.gradle.jvm.tasks.Jar::class) {
archiveAppendix = null
}
}
-96
View File
@@ -1,96 +0,0 @@
description = 'Kotlin Test for JS'
apply plugin: 'kotlin-platform-js'
configurations {
distJs
distLibrary
[compileClasspath, runtimeClasspath, testCompileClasspath, testRuntimeClasspath].forEach {
it.attributes {
attribute(org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.jsCompilerAttribute, org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.legacy)
}
}
}
dependencies {
expectedBy project(':kotlin-test:kotlin-test-common')
expectedBy project(':kotlin-test:kotlin-test-annotations-common')
api RepoDependencies.kotlinStdlib(project)
}
compileKotlin2Js {
kotlinOptions.freeCompilerArgs = [
"-Xallow-kotlin-package",
"-opt-in=kotlin.contracts.ExperimentalContracts",
"-opt-in=kotlin.RequiresOptIn",
"-Xforce-deprecated-legacy-compiler-usage",
"-Xexpect-actual-classes"
]
kotlinOptions {
moduleKind = "umd"
outputFile = "${buildDir}/classes/main/kotlin-test.js"
sourceMap = true
sourceMapPrefix = "./"
sourceMapEmbedSources = "always"
}
}
compileTestKotlin2Js {
kotlinOptions {
metaInfo = false
moduleKind = "umd"
freeCompilerArgs = ["-Xallow-kotlin-package", "-Xforce-deprecated-legacy-compiler-usage"]
}
}
archivesBaseName = 'kotlin-test-js'
jar {
enabled false
}
tasks.register("libraryJarWithoutIr", Jar) {
dependsOn(compileKotlin2Js)
archiveClassifier.set(null)
destinationDirectory = file("$buildDir/lib/dist")
from("$buildDir/classes/main")
LibrariesCommon.manifestAttributes(project, manifest, 'Test')
}
tasks.register("libraryJarWithIr", Zip) {
dependsOn(libraryJarWithoutIr)
archiveExtension = "jar"
destinationDirectory = file("$buildDir/libs")
duplicatesStrategy DuplicatesStrategy.FAIL
def archiveOperations = services.get(ArchiveOperations)
from { libraryJarWithoutIr.archiveFile.map { archiveOperations.zipTree(it) } }
dependsOn(":kotlin-test:kotlin-test-js-ir:compileKotlinJs")
from {
def irKlib = tasks.getByPath(":kotlin-test:kotlin-test-js-ir:compileKotlinJs")
fileTree(irKlib.outputs.files.first().path)
}
}
jar.dependsOn(libraryJarWithIr)
tasks.register("sourcesJar", Jar) {
dependsOn(classes)
archiveClassifier.set('sources')
from (sourceSets.main.allSource)
}
artifacts {
archives libraryJarWithIr
distLibrary libraryJarWithIr
archives sourcesJar
distJs(file(compileKotlin2Js.kotlinOptions.outputFile)) {
builtBy(compileKotlin2Js)
}
}
RepoArtifacts.sourcesJar(project)
RepoArtifacts.javadocJar(project)
-1
View File
@@ -1 +0,0 @@
node_modules
-105
View File
@@ -1,105 +0,0 @@
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
plugins {
id "com.github.node-gradle.node" version "5.0.0"
}
description = 'Kotlin-test integration tests for JS'
apply plugin: 'kotlin-platform-js'
configurations {
nodeModules {
extendsFrom api
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, KotlinUsages.KOTLIN_RUNTIME))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy)
}
}
[compileClasspath, runtimeClasspath, testCompileClasspath, testRuntimeClasspath].forEach {
it.attributes {
attribute(org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.jsCompilerAttribute, org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.legacy)
}
}
}
dependencies {
api project(':kotlin-test:kotlin-test-js')
}
// package.json contains direct links to the builddir
buildDir = "$projectDir/build"
["compileKotlin2Js", "compileTestKotlin2Js"].forEach {
tasks.named(it).configure {
kotlinOptions {
moduleKind = "commonjs"
freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
}
}
}
tasks.register("populateNodeModules", Copy) {
dependsOn(compileKotlin2Js)
dependsOn(configurations.nodeModules)
from compileKotlin2Js.destinationDirectory
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // temporary until stdlib mpp migration is completed
from {
configurations.nodeModules.collect {
// WORKAROUND: Some JS IR jars were absent and caused this task to fail.
// They don't contain .js thus we can skip them.
if (it.exists()) {
zipTree(it.absolutePath).matching { include '*.js' }
}
}
}
into "${buildDir}/node_modules"
}
node {
version = RepoDependencies.getNodejsVersion(project)
download = true
}
def createFrameworkTest(def name) {
return tasks.register("test$name", NpmTask) {
dependsOn(compileTestKotlin2Js, populateNodeModules, npmInstall)
def testName = name
def lowerName = name.toLowerCase()
def tcOutput = project.file("$buildDir/tc-${lowerName}.log")
def stdOutput = "$buildDir/test-${lowerName}.log"
def errOutput = "$buildDir/test-${lowerName}.err.log"
def exitCodeFile = project.file("$buildDir/test-${lowerName}.exit-code")
inputs.files(sourceSets.test.output)
inputs.dir("${buildDir}/node_modules")
outputs.files(tcOutput, stdOutput, errOutput, exitCodeFile)
args = ['run', "test-$lowerName"]
group = 'verification'
execOverrides {
it.ignoreExitValue = true
it.standardOutput = new FileOutputStream(stdOutput)
it.errorOutput = new FileOutputStream(errOutput)
}
def ignoreTestFailures = rootProject.ignoreTestFailures
doLast {
println tcOutput.text
if (exitCodeFile.text != "0" && !ignoreTestFailures) {
throw new GradleException("$testName integration test failed")
}
}
}
}
tasks.check {
['Jest', 'Jasmine', 'Mocha', 'Qunit', 'Tape'].each {
dependsOn createFrameworkTest(it)
}
}
File diff suppressed because it is too large Load Diff
-20
View File
@@ -1,20 +0,0 @@
{
"scripts": {
"test-jasmine": "jasmine js/jasmine-reporter.js build/classes/kotlin/test/kotlin-test-js-it_test.js",
"test-jest": "jest",
"test-mocha": "mocha --reporter js/mocha-reporter.js build/classes/kotlin/test/kotlin-test-js-it_test.js",
"test-qunit": "qunit --require ./js/qunit-reporter.js build/classes/kotlin/test/kotlin-test-js-it_test.js",
"test-tape": "tape js/tape-reporter.js js/tape-plugin.js build/classes/kotlin/test/kotlin-test-js-it_test.js"
},
"devDependencies": {
"jasmine": "^3.10.0",
"jest": "^29.5.0",
"mocha": "^9.2.1",
"qunit": "^2.18.2",
"tape": "~4.10.0"
},
"jest": {
"testResultsProcessor": "<rootDir>/js/jest-reporter.js",
"testRegex": "_test\\.js$"
}
}
@@ -281,7 +281,8 @@ open class HierarchicalMppIT : KGPBaseTest() {
"my-lib-bar-metadata-1.0-all.jar",
"third-party-lib-metadata-1.0.jar",
"kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar",
"kotlin-dom-api-compat-${buildOptions.kotlinVersion}.klib"
"kotlin-dom-api-compat-${buildOptions.kotlinVersion}.klib",
"kotlin-test-js-${buildOptions.kotlinVersion}.klib",
).toSortedSet(),
transformedArtifacts().toSortedSet()
)
+3 -3
View File
@@ -136,7 +136,6 @@ val distCompilerPluginProjectsCompat = listOf(
val distSourcesProjects = listOfNotNull(
":kotlin-annotations-jvm",
":kotlin-script-runtime",
":kotlin-test:kotlin-test-js".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
":kotlin-test:kotlin-test-junit",
":kotlin-test:kotlin-test-junit5",
":kotlin-test:kotlin-test-testng"
@@ -169,7 +168,8 @@ dependencies {
if (!kotlinBuildProperties.isInJpsBuildIdeaSync) {
libraries(kotlinStdlib(classifier = "distJsJar"))
libraries(kotlinStdlib(classifier = "distJsKlib"))
libraries(project(":kotlin-test:kotlin-test-js", configuration = "distLibrary"))
libraries(project(":kotlin-test:kotlin-test-js-ir", configuration = "jsRuntimeElements"))
libraries(project(":kotlin-test:kotlin-test-js-ir", configuration = "jsLegacyRuntimeElements"))
}
librariesStripVersion(commonDependency("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
@@ -199,6 +199,7 @@ dependencies {
sources(kotlinStdlib("jdk7", classifier = "sources"))
sources(kotlinStdlib("jdk8", classifier = "sources"))
sources(project(":kotlin-test:kotlin-test-js-ir", configuration = "jsSourcesElements"))
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
sources(kotlinStdlib(classifier = "sources"))
@@ -214,7 +215,6 @@ dependencies {
distStdlibMinimalForTests(project(":kotlin-stdlib-jvm-minimal-for-test"))
distJSContents(project(":kotlin-stdlib", configuration = "distJsContent"))
distJSContents(project(":kotlin-test:kotlin-test-js", configuration = "distJs"))
distCommonContents(project(":kotlin-stdlib", configuration = "commonMainMetadataElements"))
distCommonContents(project(":kotlin-stdlib", configuration = "metadataSourcesElements"))
@@ -10,6 +10,7 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-js</artifactId>
<version>ArtifactsTest.version</version>
<packaging>klib</packaging>
<name>Kotlin Test Js</name>
<description>Kotlin Test for JS</description>
<url>https://kotlinlang.org/</url>
-4
View File
@@ -598,9 +598,7 @@ if (buildProperties.inJpsBuildIdeaSync) {
":tools:kotlin-stdlib-gen",
":kotlin-test",
":kotlin-test:kotlin-test-js",
":kotlin-test:kotlin-test-js-ir",
":kotlin-test:kotlin-test-js:kotlin-test-js-it",
":kotlin-test:kotlin-test-js-ir:kotlin-test-js-ir-it",
":kotlin-test:kotlin-test-wasm-js",
":kotlin-test:kotlin-test-wasm-wasi",
@@ -623,9 +621,7 @@ if (buildProperties.inJpsBuildIdeaSync) {
project(':tools:kotlin-stdlib-gen').projectDir = "$rootDir/libraries/tools/kotlin-stdlib-gen" as File
project(':kotlin-test').projectDir = "$rootDir/libraries/kotlin.test" as File
project(':kotlin-test:kotlin-test-js').projectDir = "$rootDir/libraries/kotlin.test/js" as File
project(':kotlin-test:kotlin-test-js-ir').projectDir = "$rootDir/libraries/kotlin.test/js-ir" as File
project(':kotlin-test:kotlin-test-js:kotlin-test-js-it').projectDir = "$rootDir/libraries/kotlin.test/js/it" as File
project(':kotlin-test:kotlin-test-js-ir:kotlin-test-js-ir-it').projectDir = "$rootDir/libraries/kotlin.test/js-ir/it" as File
project(':kotlin-test:kotlin-test-wasm-js').projectDir = "$rootDir/libraries/kotlin.test/wasm/js" as File
project(':kotlin-test:kotlin-test-wasm-wasi').projectDir = "$rootDir/libraries/kotlin.test/wasm/wasi" as File