Skip to content

Commit

Permalink
chore: Move to Kotlin 1.9.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Virelion committed Nov 18, 2023
1 parent cf2a358 commit 1524890
Show file tree
Hide file tree
Showing 21 changed files with 282 additions and 269 deletions.
1 change: 1 addition & 0 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
publishMacosX64PublicationToMavenLocal
publishIosX64PublicationToMavenLocal
publishIosArm64PublicationToMavenLocal
publishIosArmSimulator64PublicationToMavenLocal
macosX64Test iosX64Test
- name: Integration tests
working-directory: integration-test-project
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ buildscript {
}

plugins {
kotlin("multiplatform") version "1.7.10" apply false
id("org.jlleitschuh.gradle.ktlint") version "10.3.0" apply false
kotlin("multiplatform") version "1.9.20" apply false
id("org.jlleitschuh.gradle.ktlint") version "11.6.1" apply false
id("com.gradle.plugin-publish") version "1.1.0" apply false
id("nebula.release") version "13.2.1"
}
Expand Down
2 changes: 1 addition & 1 deletion buildata-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ val kspVersion: String by project
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("gradle-plugin-api"))
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
implementation("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$kspVersion")
compileOnly("com.google.auto.service:auto-service:1.0.1")
kapt("com.google.auto.service:auto-service:1.0.1")
Expand Down
1 change: 0 additions & 1 deletion buildata-ksp-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ repositories {
val kspVersion: String by project

dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("compiler-embeddable"))
implementation("com.google.devtools.ksp:symbol-processing-api:$kspVersion")
compileOnly("com.google.auto.service:auto-service:1.0.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
package io.github.virelion.buildata.ksp

import com.google.devtools.ksp.symbol.KSAnnotation
import com.google.devtools.ksp.symbol.KSPropertyDeclaration
import com.google.devtools.ksp.symbol.KSType
import com.google.devtools.ksp.symbol.KSValueParameter
import io.github.virelion.buildata.ksp.extensions.classFQName
import io.github.virelion.buildata.ksp.extensions.className
import io.github.virelion.buildata.ksp.extensions.pkg
Expand All @@ -26,12 +28,20 @@ import io.github.virelion.buildata.ksp.utils.CodeBuilder
class ClassProperty(
val name: String,
val type: KSType,
val hasDefaultValue: Boolean,
val nullable: Boolean,
val annotations: Sequence<KSAnnotation>,
val buildable: Boolean,
val pathReflection: Boolean
val pathReflection: Boolean,
val classProperty: KSPropertyDeclaration?,
val constructorParameter: KSValueParameter
) {
val annotations: Sequence<KSAnnotation> get() {
return constructorParameter.annotations +
(classProperty?.annotations ?: emptySequence()) +
(classProperty?.getter?.annotations ?: emptySequence()) +
(classProperty?.setter?.annotations ?: emptySequence())
}

val hasDefaultValue: Boolean get() = constructorParameter.hasDefault
val backingPropName = "${name}_Element"

fun generatePropertyDeclaration(codeBuilder: CodeBuilder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ internal class KSClassDeclarationProcessor(
.filter { it.isVar || it.isVal }
.map { parameter ->
val type = parameter.type.resolve()
val classProp = this.getAllProperties().find { it.simpleName == parameter.name }

ClassProperty(
name = requireNotNull(parameter.name?.getShortName(), parameter) { "$printableFqName contains nameless property" },
type = type,
hasDefaultValue = parameter.hasDefault,
nullable = type.nullability == Nullability.NULLABLE,
annotations = parameter.annotations,
buildable = (type.classFQName() in annotatedClasses.buildable),
pathReflection = (type.classFQName() in annotatedClasses.pathReflection)
pathReflection = (type.classFQName() in annotatedClasses.pathReflection),
classProp,
parameter
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ fun KSType.typeFQName(): String {
val genericTypes = if (this.innerArguments.isNotEmpty()) {
this.innerArguments.mapNotNull { it.type?.resolve()?.typeFQName() }
.joinToString(prefix = "<", postfix = ">", separator = ", ")
} else ""
} else {
""
}
return "${declaration.qualifiedName!!.getQualifier()}.${className()}$genericTypes${nullability.toCode()}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ package io.github.virelion.buildata.ksp.path
import com.google.devtools.ksp.symbol.KSAnnotation
import io.github.virelion.buildata.ksp.ClassProperty
import io.github.virelion.buildata.ksp.extensions.classFQName
import org.jetbrains.kotlin.utils.addToStdlib.safeAs

@JvmInline
value class StringNamePathIdentifier(
private val classProperty: ClassProperty,
private val classProperty: ClassProperty
) {
companion object {
val PATH_ELEMENT_NAME_FQNAME = "io.github.virelion.buildata.path.PathElementName"
Expand All @@ -47,11 +46,11 @@ value class StringNamePathIdentifier(
}

private fun KSAnnotation.getFirstParamOfAnnotationAsString(): String? {
return arguments.firstOrNull()?.value?.safeAs<String>()
return arguments.firstOrNull()?.value as? String
}

private fun KSAnnotation.getFirstListElementOfAnnotationAsString(): String? {
return arguments.firstOrNull()?.value?.safeAs<List<String>>()?.firstOrNull()
return (arguments.firstOrNull()?.value as? List<String>)?.firstOrNull()
}

override fun toString(): String {
Expand Down
52 changes: 10 additions & 42 deletions buildata-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
kotlin("multiplatform")
`maven-publish`
id("org.jlleitschuh.gradle.ktlint")
id("org.jetbrains.dokka") version "1.8.10"
id("org.jetbrains.dokka") version "1.9.10"
signing
}

Expand Down Expand Up @@ -48,7 +48,9 @@ kotlin {
linuxX64()
}

ios()
iosX64()
iosArm64()
iosSimulatorArm64()
val publicationsFromMainHost =
listOf(jvm(), js())
.map { it.name } + "kotlinMultiplatform" + "androidDebug" + "androidRelease" + "metadata"
Expand All @@ -70,12 +72,12 @@ kotlin {
}

sourceSets {
val commonMain by getting {
commonMain {
dependencies {
}
}

val commonTest by getting {
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
Expand All @@ -100,40 +102,13 @@ kotlin {
}
}

val nativeMain by creating {
dependencies {
}
}

val mingwX64Main by getting {
dependsOn(nativeMain)
}

val macosX64Main by getting {
dependsOn(nativeMain)
}

if (linuxTargetEnabled) {
val linuxX64Main by getting {
dependsOn(nativeMain)
}
}

val iosX64Main by getting {
dependsOn(nativeMain)
}

val iosArm64Main by getting {
dependsOn(nativeMain)
}

if (androidEnabled) {
val androidMain by getting {
dependencies {
}
}

val androidTest by getting {
val androidUnitTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
Expand All @@ -146,19 +121,19 @@ kotlin {
tasks {
withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn")
freeCompilerArgs = freeCompilerArgs + listOf("-opt-in=kotlin.RequiresOptIn")
}
}

withType(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class).all {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn")
freeCompilerArgs = freeCompilerArgs + listOf("-opt-in=kotlin.RequiresOptIn")
}
}

withType(org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile::class).all {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn")
freeCompilerArgs = freeCompilerArgs + listOf("-opt-in=kotlin.RequiresOptIn")
}
}

Expand Down Expand Up @@ -200,9 +175,6 @@ afterEvaluate {
apply(from = "$rootDir/gradle/pom.gradle.kts")
val configurePOM: ((MavenPublication, Project) -> Unit) by extra

this.forEach {
logger.warn(it.name)
}
this.getByName<MavenPublication>("androidRelease") {
configurePOM(this, project)
}
Expand All @@ -216,10 +188,8 @@ afterEvaluate {
}

fun Project.configureAndroid() {

configure<LibraryExtension> {
namespace = "io.github.virelion"
buildToolsVersion = "29.0.2"
compileSdkVersion = "android-29"

defaultConfig {
Expand All @@ -234,14 +204,12 @@ fun Project.configureAndroid() {
sourceSets.getByName("main").apply {
java.srcDirs("src/androidMain/kotlin")
res.srcDirs("src/androidMain/res")
manifest.srcFile("src/androidMain/AndroidManifest.xml")
assets.srcDirs("src/commonMain/resources/assets")
}

sourceSets.getByName("androidTest").apply {
java.srcDirs("src/commonTest/kotlin", "src/jvmTest/kotlin")
res.srcDirs("src/androidTest/res")
manifest.srcFile("src/androidMain/AndroidManifest.xml")
assets.srcDirs("src/commonMain/resources/assets")
}

Expand Down
2 changes: 0 additions & 2 deletions buildata-runtime/src/androidMain/AndroidManifest.xml

This file was deleted.

3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
group=io.github.virelion
version=0.0.0-SNAPSHOT

kspVersion= 1.8.20-RC2-1.0.9
kspVersion= 1.9.20-1.0.14

kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.enableGranularSourceSetsMetadata=true

org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m
6 changes: 3 additions & 3 deletions integration-test-project/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ buildscript {
google()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
classpath("com.android.tools.build:gradle:8.1.0")
}
}

plugins {
val kotlinVersion = "1.8.20"
val kotlinVersion = "1.9.20"
kotlin("multiplatform") version kotlinVersion apply false
kotlin("jvm") version kotlinVersion apply false
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
id("io.github.virelion.buildata") version "0.0.0-SNAPSHOT" apply false
}

Expand Down
Binary file modified integration-test-project/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sat Jul 20 17:41:23 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip
Loading

0 comments on commit 1524890

Please sign in to comment.