Skip to content

Commit 8255d8e

Browse files
authored
Swap from kapt to KSP and upgrade Gradle (#292)
* Swap from kapt to KSP * Upgrade gradle
1 parent 78eb7b9 commit 8255d8e

File tree

6 files changed

+72
-46
lines changed

6 files changed

+72
-46
lines changed

build.gradle.kts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
22

3-
apply(plugin = "kotlin")
4-
apply(plugin = "kotlin-kapt")
5-
63
java {
74
sourceCompatibility = JavaVersion.VERSION_17
85
targetCompatibility = JavaVersion.VERSION_17
@@ -14,7 +11,7 @@ kotlin {
1411

1512
plugins {
1613
kotlin("jvm") version "1.9.22"
17-
kotlin("kapt") version "1.9.22"
14+
id("com.google.devtools.ksp") version "1.9.22-1.0.16"
1815
application
1916
jacoco
2017
}
@@ -41,14 +38,15 @@ dependencies {
4138
// used for generating skeletons
4239
implementation("com.squareup:kotlinpoet:1.18.1")
4340

44-
// dependency injection library and annotation procressing
41+
// dependency injection library and annotation processing
4542
implementation("com.google.dagger:dagger:2.57.2")
46-
kapt("com.google.dagger:dagger-compiler:2.57.2")
47-
kaptTest("com.google.dagger:dagger-compiler:2.57.2")
43+
ksp("com.google.dagger:dagger-compiler:2.57.2")
44+
kspTest("com.google.dagger:dagger-compiler:2.57.2")
4845

4946
// test libraries
5047
testImplementation(kotlin("test"))
5148
testImplementation("org.junit.jupiter:junit-jupiter:5.10.3")
49+
testImplementation("org.junit.platform:junit-platform-launcher:1.10.3")
5250
}
5351

5452
tasks.test {
@@ -80,7 +78,7 @@ jacoco {
8078
sourceSets {
8179
test {
8280
java {
83-
setSrcDirs(listOf("build/generated/source/kapt/test"))
81+
setSrcDirs(listOf("build/generated/ksp/test/kotlin"))
8482
}
8583
}
8684
}

gradle.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
kotlin.code.style=official
2+
3+
# Gradle memory settings
4+
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError
5+
org.gradle.parallel=true
6+
org.gradle.caching=true
7+
8+
# Kotlin compiler settings
9+
kotlin.daemon.jvmargs=-Xmx4g
10+
kotlin.incremental=true

gradle/wrapper/gradle-wrapper.jar

-13.6 KB
Binary file not shown.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#Sat Nov 30 17:48:46 PST 2024
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/main/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +82,11 @@ do
8082
esac
8183
done
8284

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
85+
# This is normally unused
86+
# shellcheck disable=SC2034
8687
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
88+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
9090

9191
# Use the maximum available, or set MAX_FD != -1 to use that value.
9292
MAX_FD=maximum
@@ -114,7 +114,6 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118117

119118

120119
# Determine the Java command to use to start the JVM.
@@ -133,22 +132,29 @@ location of your Java installation."
133132
fi
134133
else
135134
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
135+
if ! command -v java >/dev/null 2>&1
136+
then
137+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137138
138139
Please set the JAVA_HOME variable in your environment to match the
139140
location of your Java installation."
141+
fi
140142
fi
141143

142144
# Increase the maximum file descriptors if we can.
143145
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144146
case $MAX_FD in #(
145147
max*)
148+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
149+
# shellcheck disable=SC2039,SC3045
146150
MAX_FD=$( ulimit -H -n ) ||
147151
warn "Could not query maximum file descriptor limit"
148152
esac
149153
case $MAX_FD in #(
150154
'' | soft) :;; #(
151155
*)
156+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
157+
# shellcheck disable=SC2039,SC3045
152158
ulimit -n "$MAX_FD" ||
153159
warn "Could not set maximum file descriptor limit to $MAX_FD"
154160
esac
@@ -165,7 +171,6 @@ fi
165171
# For Cygwin or MSYS, switch paths to Windows format before running java
166172
if "$cygwin" || "$msys" ; then
167173
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168-
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169174

170175
JAVACMD=$( cygpath --unix "$JAVACMD" )
171176

@@ -193,18 +198,27 @@ if "$cygwin" || "$msys" ; then
193198
done
194199
fi
195200

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
201210

202211
set -- \
203212
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204-
-classpath "$CLASSPATH" \
205-
org.gradle.wrapper.GradleWrapperMain \
213+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
206214
"$@"
207215

216+
# Stop when "xargs" is not available.
217+
if ! command -v xargs >/dev/null 2>&1
218+
then
219+
die "xargs is not available"
220+
fi
221+
208222
# Use "xargs" to parse quoted args.
209223
#
210224
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

17-
@if "%DEBUG%" == "" @echo off
19+
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
1921
@rem
2022
@rem Gradle startup script for Windows
@@ -25,7 +27,8 @@
2527
if "%OS%"=="Windows_NT" setlocal
2628

2729
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
30+
if "%DIRNAME%"=="" set DIRNAME=.
31+
@rem This is normally unused
2932
set APP_BASE_NAME=%~n0
3033
set APP_HOME=%DIRNAME%
3134

@@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4043

4144
set JAVA_EXE=java.exe
4245
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
46+
if %ERRORLEVEL% equ 0 goto execute
4447

45-
echo.
46-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47-
echo.
48-
echo Please set the JAVA_HOME variable in your environment to match the
49-
echo location of your Java installation.
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
5053

5154
goto fail
5255

@@ -56,32 +59,33 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5659

5760
if exist "%JAVA_EXE%" goto execute
5861

59-
echo.
60-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61-
echo.
62-
echo Please set the JAVA_HOME variable in your environment to match the
63-
echo location of your Java installation.
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
6467

6568
goto fail
6669

6770
:execute
6871
@rem Setup the command line
6972

70-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7173

7274

7375
@rem Execute Gradle
74-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7577

7678
:end
7779
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
80+
if %ERRORLEVEL% equ 0 goto mainEnd
7981

8082
:fail
8183
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8284
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
85+
set EXIT_CODE=%ERRORLEVEL%
86+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
87+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
88+
exit /b %EXIT_CODE%
8589

8690
:mainEnd
8791
if "%OS%"=="Windows_NT" endlocal

0 commit comments

Comments
 (0)