Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-support/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ allprojects {
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.add("-Xjvm-default=all")
freeCompilerArgs.add("-jvm-default=no-compatibility")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
Expand Down Expand Up @@ -231,7 +230,7 @@ class WireBuildPlugin : Plugin<Project> {
tasks.withType(KotlinJvmCompile::class.java).configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString()))
freeCompilerArgs.add("-Xjvm-default=all")
freeCompilerArgs.add("-jvm-default=no-compatibility")
}
}
// Kotlin requires the Java compatibility matches.
Expand All @@ -252,48 +251,46 @@ class WireBuildPlugin : Plugin<Project> {
kotlin.configureWebKotlinLibraries()
}
plugins.withId("org.jetbrains.kotlin.js") {
val kotlin = extensions.getByName("kotlin") as KotlinJsProjectExtension
kotlin.configureWebKotlinLibraries()
val kotlin = extensions.getByName("kotlin") as KotlinProjectExtension
kotlin.configureJsKotlinLibraries()
}
}

// For KotlinWasm/Js, versions of toolchain and stdlib need to be the same:
// https://youtrack.jetbrains.com/issue/KT-71032
private fun KotlinProjectExtension.configureWebKotlinLibraries() {
private fun KotlinProjectExtension.configureJsKotlinLibraries() {
val kotlinVersion = project.getVersionByName("kotlin")

when (this) {
is KotlinJsProjectExtension -> {
val suffix = "js"
sourceSets.apply {
getByName("main").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
}
getByName("test").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-test-$suffix:$kotlinVersion")
}
}
val suffix = "js"
sourceSets.apply {
getByName("main").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
}
getByName("test").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-test-$suffix:$kotlinVersion")
}
}
}

is KotlinMultiplatformExtension -> {
targets.matching { it.platformType in listOf(KotlinPlatformType.js, KotlinPlatformType.wasm) }.configureEach {
val suffix = when (platformType) {
KotlinPlatformType.js -> "js"
KotlinPlatformType.wasm -> if (targetName.contains("wasi", true)) "wasm-wasi" else "wasm-js"
else -> return@configureEach
}
private fun KotlinMultiplatformExtension.configureWebKotlinLibraries() {
val kotlinVersion = project.getVersionByName("kotlin")

this@configureWebKotlinLibraries.sourceSets.apply {
getByName("${targetName}Main").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
}
targets.matching { it.platformType in listOf(KotlinPlatformType.js, KotlinPlatformType.wasm) }.configureEach {
val suffix = when (platformType) {
KotlinPlatformType.js -> "js"
KotlinPlatformType.wasm -> if (targetName.contains("wasi", true)) "wasm-wasi" else "wasm-js"
else -> return@configureEach
}

getByName("${targetName}Test").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-test-$suffix:$kotlinVersion")
}
}
this@configureWebKotlinLibraries.sourceSets.apply {
getByName("${targetName}Main").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
}

getByName("${targetName}Test").dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-$suffix:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-test-$suffix:$kotlinVersion")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jimfs = "1.3.1"
jmh = "1.37"
jsr305 = "3.0.2"
junit = "4.13.2"
kotlin = "2.3.21"
kotlin = "2.4.0"
# Set to lower version than KGP version to maximize compatibility
kotlinCoreLibrariesVersion = "2.0.21"
kotlinpoet = "2.3.0"
Expand Down
2 changes: 1 addition & 1 deletion samples/js/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("js")
kotlin("multiplatform")
id("com.squareup.wire")
}

Expand Down
2 changes: 1 addition & 1 deletion samples/wire-grpc-sample/server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tasks.withType<JavaCompile>().configureEach {
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
freeCompilerArgs.add("-Xjvm-default=all")
freeCompilerArgs.add("-jvm-default=no-compatibility")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.UnknownConfigurationException
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.SourceSetContainer
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet

class WirePlugin : Plugin<Project> {
Expand Down Expand Up @@ -270,7 +270,7 @@ class WirePlugin : Plugin<Project> {

isJsOnly -> {
val sourceSets =
project.extensions.getByType(KotlinJsProjectExtension::class.java).sourceSets
project.extensions.getByType(KotlinProjectExtension::class.java).sourceSets
val sourceSet = (sourceSets.getByName("main") as DefaultKotlinSourceSet)
project.dependencies.add(sourceSet.apiConfigurationName, runtimeDependency)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ class WirePluginTest {
}
assertThat(buildCacheDir.exists()).isFalse()

val generatedProto = "build/generated/source/wire/com/squareup/geology/Period.kt"
val generatedProto = "build/generated/source/wire/com/squareup/geology/Period.java"

val fixtureRoot = File("src/test/projects/cache-relocation-1")
val result = fixtureGradleRunner(fixtureRoot)
Expand Down Expand Up @@ -1319,7 +1319,7 @@ class WirePluginTest {
}
assertThat(buildCacheDir.exists()).isFalse()

val generatedStatus = "build/generated/source/wire/com/google/rpc/Status.kt"
val generatedStatus = "build/generated/source/wire/com/google/rpc/Status.java"

val fixtureRoot = File("src/test/projects/cache-source-relocation-1")
val result = fixtureGradleRunner(fixtureRoot)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
dependencies {
classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
classpath libs.pluginz.kotlin
}

repositories {
Expand All @@ -14,7 +13,6 @@ buildscript {
}

apply plugin: 'application'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.squareup.wire'

// The code in this test project should be identical to
Expand All @@ -35,6 +33,6 @@ dependencies {
}

wire {
kotlin {
java {
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
dependencies {
classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
classpath libs.pluginz.kotlin
}

repositories {
Expand All @@ -14,7 +13,6 @@ buildscript {
}

apply plugin: 'application'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.squareup.wire'

// The code in this test project should be identical to
Expand All @@ -35,6 +33,6 @@ dependencies {
}

wire {
kotlin {
java {
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
dependencies {
classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
classpath libs.pluginz.kotlin
}

repositories {
Expand All @@ -14,7 +13,6 @@ buildscript {
}

apply plugin: 'application'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.squareup.wire'

// The code in this test project should be identical to
Expand All @@ -36,6 +34,6 @@ wire {
srcJar("com.google.api.grpc:proto-google-common-protos:2.57.0")
include("google/rpc/status.proto")
}
kotlin {
java {
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
buildscript {
dependencies {
classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
classpath libs.pluginz.kotlin
}

repositories {
Expand All @@ -14,7 +13,6 @@ buildscript {
}

apply plugin: 'application'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.squareup.wire'

// The code in this test project should be identical to
Expand All @@ -36,6 +34,6 @@ wire {
srcJar("com.google.api.grpc:proto-google-common-protos:2.57.0")
include("google/rpc/status.proto")
}
kotlin {
java {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,19 @@ data class Service(
)
}

@JvmStatic internal fun fromElements(
@JvmStatic
@JvmName("fromElements\$wire_schema") // Preserve the Kotlin 2.3 internal JVM name.
internal fun fromElements(
packageName: String?,
elements: List<ServiceElement>,
): List<Service> = elements.map { service ->
val protoType = get(packageName, service.name)
fromElement(protoType, service)
}

@JvmStatic internal fun toElements(services: List<Service>): List<ServiceElement> = services.map { service ->
@JvmStatic
@JvmName("toElements\$wire_schema") // Preserve the Kotlin 2.3 internal JVM name.
internal fun toElements(services: List<Service>): List<ServiceElement> = services.map { service ->
ServiceElement(
service.location,
service.name,
Expand Down
Loading