Skip to content

Commit

Permalink
Bump Kotlin, Gradle version; various improvements to build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
daugeldauge committed Dec 5, 2023
1 parent 46f1aa6 commit 9bf124a
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 42 deletions.
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ group=com.daugeldauge.kinzhal
version=0.0.5

kotlin.code.style=official
kotlin.mpp.stability.nowarn=true

org.gradle.configuration-cache=true
org.gradle.caching=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
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
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
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
16 changes: 12 additions & 4 deletions kinzhal-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ repositories {

kotlin {
jvm()
ios()
linuxX64()

iosX64()
iosArm64()
iosSimulatorArm64()

macosArm64()
macosX64()
watchos()

watchosArm64()
watchosX64()
watchosArm32()
watchosSimulatorArm64()
tvos()

tvosArm64()
tvosX64()
tvosSimulatorArm64()
linuxX64()
}
22 changes: 9 additions & 13 deletions kinzhal-processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ repositories {
}

kotlin {
sourceSets {
jvm()
jvm()

getByName("jvmMain") {
dependencies {
implementation(projects.kinzhalAnnotations)
implementation(libs.ksp.symbolProcessingApi)
implementation(libs.kotlinpoet)
}
sourceSets {
jvmMain.dependencies {
implementation(projects.kinzhalAnnotations)
implementation(libs.ksp.symbolProcessingApi)
implementation(libs.kotlinpoet)
}

getByName("jvmTest") {
dependencies {
implementation(kotlin("test"))
implementation(libs.compileTestingKsp)
}
jvmTest.dependencies {
implementation(kotlin("test"))
implementation(libs.compileTestingKsp)
}
}
}
Expand Down
36 changes: 21 additions & 15 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@Suppress("DSL_SCOPE_VIOLATION") // https://youtrack.jetbrains.com/issue/KTIJ-19369
import org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon

plugins {
alias(libs.plugins.ksp)
kotlin("multiplatform")
Expand All @@ -11,27 +12,23 @@ repositories {
mavenCentral()
}

dependencies {
ksp(kinzhalDependency(projects.kinzhalProcessor))
}

kotlin {
sourceSets {
jvm()
ios()
iosX64()
iosArm64()
iosSimulatorArm64()
macosX64()

getByName("commonMain") {
commonMain {
dependencies {
implementation(kinzhalDependency(projects.kinzhalAnnotations))
}

if (System.getProperty("idea.sync.active") != null) {
kotlin.srcDir("$buildDir/generated/ksp/jvm/jvmMain/kotlin") // only needed for IDE to see generated code // TODO figure out how to avoid this
}
kotlin.srcDir(layout.buildDirectory.dir("generated/ksp/metadata/commonMain/kotlin")) // only needed for IDE to see generated code // TODO figure out how to avoid this
}

getByName("commonTest") {
commonTest {
dependencies {
implementation(kotlin("test"))
}
Expand All @@ -40,14 +37,23 @@ kotlin {
}
}

dependencies {
kspCommonMainMetadata(kinzhalDependency(projects.kinzhalProcessor))
}

tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
if (this !is KotlinCompileCommon) {
dependsOn("kspCommonMainKotlinMetadata")
}

kotlinOptions.allWarningsAsErrors = true
}


fun kinzhalDependency(project: ProjectDependency): Any {
return if (!hasProperty("useSnapshotForSample")) {
project
} else {
"${project.group}:${project.name}:$version-SNAPSHOT"
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.allWarningsAsErrors = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.daugeldauge.kinzhal.sample.graph

import com.daugeldauge.kinzhal.annotations.Component
import com.daugeldauge.kinzhal.sample.graph.network.DeezerApi
import com.daugeldauge.kinzhal.sample.graph.network.HttpClient
import com.daugeldauge.kinzhal.sample.graph.network.HttpClientScope
import com.daugeldauge.kinzhal.sample.graph.network.NetworkModule

Expand Down
5 changes: 2 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ pluginManagement {
}

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
versionCatalogs {
create("libs") {
val kotlinVersion = "1.8.0"
val kotlinVersion = "1.9.21"
version("kotlin", kotlinVersion)

val kspVersion = "$kotlinVersion-1.0.9"
val kspVersion = "$kotlinVersion-1.0.15"

library("kotlinpoet", "com.squareup:kotlinpoet:1.9.0")
library("compileTestingKsp", "com.github.tschuchortdev:kotlin-compile-testing-ksp:1.4.4")
Expand Down

0 comments on commit 9bf124a

Please sign in to comment.