Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scala to language template #14

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
11 changes: 11 additions & 0 deletions languages/scala/code/.codecrafters/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
#
# This script is used to compile your program on CodeCrafters
#
# This runs before .codecrafters/run.sh
#
# Learn more: https://codecrafters.io/program-interface

set -e # Exit on failure

sbt assembly
11 changes: 11 additions & 0 deletions languages/scala/code/.codecrafters/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
#
# This script is used to run your program on CodeCrafters
#
# This runs after .codecrafters/compile.sh
#
# Learn more: https://codecrafters.io/program-interface

set -e # Exit on failure

exec java -jar ./target/scala-3.3.5/{{course_slug}}.jar "$@"
7 changes: 7 additions & 0 deletions languages/scala/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/target
/.bloop/
/.bsp/
/.metals/
/project/.bloop/
metals.sbt
metals/project/
16 changes: 16 additions & 0 deletions languages/scala/code/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Dependencies._

ThisBuild / scalaVersion := "3.3.5"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.CodeCrafters"
ThisBuild / organizationName := "CodeCrafters"

assembly / assemblyJarName := "{{course_slug}}"

lazy val root = (project in file("."))
.settings(
name := "codecrafter-{{course_slug}}",
// List your dependencies here
libraryDependencies ++= Seq(
),
)
1 change: 1 addition & 0 deletions languages/scala/code/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.10.7
3 changes: 3 additions & 0 deletions languages/scala/code/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")
6 changes: 6 additions & 0 deletions languages/scala/code/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Main extends App {
// You can use print statements as follows for debugging, they'll be visible when running tests.
System.err.println("Logs from your program will appear here!")
// Uncomment this block to pass the first stage
// println("TODO: Implement starter code")
}
3 changes: 3 additions & 0 deletions languages/scala/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
attributes:
required_executable: sbt (1.10.7)
user_editable_file: src/main/scala/Main.scala
13 changes: 13 additions & 0 deletions languages/scala/dockerfiles/scala-3.3.5.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# syntax=docker/dockerfile:1.7-labs
FROM maven:3.9.9-eclipse-temurin-17-alpine

# Ensures the container is re-built if dependency files change
ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.sbt"

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

Comment on lines +15 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical issue with COPY command flags.
The COPY command on line 44 uses unsupported --exclude flags. Docker does not support these flags in the COPY command. Instead, manage exclusions by using a .dockerignore file (e.g., include .git and README.md there) and update the command as follows:

- COPY --exclude=.git --exclude=README.md . /app
+ COPY . /app
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY --exclude=.git --exclude=README.md . /app
# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
COPY . /app
🧰 Tools
🪛 Hadolint (2.12.0)

[error] 44-44: invalid flag: --exclude

(DL1000)

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