Skip to content

Commit

Permalink
Dependency updates
Browse files Browse the repository at this point in the history
- Update Gradle to 8.4
- Update Kotlin to 2.0.0-Beta1
- Switch to multiple compilations instead of targets for generation source
  - publish Gradle Module metadata
- Update ksp to 2.0.0-Beta1-1.0.14
- Update mockk to 1.13.8
- Update Dokka to 1.9.10
- Update kotlinpoet to 1.15.0
  - Switch TypeSpec builders to TypeSpecHolder.Builder
  • Loading branch information
DRSchlaubi committed Nov 18, 2023
1 parent 46fc633 commit 225d359
Show file tree
Hide file tree
Showing 80 changed files with 354 additions and 721 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions buildSrc/src/main/kotlin/JVMTarget.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import gradle.kotlin.dsl.accessors._8d1ef46afdac024fc616c6e49cc7c389.java
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.kotlin.dsl.the
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
Expand All @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget

fun Project.configureJVMTarget() {
plugins.withId("org.gradle.java") {
java {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
}
}
Expand All @@ -22,12 +22,10 @@ fun Project.configureJVMTarget() {
}

plugins.withId("org.jetbrains.kotlin.multiplatform") {
the<KotlinMultiplatformExtension>().targets {
withType<KotlinJvmTarget>().configureEach {
compilations.all {
compilerOptions.configure {
jvmTarget = JvmTarget.JVM_1_8
}
the<KotlinMultiplatformExtension>().targets.withType<KotlinJvmTarget> {
compilations.all {
compilerOptions.configure {
jvmTarget = JvmTarget.JVM_1_8
}
}
}
Expand Down
60 changes: 20 additions & 40 deletions buildSrc/src/main/kotlin/code-generator.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,77 +1,57 @@
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")

import com.google.devtools.ksp.gradle.KspTask
import dev.kord.codegen.gradle.CodeGenerationExtension
import dev.kord.codegen.gradle.DownloadSourceTask
import java.lang.Boolean as JBoolean

plugins {
org.jetbrains.kotlin.multiplatform
org.jetbrains.kotlin.jvm
com.google.devtools.ksp
}

val codeGenerationExtension = extensions.create("codeGeneration", CodeGenerationExtension::class)
val generationSourceAttribute = Attribute.of("generationSource", JBoolean::class.java)
val downloadSources by tasks.creating(DownloadSourceTask::class) {
dependency = codeGenerationExtension.dependency
}

kotlin {
explicitApi()
jvm()

targets {
jvm {
attributes {
attribute(generationSourceAttribute, false as java.lang.Boolean)
}
}
jvm("generationSource") {
attributes {
attribute(generationSourceAttribute, true as java.lang.Boolean)
}

compilations.all {
compilerOptions.configure {
freeCompilerArgs.add("-Xjvm-default=all")
// TODO: Suppress warnings once KT-8087 hits
}
target.compilations {
create("generationSource") {
compilerOptions.configure {
freeCompilerArgs.add("-Xjvm-default=all")
// TODO: Suppress warnings once KT-8087 hits
}
}
}

sourceSets {
all {
main {
languageSettings.optIn("dev.kord.codegen.kotlinpoet.CodeGenInternal")
kotlin.srcDir("build/generated/ksp/generationSource/kotlin")
}

commonMain {
kotlin.srcDir("build/generated/ksp/generationSource/generationSourceMain/kotlin")
}

named("generationSourceMain") {
kotlin.srcDir(downloadSources.destinationDirectory.map { it.dir("main") })
named("generationSource") {
kotlin.srcDir(downloadSources.destinationDirectory.map { it.dir("commonMain") })
}
}
}

tasks {
named("compileKotlinGenerationSource") {
dependsOn(downloadSources)
}

afterEvaluate {
val ksp = named("kspKotlinGenerationSource") {
val kspGenerationSourceKotlin by getting(KspTask::class) {
dependsOn(downloadSources)
// We don't need to reify twice, actual reification occurs in main source
commandLineArgumentProviders.add(CommandLineArgumentProvider{ listOf("disable-reification=true") })
}

listOf("compileKotlinJvm", "jvmSourcesJar").forEach {
named(it) {
dependsOn(ksp)
}
compileKotlin {
dependsOn(kspGenerationSourceKotlin)
}
named("kspKotlin") {
dependsOn(kspGenerationSourceKotlin)
}
}
}


ksp {
arg { listOf("package-name=${codeGenerationExtension.packageName.get()}") }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class DownloadSourceTask : DefaultTask() {
}

val artifacts = project.dependencies.createArtifactResolutionQuery()
.forModule(dependency.group as String, dependency.name, dependency.version as String)
.forModule(dependency.group!!, dependency.name, dependency.version as String)
.withArtifacts(JvmLibrary::class.java, SourcesArtifact::class.java)
.execute()

Expand Down
42 changes: 2 additions & 40 deletions buildSrc/src/main/kotlin/kord-publishing.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.KotlinMultiplatform
import gradle.kotlin.dsl.accessors._8d1ef46afdac024fc616c6e49cc7c389.kotlin
import org.intellij.lang.annotations.Language
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget

Expand Down Expand Up @@ -58,46 +58,8 @@ mavenPublishing {
plugins.withId("org.jetbrains.kotlin.jvm") {
configure(KotlinJvm(JavadocJar.Dokka("dokkaHtml")))
}
}

afterEvaluate {
plugins.withId("org.jetbrains.kotlin.multiplatform") {
if (kotlin.targets.any { it !is KotlinJvmTarget && it !is KotlinMetadataTarget }) {
mavenPublishing.configure(KotlinMultiplatform(JavadocJar.Dokka("dokkaHtml")))
return@withId
}
val dokkaJar by tasks.registering(Jar::class) {
from(tasks.named("dokkaHtml"))
archiveClassifier = "javadoc"
}


// We're kinda abusing the KMP target system here
// We make an extra jvm target for the kotlinpoet source to run ksp on it, however we don't want to publish
// that target, so we emulate the "jvm" target being a normal Kotlin/JVM project and publish it that way
afterEvaluate {
publishing.publications.create<MavenPublication>("maven") {
from(kotlin.targets.getByName("jvm").components.first())
artifact(dokkaJar)
}
}

// Remove auto-generated KMP publications
tasks {
withType<PublishToMavenLocal> {
enabled = name == "publishMavenPublicationToMavenLocal"
}

withType<PublishToMavenRepository> {
enabled = name == "publishMavenPublicationToMavenRepository"
|| name == "publishMavenPublicationToMavenCentralRepository"
}

// Theoretically, this makes us loose information, however, that information is not relevant, since this is
// pretty much only a JVM lib targeting JVM 1.8 (so validation of that is unnecessary)
withType<GenerateModuleMetadata> {
enabled = false
}
}
configure(KotlinMultiplatform(JavadocJar.Dokka("dokkaHtml")))
}
}
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[versions]
kotlin = "1.9.10"
kotlinpoet = "1.14.2"
ksp = "1.9.10-1.0.13"
kotlin = "2.0.0-Beta1"
kotlinpoet = "1.15.0"
ksp = "2.0.0-Beta1-1.0.14"

# The compiled binary of codegen.kt we use to compile codegen.kt itself
codegen-kt = "main-SNAPSHOT"

[libraries]
ksp-api = { group = "com.google.devtools.ksp", name = "symbol-processing-api", version.ref = "ksp" }
kotlinpoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinpoet" }
kotlinpoet = { group = "com.squareup", name = "kotlinpoet-jvm", version.ref = "kotlinpoet" }
kotlinpoet-ksp = { group = "com.squareup", name = "kotlinpoet-ksp", version.ref = "kotlinpoet" }

codegen-kotlinpoet = { group = "dev.kord.codegen", name = "kotlinpoet", version = "main-20230912.212936-5" }
codegen-ksp = { group = "dev.kord.codegen", name = "ksp", version = "main-20230912.211940-5" }
codegen-ksp-processor = { group = "dev.kord.codegen", name = "ksp-processor", version = "main-20230912.211940-7" }

mockk = { group = "io.mockk", name = "mockk", version = "1.13.7" }
mockk = { group = "io.mockk", name = "mockk", version = "1.13.8" }

kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
ksp-plugin = { group = "com.google.devtools.ksp", name = "symbol-processing-gradle-plugin", version.ref = "ksp" }
dokka-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version = "1.9.0" }
dokka-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version = "1.9.10" }
maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.3" }

binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version = "0.13.2" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions kotlinpoet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ plugins {
}

dependencies {
commonMainApi(libs.kotlinpoet)
commonMainImplementation(kotlin("reflect"))
commonMainCompileOnly(projects.kotlinpoet.internalAnnotations)
kspCommonMainMetadata(projects.kotlinpoet.processor)
api(libs.kotlinpoet)
implementation(kotlin("reflect"))
compileOnly(projects.kotlinpoet.internalAnnotations)
ksp(projects.kotlinpoet.processor)

commonTestImplementation(kotlin("test-junit5"))
testImplementation(kotlin("test-junit5"))
}

kotlin {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 225d359

Please sign in to comment.