diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 535215f..9d3f5d9 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -22,23 +22,23 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3.0.2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Java - uses: actions/setup-java@v3.5.0 + uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: 11 + distribution: 'temurin' + java-version: 17 - name: build - uses: gradle/gradle-build-action@v2.3.0 + uses: gradle/gradle-build-action@v2 with: arguments: --full-stacktrace build - name: Upload reports - uses: actions/upload-artifact@v3.1.0 + uses: actions/upload-artifact@v4 with: name: 'reports-${{ matrix.os }}' path: '**/build/reports/**' @@ -51,18 +51,18 @@ jobs: timeout-minutes: 60 steps: - - uses: actions/checkout@v3.0.2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Java - uses: actions/setup-java@v3.5.0 + uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: 11 + distribution: 'temurin' + java-version: 17 - name: Format - uses: gradle/gradle-build-action@v2.2.0 + uses: gradle/gradle-build-action@v2 with: arguments: ktlintFormat @@ -70,7 +70,7 @@ jobs: run: ./gradlew --stop - name: "Commit formatted files" - uses: stefanzweifel/git-auto-commit-action@v4.15.0 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Format files using ktlint file_pattern: "**/*.kt" @@ -80,21 +80,21 @@ jobs: timeout-minutes: 60 steps: - - uses: actions/checkout@v3.0.2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Java - uses: actions/setup-java@v3.5.0 + uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: 11 + distribution: 'temurin' + java-version: 17 - name: Checkout run: rm -rf docs - name: Format - uses: gradle/gradle-build-action@v2.2.0 + uses: gradle/gradle-build-action@v2 with: arguments: :mutable-utils:dokkaHtml @@ -102,7 +102,7 @@ jobs: run: ./gradlew --stop - name: "Commit formatted files" - uses: stefanzweifel/git-auto-commit-action@v4.15.0 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Update documentation file_pattern: "docs/*" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c38ac44..ec6e735 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,18 +7,21 @@ jobs: publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Set up Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - java-version: 11 - distribution: 'adopt' + distribution: 'temurin' + java-version: 17 + - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1.0.4 + uses: gradle/wrapper-validation-action@v1 + - name: Publish package - uses: gradle/gradle-build-action@v2.3.0 + uses: gradle/gradle-build-action@v2 with: arguments: publish env: diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 9d60f3d..92376c6 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -6,9 +6,6 @@ plugins { } val gradleJvmTarget = "11" -val gradleKotlinTarget = "1.8" - -val kotlinVersion = "1.8.10" dependencies { implementation(platform(libs.kotlin.bom)) @@ -21,23 +18,9 @@ dependencies { implementation(libs.gradlePlugin.dokka) } - -tasks.withType().configureEach { - kotlinOptions { - jvmTarget = gradleJvmTarget - apiVersion = gradleKotlinTarget - languageVersion = gradleKotlinTarget - } -} - - -kotlin { - jvmToolchain { +java { + toolchain { (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget)) } } - -kotlinDslPluginOptions { - jvmTarget.set(gradleJvmTarget) -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b4ebb01..c88074a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,14 +1,14 @@ [versions] -kotlin = "1.8.10" -dokka = "1.8.10" -kspVersion = "1.8.10-1.0.9" -kotlinPoet = "1.12.0" -kotlinCompileTesting = "1.5.0" -kotest = "5.5.5" -classgraph = "4.8.157" -commonsIo = "2.11.0" -ktlint = "11.3.1" -junit = "5.9.2" +kotlin = "1.9.21" +dokka = "1.9.10" +kspVersion = "1.9.21-1.0.16" +kotlinPoet = "1.15.3" +kotlinCompileTesting = "0.4.0" +kotest = "5.8.0" +classgraph = "4.8.165" +commonsIo = "2.15.1" +ktlint = "12.0.3" +junit = "5.10.1" [libraries] kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" } @@ -17,8 +17,8 @@ kotlin-stdlibJDK8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8" } kotlinPoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinPoet" } kotlinPoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinPoet" } ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "kspVersion" } -kotlinCompileTesting = { module = "com.github.tschuchortdev:kotlin-compile-testing", version.ref = "kotlinCompileTesting" } -kotlinCompileTestingKsp = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version.ref = "kotlinCompileTesting" } +kotlinCompileTesting = { module = "dev.zacsweers.kctfork:core", version.ref = "kotlinCompileTesting" } +kotlinCompileTestingKsp = { module = "dev.zacsweers.kctfork:ksp", version.ref = "kotlinCompileTesting" } kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } classgraph = { module = "io.github.classgraph:classgraph", version.ref = "classgraph" } apache-commons-io = { module = "commons-io:commons-io", version.ref = "commonsIo" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ef62641..a595206 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/kopykat-ksp/src/main/kotlin/at/kopyk/utils/TypeCompileScope.kt b/kopykat-ksp/src/main/kotlin/at/kopyk/utils/TypeCompileScope.kt index 2780d58..329590c 100644 --- a/kopykat-ksp/src/main/kotlin/at/kopyk/utils/TypeCompileScope.kt +++ b/kopykat-ksp/src/main/kotlin/at/kopyk/utils/TypeCompileScope.kt @@ -14,6 +14,7 @@ import com.google.devtools.ksp.symbol.KSDeclaration import com.google.devtools.ksp.symbol.KSPropertyDeclaration import com.google.devtools.ksp.symbol.KSType import com.google.devtools.ksp.symbol.KSTypeAlias +import com.google.devtools.ksp.symbol.KSTypeParameter import com.google.devtools.ksp.symbol.KSTypeReference import com.google.devtools.ksp.symbol.Visibility import com.squareup.kotlinpoet.ClassName @@ -93,6 +94,7 @@ internal class ClassCompileScope( get() = parameterizedWhenNotEmpty(typeVariableNames.map { it.makeInvariant() }) override fun KSType.hasMutableCopy(): Boolean { + if (declaration is KSTypeParameter) return false val closestDecl = declaration.closestClassDeclaration() return closestDecl != null && closestDecl in mutableCandidates } diff --git a/utils/compiletesting/build.gradle.kts b/utils/compiletesting/build.gradle.kts index a1fa253..77c8790 100644 --- a/utils/compiletesting/build.gradle.kts +++ b/utils/compiletesting/build.gradle.kts @@ -18,4 +18,5 @@ dependencies { ) } implementation(libs.kotlinCompileTestingKsp) + implementation(libs.ksp) } diff --git a/utils/compiletesting/src/main/kotlin/at/kopyk/compiletesting/Compilation.kt b/utils/compiletesting/src/main/kotlin/at/kopyk/compiletesting/Compilation.kt index 1325bde..801a1cb 100644 --- a/utils/compiletesting/src/main/kotlin/at/kopyk/compiletesting/Compilation.kt +++ b/utils/compiletesting/src/main/kotlin/at/kopyk/compiletesting/Compilation.kt @@ -1,6 +1,9 @@ +@file:OptIn(ExperimentalCompilerApi::class) + package at.kopyk.compiletesting import com.google.devtools.ksp.processing.SymbolProcessorProvider +import com.tschuchort.compiletesting.CompilationResult import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.KotlinCompilation.ExitCode.OK import com.tschuchort.compiletesting.SourceFile @@ -13,6 +16,7 @@ import java.io.File import java.net.URLClassLoader import java.nio.file.Files import java.nio.file.Paths +import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi private const val SOURCE_FILENAME = "Source.kt" @@ -54,7 +58,7 @@ public fun String.evals( // ======================================= internal data class FullCompilationResult( - val mainResult: KotlinCompilation.Result, + val mainResult: CompilationResult, val additionalMessages: String? ) { val exitCode = mainResult.exitCode @@ -65,10 +69,10 @@ internal data class FullCompilationResult( } } -private fun KotlinCompilation.Result.pass1Result() = +private fun CompilationResult.pass1Result() = FullCompilationResult(this, null) -private fun KotlinCompilation.Result.pass2Result(additionalMessages: String) = +private fun CompilationResult.pass2Result(additionalMessages: String) = FullCompilationResult(this, additionalMessages) internal fun compile(