Skip to content

Commit 0493443

Browse files
authored
Merge pull request #429 from codecrafters-io/andy/kotlin
[CC-1966] Use Gradle for Kotlin
2 parents 7541732 + 2aea0a9 commit 0493443

File tree

37 files changed

+700
-318
lines changed

37 files changed

+700
-318
lines changed

compiled_starters/kotlin/.codecrafters/compile.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88

99
set -e # Exit on failure
1010

11-
mvn -B package -Ddir=/tmp/codecrafters-build-dir
11+
gradle build
12+
cd /tmp/codecrafters-build-redis-kotlin/distributions
13+
rm -rf app
14+
tar -xvf app.tar

compiled_starters/kotlin/.codecrafters/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88

99
set -e # Exit on failure
1010

11-
exec java -jar /tmp/codecrafters-build-dir/build-your-own-redis.jar "$@"
11+
exec /tmp/codecrafters-build-redis-kotlin/distributions/app/bin/app "$@"
Lines changed: 153 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,153 @@
1-
target/
2-
.idea/
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
.kotlin
4+
5+
# Ignore Gradle build output directory
6+
**/build
7+
8+
### Windows template
9+
# Windows thumbnail cache files
10+
Thumbs.db
11+
Thumbs.db:encryptable
12+
ehthumbs.db
13+
ehthumbs_vista.db
14+
15+
# Dump file
16+
*.stackdump
17+
18+
# Folder config file
19+
[Dd]esktop.ini
20+
21+
# Recycle Bin used on file shares
22+
$RECYCLE.BIN/
23+
24+
# Windows Installer files
25+
*.cab
26+
*.msi
27+
*.msix
28+
*.msm
29+
*.msp
30+
31+
# Windows shortcuts
32+
*.lnk
33+
34+
### macOS template
35+
# General
36+
.DS_Store
37+
.AppleDouble
38+
.LSOverride
39+
40+
# Icon must end with two \r
41+
Icon
42+
43+
# Thumbnails
44+
._*
45+
46+
# Files that might appear in the root of a volume
47+
.DocumentRevisions-V100
48+
.fseventsd
49+
.Spotlight-V100
50+
.TemporaryItems
51+
.Trashes
52+
.VolumeIcon.icns
53+
.com.apple.timemachine.donotpresent
54+
55+
# Directories potentially created on remote AFP share
56+
.AppleDB
57+
.AppleDesktop
58+
Network Trash Folder
59+
Temporary Items
60+
.apdisk
61+
62+
### Linux template
63+
*~
64+
65+
# temporary files which can be created if a process still has a handle open of a deleted file
66+
.fuse_hidden*
67+
68+
# KDE directory preferences
69+
.directory
70+
71+
# Linux trash folder which might appear on any partition or disk
72+
.Trash-*
73+
74+
# .nfs files are created when an open file is removed but is still being accessed
75+
.nfs*
76+
77+
### JetBrains template
78+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
79+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
80+
81+
*.iml
82+
*.ipr
83+
*.iws
84+
/.idea/*
85+
86+
# Exclude non-user-specific stuff
87+
!.idea/.name
88+
!.idea/codeInsightSettings.xml
89+
!.idea/codeStyles/
90+
!.idea/copyright/
91+
!.idea/dataSources.xml
92+
!.idea/detekt.xml
93+
!.idea/encodings.xml
94+
!.idea/externalDependencies.xml
95+
!.idea/file.template.settings.xml
96+
!.idea/fileTemplates/
97+
!.idea/icon.svg
98+
!.idea/inspectionProfiles/
99+
!.idea/runConfigurations/
100+
!.idea/scopes/
101+
!.idea/vcs.xml
102+
103+
### Kotlin template
104+
# Compiled class file
105+
*.class
106+
107+
# Log file
108+
*.log
109+
110+
# Package Files #
111+
*.jar
112+
*.war
113+
*.nar
114+
*.ear
115+
*.zip
116+
*.tar.gz
117+
*.rar
118+
119+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
120+
hs_err_pid*
121+
122+
### Gradle template
123+
.gradle
124+
125+
# Note that you may need to exclude by hand other folders
126+
# named build if necessary (e.g., in src/)
127+
**/build/
128+
129+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
130+
!gradle/wrapper/gradle-wrapper.jar
131+
132+
# Cache of project
133+
.gradletasknamecache
134+
.gitignore-android
135+
### Android-specific stuff
136+
# Built application files
137+
*.apk
138+
*.ap_
139+
*.aab
140+
*.apks
141+
142+
# Files for the Dalvik VM
143+
*.dex
144+
145+
# Generated files
146+
bin/
147+
gen/
148+
149+
# Local configuration file (sdk path, etc)
150+
local.properties
151+
152+
# Google/Firebase secrets
153+
google-services.json

compiled_starters/kotlin/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ event loops, the Redis protocol and more.
1212

1313
# Passing the first stage
1414

15-
The entry point for your Redis implementation is in `src/main/kotlin/Main.kt`.
16-
Study and uncomment the relevant code, and push your changes to pass the first
17-
stage:
15+
The entry point for your Redis implementation is in
16+
`app/src/main/kotlin/App.kt`. Study and uncomment the relevant code, and push
17+
your changes to pass the first stage:
1818

1919
```sh
2020
git commit -am "pass 1st stage" # any msg
@@ -27,8 +27,8 @@ That's all!
2727

2828
Note: This section is for stages 2 and beyond.
2929

30-
1. Ensure you have `kotlin (>=2.0)` installed locally
30+
1. Ensure you have `gradle (9.1.0)` installed locally
3131
1. Run `./your_program.sh` to run your Redis server, which is implemented in
32-
`src/main/kotlin/Main.kt`.
32+
`app/src/main/kotlin/App.kt`.
3333
1. Commit your changes and run `git push origin master` to submit your solution
3434
to CodeCrafters. Test output will be streamed to your terminal.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file was generated by the Gradle 'init' task.
3+
*
4+
* This generated file contains a sample Kotlin application project to get you started.
5+
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/9.1.0/userguide/building_java_projects.html in the Gradle documentation.
6+
*/
7+
8+
layout.buildDirectory.set(file("/tmp/codecrafters-build-redis-kotlin"))
9+
10+
plugins {
11+
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
12+
alias(libs.plugins.kotlin.jvm)
13+
14+
// Apply the application plugin to add support for building a CLI application in Java.
15+
application
16+
}
17+
18+
repositories {
19+
// Use Maven Central for resolving dependencies.
20+
mavenCentral()
21+
}
22+
23+
dependencies {
24+
}
25+
26+
// Apply a specific Java toolchain to ease working on different environments.
27+
java {
28+
toolchain {
29+
languageVersion = JavaLanguageVersion.of(24)
30+
}
31+
}
32+
33+
application {
34+
// Define the main class for the application.
35+
mainClass.set("AppKt")
36+
}

compiled_starters/kotlin/codecrafters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ debug: false
77
# Use this to change the Kotlin version used to run your code
88
# on Codecrafters.
99
#
10-
# Available versions: kotlin-2.0
11-
buildpack: kotlin-2.0
10+
# Available versions: kotlin-2.2
11+
buildpack: kotlin-2.2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
3+
4+
org.gradle.caching=true
5+
org.gradle.configuration-cache=true
6+
org.gradle.daemon=false
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
3+
4+
[plugins]
5+
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "2.2.0" }

compiled_starters/kotlin/pom.xml

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)