Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ concurrency:
jobs:
test_course_definition:
uses: codecrafters-io/course-sdk/.github/workflows/test-course-definition.yml@main
with:
sdkRef: main
permissions:
contents: read
checks: write
pull-requests: write
secrets: inherit
5 changes: 4 additions & 1 deletion compiled_starters/kotlin/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@

set -e # Exit on failure

mvn -B package -Ddir=/tmp/codecrafters-build-dir
gradle distTar
cd /tmp/codecrafters-build-sqlite-kotlin/distributions
rm -rf app
tar -xvf app.tar
2 changes: 1 addition & 1 deletion compiled_starters/kotlin/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec java -jar /tmp/codecrafters-build-dir/build-your-own-sqlite.jar "$@"
exec /tmp/codecrafters-build-sqlite-kotlin/distributions/app/bin/app "$@"
155 changes: 153 additions & 2 deletions compiled_starters/kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,156 @@
# Database files used for testing
*.db

target/
.idea/
# Ignore Gradle project-specific cache directory
.gradle
.kotlin

# Ignore Gradle build output directory
**/build

### Windows template
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Linux template
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

*.iml
*.ipr
*.iws
/.idea/*

# Exclude non-user-specific stuff
!.idea/.name
!.idea/codeInsightSettings.xml
!.idea/codeStyles/
!.idea/copyright/
!.idea/dataSources.xml
!.idea/detekt.xml
!.idea/encodings.xml
!.idea/externalDependencies.xml
!.idea/file.template.settings.xml
!.idea/fileTemplates/
!.idea/icon.svg
!.idea/inspectionProfiles/
!.idea/runConfigurations/
!.idea/scopes/
!.idea/vcs.xml

### Kotlin template
# Compiled class file
*.class

# Log file
*.log

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Gradle template
.gradle

# Note that you may need to exclude by hand other folders
# named build if necessary (e.g., in src/)
**/build/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle/wrapper/gradle-wrapper.jar

# Cache of project
.gradletasknamecache
.gitignore-android
### Android-specific stuff
# Built application files
*.apk
*.ap_
*.aab
*.apks

# Files for the Dalvik VM
*.dex

# Generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Google/Firebase secrets
google-services.json
10 changes: 5 additions & 5 deletions compiled_starters/kotlin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ and more.

# Passing the first stage

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

```sh
git commit -am "pass 1st stage" # any msg
Expand All @@ -30,9 +30,9 @@ Time to move on to the next stage!

Note: This section is for stages 2 and beyond.

1. Ensure you have `kotlin (>=2.0)` installed locally
1. Ensure you have `gradle (9.1.0)` installed locally
1. Run `./your_program.sh` to run your program, which is implemented in
`src/main/kotlin/Main.kt`.
`app/src/main/kotlin/App.kt`.
1. Commit your changes and run `git push origin master` to submit your solution
to CodeCrafters. Test output will be streamed to your terminal.

Expand Down
36 changes: 36 additions & 0 deletions compiled_starters/kotlin/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Kotlin application project to get you started.
* 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.
*/

layout.buildDirectory.set(file("/tmp/codecrafters-build-sqlite-kotlin"))

plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
alias(libs.plugins.kotlin.jvm)

// Apply the application plugin to add support for building a CLI application in Java.
application
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(24)
}
}

application {
// Define the main class for the application.
mainClass.set("AppKt")
}
4 changes: 2 additions & 2 deletions compiled_starters/kotlin/codecrafters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ debug: false
# Use this to change the Kotlin version used to run your code
# on Codecrafters.
#
# Available versions: kotlin-2.0
buildpack: kotlin-2.0
# Available versions: kotlin-2.2
buildpack: kotlin-2.2
6 changes: 6 additions & 0 deletions compiled_starters/kotlin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.daemon=false
5 changes: 5 additions & 0 deletions compiled_starters/kotlin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "2.2.0" }
14 changes: 14 additions & 0 deletions compiled_starters/kotlin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/9.1.0/userguide/multi_project_builds.html in the Gradle documentation.
*/

plugins {
// Apply the foojay-resolver plugin to allow automatic download of JDKs
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}

rootProject.name = "codecrafters-sqlite"
include("app")
7 changes: 5 additions & 2 deletions compiled_starters/kotlin/your_program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ set -e # Exit early if any commands fail
# - Edit .codecrafters/compile.sh to change how your program compiles remotely
(
cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
mvn -B package -Ddir=/tmp/codecrafters-build-dir
gradle distTar
cd /tmp/codecrafters-build-sqlite-kotlin/distributions
rm -rf app
tar -xvf app.tar
)

# Copied from .codecrafters/run.sh
#
# - Edit this to change how your program runs locally
# - Edit .codecrafters/run.sh to change how your program runs remotely
exec java -jar /tmp/codecrafters-build-dir/build-your-own-sqlite.jar "$@"
exec /tmp/codecrafters-build-sqlite-kotlin/distributions/app/bin/app "$@"
16 changes: 16 additions & 0 deletions dockerfiles/kotlin-2.2.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# syntax=docker/dockerfile:1.7-labs
FROM gradle:jdk24-alpine

# Ensures the container is re-built if pom.xml changes
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="settings.gradle.kts,app/build.gradle.kts,gradle/libs.versions.toml"

WORKDIR /app

# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app

# Install language-specific dependencies
RUN .codecrafters/compile.sh

RUN mkdir -p /app-cached
RUN if [ -d "/app/.gradle" ]; then mv /app/.gradle /app-cached; fi
5 changes: 4 additions & 1 deletion solutions/kotlin/01-dr6/code/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@

set -e # Exit on failure

mvn -B package -Ddir=/tmp/codecrafters-build-dir
gradle distTar
cd /tmp/codecrafters-build-sqlite-kotlin/distributions
rm -rf app
tar -xvf app.tar
2 changes: 1 addition & 1 deletion solutions/kotlin/01-dr6/code/.codecrafters/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

set -e # Exit on failure

exec java -jar /tmp/codecrafters-build-dir/build-your-own-sqlite.jar "$@"
exec /tmp/codecrafters-build-sqlite-kotlin/distributions/app/bin/app "$@"
Loading
Loading