Skip to content

Commit

Permalink
Update to K2 (#510)
Browse files Browse the repository at this point in the history
* Updates

* Update KCT

* Cleanups

* Update CI

* Add .kotlin to .gitignore

* Misc opt-ins and beta3 fixes

* Update KCT to alpha02

* Update KCT + add KSP2 testing

* Add exclusions

* Spotless

* Oops one too many

* concurrency

* Remove JDK from matrix

* Typo

* Spotless

* Enable CC

* Enable caching and COD

* Fixes

* Disable CC in publishing

* Mark validateProguardRules as not CC compatible

* Beta4

* Update KSP2 and KCT bits

* Update to beta5

* kct 0.5.0-alpha06

* Try raising

* Use correct rename

* Update CI

* KSP 1.0.20

* RC1

* Migrate to kotlin-metadata

* RC2

* KSP RC2

* RC3

* KSP RC3

* 2.0.0 final

* KSP final + lint alpha
  • Loading branch information
ZacSweers authored May 22, 2024
1 parent 75a0764 commit 7bd35a8
Show file tree
Hide file tree
Showing 31 changed files with 316 additions and 263 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
name: CI

on: [ push, pull_request ]
on:
# Only run push on main
push:
branches:
- main
paths-ignore:
- '**/*.md'
# Always run on PRs
pull_request:
branches: [ main ]

concurrency:
group: 'ci-${{ github.event.merge_group.head_ref || github.head_ref }}-${{ github.workflow }}'
cancel-in-progress: true

jobs:
build:
name: 'JDK ${{ matrix.java }} - KSP ${{ matrix.ksp_enabled }} - Kotlin ${{ matrix.kotlin }} - K2 ${{ matrix.k2_enabled }}'
name: 'KSP ${{ matrix.ksp_enabled }} / K2 ${{ matrix.k2_enabled }}'
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '21' ]
kotlin: [ '1.9.24' ]
ksp_enabled: [ true, false ]
k2_enabled: [ true, false ]
fail-fast: false

env:
DEP_OVERRIDE_kotlin: ${{ matrix.kotlin }}
DEP_OVERRIDE_java: ${{ matrix.java }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -29,10 +36,10 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
java-version: '21'

- name: Build project
run: ./gradlew build check -Pmoshix.useKsp=${{ matrix.ksp_enabled }} -Pkotlin.experimental.tryK2=${{ matrix.k2_enabled }} --stacktrace
run: ./gradlew build check -Pmoshix.useKsp=${{ matrix.ksp_enabled }} -Pkotlin.experimental.tryK2=${{ matrix.k2_enabled }} --quiet

publish-snapshot:
needs: 'build'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ gen/
.gradle/
.gradletasknamecache
build/
.kotlin/

# Local configuration file (sdk path, etc)
local.properties
Expand Down
21 changes: 13 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import com.android.build.api.dsl.Lint
import com.google.devtools.ksp.gradle.KspTask
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import java.net.URI
import org.jetbrains.dokka.gradle.DokkaTask
Expand Down Expand Up @@ -85,15 +86,19 @@ subprojects {
project.tasks.withType<JavaCompile>().configureEach { options.release.set(jvmTargetProvider) }
}
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(libs.versions.jvmTarget.map(JvmTarget::fromTarget))
freeCompilerArgs.addAll("-Xjsr305=strict", "-progressive")
// TODO disabled because Gradle's Kotlin handling is silly
// https://github.com/gradle/gradle/issues/16779
// allWarningsAsErrors = true
tasks
.withType<KotlinCompile>()
.matching { it !is KspTask }
.configureEach {
compilerOptions {
jvmTarget.set(libs.versions.jvmTarget.map(JvmTarget::fromTarget))
freeCompilerArgs.addAll("-Xjsr305=strict")
progressiveMode.set(true)
// TODO disabled because Gradle's Kotlin handling is silly
// https://github.com/gradle/gradle/issues/16779
// allWarningsAsErrors = true
}
}
}
if (
project.name != "sample" && !project.path.contains("sample") && !project.path.contains("test")
) {
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ POM_DEVELOPER_NAME=Zac Sweers
SONATYPE_STAGING_PROFILE=dev.zacsweers
RELEASE_SIGNING_ENABLED=true

org.gradle.configureondemand=false
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.configuration-cache=true

kapt.include.compile.classpath=false

Expand Down
15 changes: 9 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ gjf = "1.17.0"
incap = "1.0.0"
jdk = "21"
jvmTarget = "11"
kotlin = "1.9.24"
kotlinCompileTesting = "0.4.1"
kotlin = "2.0.0"
kotlinCompileTesting = "0.5.0-alpha07"
kotlinpoet = "1.16.0"
ksp = "1.9.24-1.0.20"
ksp = "2.0.0-1.0.21"
ktfmt = "0.49"
moshi = "1.15.1"
okhttp = "4.12.0"
Expand All @@ -33,7 +33,7 @@ dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }
kotlinBinaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.14.0" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
lint = { id = "com.android.lint", version = "8.5.0-beta01" }
lint = { id = "com.android.lint", version = "8.6.0-alpha02" }
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.28.0" }
mavenShadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
moshix = { id = "dev.zacsweers.moshix", version = "0.26.0" } # Always replaced by the local plugin
Expand All @@ -56,7 +56,7 @@ incap = { module = "net.ltgt.gradle.incap:incap", version.ref = "incap" }
incap-processor = { module = "net.ltgt.gradle.incap:incap-processor", version.ref = "incap" }

kotlin-compilerEmbeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" }
kotlin-metadata = { module = "org.jetbrains.kotlinx:kotlinx-metadata-jvm", version = "0.9.0" }
kotlin-metadata = { module = "org.jetbrains.kotlin:kotlin-metadata-jvm", version.ref = "kotlin" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-gradlePlugin-api = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlin" }
Expand All @@ -68,8 +68,11 @@ kotlinpoet-metadata = { module = "com.squareup:kotlinpoet-metadata", version.ref
kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" }

ksp = { module = "com.google.devtools.ksp:symbol-processing", version.ref = "ksp" }
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
ksp-gradlePlugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
ksp-cli = { module = "com.google.devtools.ksp:symbol-processing-cmdline", version.ref = "ksp" }
ksp-aa-embeddable = { module = "com.google.devtools.ksp:symbol-processing-aa-embeddable", version.ref = "ksp" }
ksp-commonDeps = { module = "com.google.devtools.ksp:symbol-processing-common-deps", version.ref = "ksp" }

# Only present to trigger automatic renovate updates
ktfmt = { module = "com.facebook:ktfmt", version.ref = "ktfmt" }
Expand Down
Loading

0 comments on commit 7bd35a8

Please sign in to comment.