Skip to content

Commit

Permalink
Update Kotlin to 1.8.20
Browse files Browse the repository at this point in the history
Also Gradle to 8.0, new version of publish plugin and I hope everything still works correctly in FIR.
  • Loading branch information
ShikaSD committed Apr 12, 2023
1 parent 22f9ea1 commit dc454f4
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ gradle-app.setting
# gradle/wrapper/gradle-wrapper.properties

.DS_Store
local.properties
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The plugin adds `readResolve` method for every object which either:
// plugins dsl
plugins {
id "me.shika.kotlin-object-java-serialization" version "1.4.1"
id "me.shika.kotlin-object-java-serialization" version "1.4.2"
}
// or else
Expand All @@ -25,7 +25,7 @@ buildscript {
}
}
dependencies {
classpath "me.shika:kotlin-object-java-serialization:1.4.1"
classpath "me.shika:kotlin-object-java-serialization:1.4.2"
}
}
Expand Down
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.7.21'
id 'org.jetbrains.kotlin.jvm' version '1.8.20'
}

sourceCompatibility = 1.8

allprojects {
repositories {
mavenLocal()
Expand All @@ -13,5 +11,9 @@ allprojects {
}

group 'me.shika'
version '1.4.1'
version '1.4.2'

kotlin {
jvmToolchain(11)
}
}
33 changes: 5 additions & 28 deletions gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
plugins {
id 'com.gradle.plugin-publish' version '0.18.0'
id 'com.gradle.plugin-publish' version '1.2.0'
id 'maven-publish'
id 'java-gradle-plugin'
id 'org.jetbrains.kotlin.jvm'
}

apply from: rootProject.file('gradle/utils/embedded.gradle')

pluginBundle {
gradlePlugin {
website = 'https://github.com/ShikaSD/kotlin-object-serialization-fix'
vcsUrl = 'https://github.com/ShikaSD/kotlin-object-serialization-fix.git'

plugins {
objectSerialization {
displayName = "Java serialization fix for Kotlin object"
description = "Solves the problem of Kotlin object being having different instance after deserialization using built-in Java serialization."
tags = ['kotlin', 'compiler-plugin', 'java', 'serialization']
}
}

mavenCoordinates {
groupId = project.getGroup()
artifactId = "kotlin-object-java-serialization"
version = project.getVersion()
}
}

publishing {
afterEvaluate {
publications {
withType(MavenPublication) {
artifactId "kotlin-object-java-serialization"
}
}
}
}

gradlePlugin {
plugins {
objectSerialization {
id = "me.shika.kotlin-object-java-serialization"
implementationClass = "me.shika.ObjectSerializationPlugin"
displayName = "Java serialization fix for Kotlin object"
description = "Solves the problem of Kotlin object being having different instance after deserialization using built-in Java serialization."
tags.set(['kotlin', 'compiler-plugin', 'java', 'serialization'])
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ObjectSerializationPlugin : KotlinCompilerPluginSupportPlugin {
SubpluginArtifact(
groupId = "me.shika",
artifactId = "kotlin-object-java-serialization",
version = "1.4.1"
version = "1.4.2"
)

override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion gradle/utils/embedded.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ afterEvaluate {
}
}

task sourcesJar(type: Jar) {
tasks.getByName("sourcesJar") {
archiveClassifier = 'sources'
from embeddedProjects().collect { it.sourceSets.main.allSource }
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions integration-test/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
// Use for testing maven local
// id 'me.shika.kotlin-object-java-serialization' version '1.4.2'
}

dependencies {
Expand Down
9 changes: 1 addition & 8 deletions kotlin-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin-api"
compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable"

testImplementation 'com.github.tschuchortdev:kotlin-compile-testing:1.4.9'
testImplementation 'com.github.tschuchortdev:kotlin-compile-testing:1.5.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.jetbrains.kotlin:kotlin-compiler-embeddable'
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package me.shika
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption
import org.jetbrains.kotlin.compiler.plugin.CliOption
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.CompilerConfigurationKey

//@AutoService(CommandLineProcessor::class)
@OptIn(ExperimentalCompilerApi::class)
class ObjectSerializationCommandLineProcessor : CommandLineProcessor {
override val pluginId: String = "object-serialization-fix"
override val pluginOptions: Collection<AbstractCliOption> =
Expand Down
14 changes: 8 additions & 6 deletions kotlin-plugin/src/main/kotlin/me/shika/ComponentRegistrar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ import me.shika.generation.ObjectSerializationIrGeneration
import me.shika.generation.ObjectSerializationJvmGeneration
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension
import org.jetbrains.kotlin.com.intellij.mock.MockProject
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.jetbrains.kotlin.config.CompilerConfiguration

class ObjectSerializationComponentRegistrar(): ComponentRegistrar {
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
@OptIn(ExperimentalCompilerApi::class)
class ObjectSerializationCompilerPluginRegistrar : CompilerPluginRegistrar() {
override val supportsK2: Boolean
get() = true

override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
if (configuration[KEY_ENABLED] == false) {
return
}

ExpressionCodegenExtension.registerExtension(
project,
ObjectSerializationJvmGeneration()
)

IrGenerationExtension.registerExtension(
project,
ObjectSerializationIrGeneration()
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
me.shika.ObjectSerializationCompilerPluginRegistrar

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@ package me.shika

import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import org.junit.runners.Parameterized.Parameters
import java.lang.reflect.Method

@OptIn(ExperimentalCompilerApi::class)
@RunWith(Parameterized::class)
class ObjectSerializationFixTest(enableIr: Boolean) {
class ObjectSerializationFixTest(enableIr: Boolean, enableFir: Boolean) {
companion object {
@Parameters(name = "IR: {0}")
@Parameters(name = "IR: {0}, FIR: {1}")
@JvmStatic
fun data() = listOf(false, true)
fun data() = arrayOf(arrayOf(false, false), arrayOf(true, false), arrayOf(true, true))
}

private val compiler = KotlinCompilation().apply {
compilerPlugins = listOf(ObjectSerializationComponentRegistrar())
compilerPluginRegistrars = listOf(ObjectSerializationCompilerPluginRegistrar())
useIR = enableIr
supportsK2 = true
useK2 = enableFir
}

private val SERIALIZABLE_OBJECT = """
Expand Down
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
mavenCentral()
}
}

rootProject.name = 'kotlin-object-java-serialization'

include ':gradle-plugin'
include ':kotlin-plugin'
include ':integration-test'
include ':integration-test:scala-module'

project(':gradle-plugin').name = "kotlin-object-java-serialization"

0 comments on commit dc454f4

Please sign in to comment.