[Gradle] Remove old platform plugins ids

We want to remove Gradle ids for old deprecated multiplatform platform
plugins and eventually clean up the code.

Exception for now is common platform plugin as it is still used
in compiler tests. Will be removed separately.

^KT-65187 Verification Pending
This commit is contained in:
Yahor Berdnikau
2024-01-22 16:26:49 +01:00
committed by Space Team
parent 4b6624c920
commit 1bae743524
41 changed files with 20 additions and 340 deletions
@@ -9,6 +9,7 @@ import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.testbase.*
import org.junit.jupiter.api.DisplayName
import kotlin.io.path.appendText
import kotlin.io.path.exists
@DisplayName("Tasks configuration avoidance")
class ConfigurationAvoidanceIT : KGPBaseTest() {
@@ -128,7 +129,7 @@ class ConfigurationAvoidanceIT : KGPBaseTest() {
@DisplayName("JS unrelated tasks are not configured")
@GradleTest
fun jsNoTasksConfigured(gradleVersion: GradleVersion) {
project("kotlin2JsNoOutputFileProject", gradleVersion) {
project("kotlin-js-plugin-project", gradleVersion) {
createTaskWithExpensiveConfiguration()
build("help")
@@ -150,15 +151,27 @@ class ConfigurationAvoidanceIT : KGPBaseTest() {
expensivelyConfiguredTaskName: String = "expensivelyConfiguredTask"
): String {
@Suppress("GroovyAssignabilityCheck")
buildGradle.append(
//language=Groovy
"""
if (buildGradle.exists()) {
buildGradle.appendText(
//language=Groovy
"""
tasks.register("$expensivelyConfiguredTaskName") {
throw new GradleException("Should not configure expensive task!")
}
""".trimIndent()
)
)
} else {
buildGradleKts.appendText(
//language=kotlin
"""
|
|tasks.register("$expensivelyConfiguredTaskName") {
| throw GradleException("Should not configure expensive task!")
|}
""".trimMargin()
)
}
return expensivelyConfiguredTaskName
}
@@ -62,7 +62,7 @@ class KaptModelIT : KGPBaseTest() {
@DisplayName("Model is not available when plugin is not applied")
@GradleTest
fun testNonJvmProjects(gradleVersion: GradleVersion) {
project("kotlin2JsProject", gradleVersion) {
project("kotlin-js-plugin-project", gradleVersion) {
getModels<Kapt> {
assertNull(getModel(":"))
assertNull(getModel(":libraryProject"))
@@ -271,7 +271,7 @@ class NativeDownloadAndPlatformLibsIT : KGPBaseTest() {
@DisplayName("The plugin shouldn't download the K/N compiler if there are no corresponding targets in the project.")
@GradleTest
fun shouldNotDownloadKonanWithoutCorrespondingTargets(gradleVersion: GradleVersion) {
nativeProject("new-mpp-lib-and-app/sample-old-style-app", gradleVersion) {
nativeProject("jvm-and-js-hmpp", gradleVersion) {
build("tasks") {
assertOutputDoesNotContain("Kotlin/Native distribution: ")
}
@@ -1,24 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}
apply plugin: "org.jetbrains.kotlin.platform.js"
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
}
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
@@ -1 +0,0 @@
kotlin.internal.mpp12x.deprecation.suppress=true
@@ -1,8 +0,0 @@
package example
class Dummy {
fun f(): Int {
return 23
}
}
@@ -1,8 +0,0 @@
package example
class DummyTest {
fun test() {
Dummy().f()
}
}
@@ -1 +0,0 @@
kotlin.internal.mpp12x.deprecation.suppress=true
@@ -1,52 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'org.jetbrains.kotlin.platform.js'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
}
tasks.register("jarSources", Jar) {
from sourceSets.main.allSource
archiveClassifier = 'source'
}
artifacts {
implementation jarSources
}
def outDir = "${buildDir}/kotlin2js/main/"
compileKotlin2Js.destinationDirectory = new File(outDir)
compileKotlin2Js.kotlinOptions.moduleName = "test-library"
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"]
jar {
from sourceSets.main.allSource
include "**/*.kt"
from outDir
include ("**/*")
manifest {
attributes(
"Specification-Title": "Kotlin JavaScript Lib",
"Kotlin-JS-Module-Name": "test-library"
)
}
}
jar.dependsOn(compileKotlin2Js)
@@ -1,6 +0,0 @@
package example
class Adder {
public fun add(x: Int, y: Int): Int = x + y
}
@@ -1,15 +0,0 @@
package example.library
import org.w3c.dom.Text
import kotlinx.browser.*
public class Counter(val el: Text) {
fun step(n: Int) {
document.title = "Counter: ${n}"
window.setTimeout({step(n+1)}, 1000)
}
fun start() {
step(0)
}
}
@@ -1,44 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'org.jetbrains.kotlin.platform.js'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation project(":libraryProject")
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
}
compileKotlin2Js.kotlinOptions.sourceMap = true
compileKotlin2Js.destinationDirectory = new File(projectDir, "web/js")
compileKotlin2Js.kotlinOptions.moduleName = "app"
compileKotlin2Js.kotlinOptions.suppressWarnings = true
compileKotlin2Js.kotlinOptions.verbose = true
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
build.doLast {
configurations.compile.each { File file ->
copy {
includeEmptyDirs = false
from zipTree(file.absolutePath)
into "${projectDir}/web/js/lib"
include { fileTreeElement ->
def path = fileTreeElement.path
path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
}
}
}
}
@@ -1,19 +0,0 @@
package example
import kotlinx.browser.document
import example.library.Counter
fun main(args: Array<String>) {
val el = document.createElement("div")
el.appendChild(document.createTextNode("Hello!"))
document.body!!.appendChild(el)
val counterDiv = document.createElement("div")
val counterText = document.createTextNode("Counter!")
counterDiv.appendChild(counterText)
document.body!!.appendChild(counterDiv)
val counter = Counter(counterText)
counter.start()
}
@@ -1 +0,0 @@
include 'mainProject', 'libraryProject'
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="js/lib/kotlin.js"></script>
</head>
<body>
<script src="js/app.js"></script>
</body>
</html>
@@ -1,17 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -1,7 +0,0 @@
package foo
expect class PlatformClassA {
val valueA: String
}
class CommonClassA
@@ -1,7 +0,0 @@
package foo
expect class PlatformTestA {
val valueA: PlatformClassA
}
class CommonTestA(val commonClassA: CommonClassA)
@@ -1,7 +0,0 @@
package foo
expect class PlatformClassB {
val valueB: String
}
class CommonClassB
@@ -1,7 +0,0 @@
package foo
expect class PlatformTestB {
val valueB: PlatformClassB
}
class CommonTestB(val commonClassB: CommonClassB)
@@ -1,8 +0,0 @@
apply plugin: 'kotlin-platform-jvm'
dependencies {
expectedBy project(":libA")
expectedBy project(":libB")
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.google.guava:guava:20.0'
}
@@ -1,9 +0,0 @@
package foo
actual class PlatformClassA {
actual val valueA: String = "JVM"
}
actual class PlatformClassB {
actual val valueB: String = "JVM"
}
@@ -1,7 +0,0 @@
package foo
import com.google.common.collect.ImmutableSet
fun main(args: Array<String>) {
val colors = ImmutableSet.of("red", "orange", "yellow")
}
@@ -1,9 +0,0 @@
package foo
actual class PlatformTestA {
actual val valueA: PlatformClassA = PlatformClassA()
}
actual class PlatformTestB {
actual val valueB: PlatformClassB = PlatformClassB()
}
@@ -1,5 +0,0 @@
apply plugin: 'kotlin-platform-common'
dependencies {
implementation 'com.example:sample-lib:1.0'
}
@@ -1,10 +0,0 @@
package com.example.app
import com.example.lib.id
import com.example.lib.expectedFun
fun idUsage(x: Int): Int = id(x)
fun main(args: Array<String>) {
expectedFun()
}
@@ -1,10 +0,0 @@
apply plugin: 'kotlin'
apply plugin: 'application'
dependencies {
implementation 'com.example:sample-lib:1.0'
}
application {
mainClass = 'com.example.app.JvmAppKt'
}
@@ -1,10 +0,0 @@
package com.example.app
import com.example.lib.id
import com.example.lib.expectedFun
fun idUsage(x: Int): Int = id(x)
fun main(args: Array<String>) {
expectedFun()
}
@@ -1,18 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
// NB: Build of this module depends on 'sample-lib' publication. You need to add the local
// repository where 'sample-lib' artifacts are published.
}
}
@@ -1 +0,0 @@
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinPlatformAndroidPlugin
@@ -1 +0,0 @@
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJsPlugin
@@ -1 +0,0 @@
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
@@ -1 +0,0 @@
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinPlatformAndroidPlugin
@@ -1 +0,0 @@
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJsPlugin
@@ -1 +0,0 @@
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin