From 3c30fc3e25547c00b464ae0074fe70d3c931a197 Mon Sep 17 00:00:00 2001
From: Andy Li <1450947+andy1li@users.noreply.github.com>
Date: Tue, 1 Oct 2024 08:36:17 +0800
Subject: [PATCH 1/2] Add Java support
---
.../java/.codecrafters/compile.sh | 11 ++++
compiled_starters/java/.codecrafters/run.sh | 11 ++++
compiled_starters/java/.gitattributes | 1 +
compiled_starters/java/.gitignore | 3 ++
compiled_starters/java/README.md | 39 ++++++++++++++
compiled_starters/java/codecrafters.yml | 11 ++++
compiled_starters/java/pom.xml | 52 +++++++++++++++++++
.../java/src/main/java/Main.java | 34 ++++++++++++
compiled_starters/java/your_program.sh | 24 +++++++++
course-definition.yml | 3 ++
dockerfiles/java-23.Dockerfile | 13 +++++
.../java/01-cq2/code/.codecrafters/compile.sh | 11 ++++
.../java/01-cq2/code/.codecrafters/run.sh | 11 ++++
solutions/java/01-cq2/code/.gitattributes | 1 +
solutions/java/01-cq2/code/.gitignore | 3 ++
solutions/java/01-cq2/code/README.md | 39 ++++++++++++++
solutions/java/01-cq2/code/codecrafters.yml | 11 ++++
solutions/java/01-cq2/code/pom.xml | 52 +++++++++++++++++++
.../java/01-cq2/code/src/main/java/Main.java | 29 +++++++++++
solutions/java/01-cq2/code/your_program.sh | 24 +++++++++
.../01-cq2/diff/src/main/java/Main.java.diff | 40 ++++++++++++++
solutions/java/01-cq2/explanation.md | 21 ++++++++
.../java/code/.codecrafters/compile.sh | 11 ++++
.../java/code/.codecrafters/run.sh | 11 ++++
starter_templates/java/code/.gitignore | 3 ++
starter_templates/java/code/pom.xml | 52 +++++++++++++++++++
.../java/code/src/main/java/Main.java | 34 ++++++++++++
starter_templates/java/config.yml | 3 ++
28 files changed, 558 insertions(+)
create mode 100755 compiled_starters/java/.codecrafters/compile.sh
create mode 100755 compiled_starters/java/.codecrafters/run.sh
create mode 100644 compiled_starters/java/.gitattributes
create mode 100644 compiled_starters/java/.gitignore
create mode 100644 compiled_starters/java/README.md
create mode 100644 compiled_starters/java/codecrafters.yml
create mode 100644 compiled_starters/java/pom.xml
create mode 100644 compiled_starters/java/src/main/java/Main.java
create mode 100755 compiled_starters/java/your_program.sh
create mode 100644 dockerfiles/java-23.Dockerfile
create mode 100755 solutions/java/01-cq2/code/.codecrafters/compile.sh
create mode 100755 solutions/java/01-cq2/code/.codecrafters/run.sh
create mode 100644 solutions/java/01-cq2/code/.gitattributes
create mode 100644 solutions/java/01-cq2/code/.gitignore
create mode 100644 solutions/java/01-cq2/code/README.md
create mode 100644 solutions/java/01-cq2/code/codecrafters.yml
create mode 100644 solutions/java/01-cq2/code/pom.xml
create mode 100644 solutions/java/01-cq2/code/src/main/java/Main.java
create mode 100755 solutions/java/01-cq2/code/your_program.sh
create mode 100644 solutions/java/01-cq2/diff/src/main/java/Main.java.diff
create mode 100644 solutions/java/01-cq2/explanation.md
create mode 100755 starter_templates/java/code/.codecrafters/compile.sh
create mode 100755 starter_templates/java/code/.codecrafters/run.sh
create mode 100644 starter_templates/java/code/.gitignore
create mode 100644 starter_templates/java/code/pom.xml
create mode 100644 starter_templates/java/code/src/main/java/Main.java
create mode 100644 starter_templates/java/config.yml
diff --git a/compiled_starters/java/.codecrafters/compile.sh b/compiled_starters/java/.codecrafters/compile.sh
new file mode 100755
index 0000000..c3347c5
--- /dev/null
+++ b/compiled_starters/java/.codecrafters/compile.sh
@@ -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
+
+mvn -B package -Ddir=/tmp/codecrafters-build-grep-java
diff --git a/compiled_starters/java/.codecrafters/run.sh b/compiled_starters/java/.codecrafters/run.sh
new file mode 100755
index 0000000..33828d9
--- /dev/null
+++ b/compiled_starters/java/.codecrafters/run.sh
@@ -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 /tmp/codecrafters-build-grep-java/java_grep.jar "$@"
diff --git a/compiled_starters/java/.gitattributes b/compiled_starters/java/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/compiled_starters/java/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/compiled_starters/java/.gitignore b/compiled_starters/java/.gitignore
new file mode 100644
index 0000000..a48b18a
--- /dev/null
+++ b/compiled_starters/java/.gitignore
@@ -0,0 +1,3 @@
+*.jar
+target/
+.idea/
diff --git a/compiled_starters/java/README.md b/compiled_starters/java/README.md
new file mode 100644
index 0000000..1dd5a76
--- /dev/null
+++ b/compiled_starters/java/README.md
@@ -0,0 +1,39 @@
+![progress-banner](https://codecrafters.io/landing/images/default_progress_banners/grep.png)
+
+This is a starting point for Java solutions to the
+["Build Your Own grep" Challenge](https://app.codecrafters.io/courses/grep/overview).
+
+[Regular expressions](https://en.wikipedia.org/wiki/Regular_expression)
+(Regexes, for short) are patterns used to match character combinations in
+strings. [`grep`](https://en.wikipedia.org/wiki/Grep) is a CLI tool for
+searching using Regexes.
+
+In this challenge you'll build your own implementation of `grep`. Along the way
+we'll learn about Regex syntax, how parsers/lexers work, and how regular
+expressions are evaluated.
+
+**Note**: If you're viewing this repo on GitHub, head over to
+[codecrafters.io](https://codecrafters.io) to try the challenge.
+
+# Passing the first stage
+
+The entry point for your `grep` implementation is in `src/main/java/Main.java`.
+Study and uncomment the relevant code, and push your changes to pass the first
+stage:
+
+```sh
+git commit -am "pass 1st stage" # any msg
+git push origin master
+```
+
+Time to move on to the next stage!
+
+# Stage 2 & beyond
+
+Note: This section is for stages 2 and beyond.
+
+1. Ensure you have `mvn` installed locally
+1. Run `./your_program.sh` to run your program, which is implemented in
+ `src/main/java/Main.java`.
+1. Commit your changes and run `git push origin master` to submit your solution
+ to CodeCrafters. Test output will be streamed to your terminal.
diff --git a/compiled_starters/java/codecrafters.yml b/compiled_starters/java/codecrafters.yml
new file mode 100644
index 0000000..2406954
--- /dev/null
+++ b/compiled_starters/java/codecrafters.yml
@@ -0,0 +1,11 @@
+# Set this to true if you want debug logs.
+#
+# These can be VERY verbose, so we suggest turning them off
+# unless you really need them.
+debug: false
+
+# Use this to change the Java version used to run your code
+# on Codecrafters.
+#
+# Available versions: java-23
+language_pack: java-23
diff --git a/compiled_starters/java/pom.xml b/compiled_starters/java/pom.xml
new file mode 100644
index 0000000..f527f97
--- /dev/null
+++ b/compiled_starters/java/pom.xml
@@ -0,0 +1,52 @@
+
+
+ 4.0.0
+
+ io.codecrafters
+ build-your-own-grep
+ 1.0
+
+
+ 23
+ 23
+ UTF-8
+ 23
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+ java_grep
+
+ jar-with-dependencies
+
+ false
+
+
+ true
+
+ Main
+
+
+ ${dir}
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/compiled_starters/java/src/main/java/Main.java b/compiled_starters/java/src/main/java/Main.java
new file mode 100644
index 0000000..5c7b7c5
--- /dev/null
+++ b/compiled_starters/java/src/main/java/Main.java
@@ -0,0 +1,34 @@
+import java.io.IOException;
+import java.util.Scanner;
+
+public class Main {
+ public static void main(String[] args){
+ if (args.length != 2 || !args[0].equals("-E")) {
+ System.out.println("Usage: ./your_program.sh -E ");
+ System.exit(1);
+ }
+
+ String pattern = args[1];
+ Scanner scanner = new Scanner(System.in);
+ String inputLine = scanner.nextLine();
+
+ // 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
+ //
+ // if (matchPattern(inputLine, pattern)) {
+ // System.exit(0);
+ // } else {
+ // System.exit(1);
+ // }
+ }
+
+ public static boolean matchPattern(String inputLine, String pattern) {
+ if (pattern.length() == 1) {
+ return inputLine.contains(pattern);
+ } else {
+ throw new RuntimeException("Unhandled pattern: " + pattern);
+ }
+ }
+}
diff --git a/compiled_starters/java/your_program.sh b/compiled_starters/java/your_program.sh
new file mode 100755
index 0000000..e0e0783
--- /dev/null
+++ b/compiled_starters/java/your_program.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Use this script to run your program LOCALLY.
+#
+# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
+#
+# Learn more: https://codecrafters.io/program-interface
+
+set -e # Exit early if any commands fail
+
+# Copied from .codecrafters/compile.sh
+#
+# - Edit this to change how your program compiles locally
+# - 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-grep-java
+)
+
+# 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-grep-java/java_grep.jar "$@"
diff --git a/course-definition.yml b/course-definition.yml
index dcab18a..4a6de5a 100644
--- a/course-definition.yml
+++ b/course-definition.yml
@@ -21,6 +21,9 @@ languages:
- slug: "gleam"
- slug: "go"
- slug: "haskell"
+ - slug: "java"
+ release_status: "alpha"
+ alpha_tester_usernames: ["andy1li"]
- slug: "javascript"
- slug: "kotlin"
- slug: "python"
diff --git a/dockerfiles/java-23.Dockerfile b/dockerfiles/java-23.Dockerfile
new file mode 100644
index 0000000..6199494
--- /dev/null
+++ b/dockerfiles/java-23.Dockerfile
@@ -0,0 +1,13 @@
+# syntax=docker/dockerfile:1.7-labs
+FROM maven:3.9.9-eclipse-temurin-23-alpine
+
+# Ensures the container is re-built if dependency files change
+ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="pom.xml"
+
+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
diff --git a/solutions/java/01-cq2/code/.codecrafters/compile.sh b/solutions/java/01-cq2/code/.codecrafters/compile.sh
new file mode 100755
index 0000000..c3347c5
--- /dev/null
+++ b/solutions/java/01-cq2/code/.codecrafters/compile.sh
@@ -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
+
+mvn -B package -Ddir=/tmp/codecrafters-build-grep-java
diff --git a/solutions/java/01-cq2/code/.codecrafters/run.sh b/solutions/java/01-cq2/code/.codecrafters/run.sh
new file mode 100755
index 0000000..33828d9
--- /dev/null
+++ b/solutions/java/01-cq2/code/.codecrafters/run.sh
@@ -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 /tmp/codecrafters-build-grep-java/java_grep.jar "$@"
diff --git a/solutions/java/01-cq2/code/.gitattributes b/solutions/java/01-cq2/code/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/solutions/java/01-cq2/code/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/solutions/java/01-cq2/code/.gitignore b/solutions/java/01-cq2/code/.gitignore
new file mode 100644
index 0000000..a48b18a
--- /dev/null
+++ b/solutions/java/01-cq2/code/.gitignore
@@ -0,0 +1,3 @@
+*.jar
+target/
+.idea/
diff --git a/solutions/java/01-cq2/code/README.md b/solutions/java/01-cq2/code/README.md
new file mode 100644
index 0000000..1dd5a76
--- /dev/null
+++ b/solutions/java/01-cq2/code/README.md
@@ -0,0 +1,39 @@
+![progress-banner](https://codecrafters.io/landing/images/default_progress_banners/grep.png)
+
+This is a starting point for Java solutions to the
+["Build Your Own grep" Challenge](https://app.codecrafters.io/courses/grep/overview).
+
+[Regular expressions](https://en.wikipedia.org/wiki/Regular_expression)
+(Regexes, for short) are patterns used to match character combinations in
+strings. [`grep`](https://en.wikipedia.org/wiki/Grep) is a CLI tool for
+searching using Regexes.
+
+In this challenge you'll build your own implementation of `grep`. Along the way
+we'll learn about Regex syntax, how parsers/lexers work, and how regular
+expressions are evaluated.
+
+**Note**: If you're viewing this repo on GitHub, head over to
+[codecrafters.io](https://codecrafters.io) to try the challenge.
+
+# Passing the first stage
+
+The entry point for your `grep` implementation is in `src/main/java/Main.java`.
+Study and uncomment the relevant code, and push your changes to pass the first
+stage:
+
+```sh
+git commit -am "pass 1st stage" # any msg
+git push origin master
+```
+
+Time to move on to the next stage!
+
+# Stage 2 & beyond
+
+Note: This section is for stages 2 and beyond.
+
+1. Ensure you have `mvn` installed locally
+1. Run `./your_program.sh` to run your program, which is implemented in
+ `src/main/java/Main.java`.
+1. Commit your changes and run `git push origin master` to submit your solution
+ to CodeCrafters. Test output will be streamed to your terminal.
diff --git a/solutions/java/01-cq2/code/codecrafters.yml b/solutions/java/01-cq2/code/codecrafters.yml
new file mode 100644
index 0000000..2406954
--- /dev/null
+++ b/solutions/java/01-cq2/code/codecrafters.yml
@@ -0,0 +1,11 @@
+# Set this to true if you want debug logs.
+#
+# These can be VERY verbose, so we suggest turning them off
+# unless you really need them.
+debug: false
+
+# Use this to change the Java version used to run your code
+# on Codecrafters.
+#
+# Available versions: java-23
+language_pack: java-23
diff --git a/solutions/java/01-cq2/code/pom.xml b/solutions/java/01-cq2/code/pom.xml
new file mode 100644
index 0000000..f527f97
--- /dev/null
+++ b/solutions/java/01-cq2/code/pom.xml
@@ -0,0 +1,52 @@
+
+
+ 4.0.0
+
+ io.codecrafters
+ build-your-own-grep
+ 1.0
+
+
+ 23
+ 23
+ UTF-8
+ 23
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+ java_grep
+
+ jar-with-dependencies
+
+ false
+
+
+ true
+
+ Main
+
+
+ ${dir}
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/solutions/java/01-cq2/code/src/main/java/Main.java b/solutions/java/01-cq2/code/src/main/java/Main.java
new file mode 100644
index 0000000..80e6cb4
--- /dev/null
+++ b/solutions/java/01-cq2/code/src/main/java/Main.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+import java.util.Scanner;
+
+public class Main {
+ public static void main(String[] args){
+ if (args.length != 2 || !args[0].equals("-E")) {
+ System.out.println("Usage: ./your_program.sh -E ");
+ System.exit(1);
+ }
+
+ String pattern = args[1];
+ Scanner scanner = new Scanner(System.in);
+ String inputLine = scanner.nextLine();
+
+ if (matchPattern(inputLine, pattern)) {
+ System.exit(0);
+ } else {
+ System.exit(1);
+ }
+ }
+
+ public static boolean matchPattern(String inputLine, String pattern) {
+ if (pattern.length() == 1) {
+ return inputLine.contains(pattern);
+ } else {
+ throw new RuntimeException("Unhandled pattern: " + pattern);
+ }
+ }
+}
diff --git a/solutions/java/01-cq2/code/your_program.sh b/solutions/java/01-cq2/code/your_program.sh
new file mode 100755
index 0000000..e0e0783
--- /dev/null
+++ b/solutions/java/01-cq2/code/your_program.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Use this script to run your program LOCALLY.
+#
+# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
+#
+# Learn more: https://codecrafters.io/program-interface
+
+set -e # Exit early if any commands fail
+
+# Copied from .codecrafters/compile.sh
+#
+# - Edit this to change how your program compiles locally
+# - 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-grep-java
+)
+
+# 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-grep-java/java_grep.jar "$@"
diff --git a/solutions/java/01-cq2/diff/src/main/java/Main.java.diff b/solutions/java/01-cq2/diff/src/main/java/Main.java.diff
new file mode 100644
index 0000000..ca8800e
--- /dev/null
+++ b/solutions/java/01-cq2/diff/src/main/java/Main.java.diff
@@ -0,0 +1,40 @@
+@@ -1,34 +1,29 @@
+ import java.io.IOException;
+ import java.util.Scanner;
+
+ public class Main {
+ public static void main(String[] args){
+ if (args.length != 2 || !args[0].equals("-E")) {
+ System.out.println("Usage: ./your_program.sh -E ");
+ System.exit(1);
+ }
+
+ String pattern = args[1];
+ Scanner scanner = new Scanner(System.in);
+ String inputLine = scanner.nextLine();
+
+- // 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
+- //
+- // if (matchPattern(inputLine, pattern)) {
+- // System.exit(0);
+- // } else {
+- // System.exit(1);
+- // }
++ if (matchPattern(inputLine, pattern)) {
++ System.exit(0);
++ } else {
++ System.exit(1);
++ }
+ }
+
+ public static boolean matchPattern(String inputLine, String pattern) {
+ if (pattern.length() == 1) {
+ return inputLine.contains(pattern);
+ } else {
+ throw new RuntimeException("Unhandled pattern: " + pattern);
+ }
+ }
+ }
diff --git a/solutions/java/01-cq2/explanation.md b/solutions/java/01-cq2/explanation.md
new file mode 100644
index 0000000..a4d5a90
--- /dev/null
+++ b/solutions/java/01-cq2/explanation.md
@@ -0,0 +1,21 @@
+The entry point for your grep implementation is in `src/main/java/Main.java`.
+
+Study and uncomment the relevant code:
+
+```java
+// Uncomment this block to pass the first stage
+
+if (matchPattern(inputLine, pattern)) {
+ System.exit(0);
+} else {
+ System.exit(1);
+}
+```
+
+Push your changes to pass the first stage:
+
+```
+git add .
+git commit -m "pass 1st stage" # any msg
+git push origin master
+```
diff --git a/starter_templates/java/code/.codecrafters/compile.sh b/starter_templates/java/code/.codecrafters/compile.sh
new file mode 100755
index 0000000..c3347c5
--- /dev/null
+++ b/starter_templates/java/code/.codecrafters/compile.sh
@@ -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
+
+mvn -B package -Ddir=/tmp/codecrafters-build-grep-java
diff --git a/starter_templates/java/code/.codecrafters/run.sh b/starter_templates/java/code/.codecrafters/run.sh
new file mode 100755
index 0000000..33828d9
--- /dev/null
+++ b/starter_templates/java/code/.codecrafters/run.sh
@@ -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 /tmp/codecrafters-build-grep-java/java_grep.jar "$@"
diff --git a/starter_templates/java/code/.gitignore b/starter_templates/java/code/.gitignore
new file mode 100644
index 0000000..a48b18a
--- /dev/null
+++ b/starter_templates/java/code/.gitignore
@@ -0,0 +1,3 @@
+*.jar
+target/
+.idea/
diff --git a/starter_templates/java/code/pom.xml b/starter_templates/java/code/pom.xml
new file mode 100644
index 0000000..f527f97
--- /dev/null
+++ b/starter_templates/java/code/pom.xml
@@ -0,0 +1,52 @@
+
+
+ 4.0.0
+
+ io.codecrafters
+ build-your-own-grep
+ 1.0
+
+
+ 23
+ 23
+ UTF-8
+ 23
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+ java_grep
+
+ jar-with-dependencies
+
+ false
+
+
+ true
+
+ Main
+
+
+ ${dir}
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter_templates/java/code/src/main/java/Main.java b/starter_templates/java/code/src/main/java/Main.java
new file mode 100644
index 0000000..5c7b7c5
--- /dev/null
+++ b/starter_templates/java/code/src/main/java/Main.java
@@ -0,0 +1,34 @@
+import java.io.IOException;
+import java.util.Scanner;
+
+public class Main {
+ public static void main(String[] args){
+ if (args.length != 2 || !args[0].equals("-E")) {
+ System.out.println("Usage: ./your_program.sh -E ");
+ System.exit(1);
+ }
+
+ String pattern = args[1];
+ Scanner scanner = new Scanner(System.in);
+ String inputLine = scanner.nextLine();
+
+ // 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
+ //
+ // if (matchPattern(inputLine, pattern)) {
+ // System.exit(0);
+ // } else {
+ // System.exit(1);
+ // }
+ }
+
+ public static boolean matchPattern(String inputLine, String pattern) {
+ if (pattern.length() == 1) {
+ return inputLine.contains(pattern);
+ } else {
+ throw new RuntimeException("Unhandled pattern: " + pattern);
+ }
+ }
+}
diff --git a/starter_templates/java/config.yml b/starter_templates/java/config.yml
new file mode 100644
index 0000000..c35aa0d
--- /dev/null
+++ b/starter_templates/java/config.yml
@@ -0,0 +1,3 @@
+attributes:
+ required_executable: mvn
+ user_editable_file: src/main/java/Main.java
From c5bf29098cb1071bf76bddc62111cb577a543240 Mon Sep 17 00:00:00 2001
From: Andy Li <1450947+andy1li@users.noreply.github.com>
Date: Tue, 1 Oct 2024 18:04:18 +0800
Subject: [PATCH 2/2] Update artifact name
---
compiled_starters/java/.codecrafters/run.sh | 2 +-
compiled_starters/java/pom.xml | 4 ++--
compiled_starters/java/your_program.sh | 2 +-
solutions/java/01-cq2/code/.codecrafters/run.sh | 2 +-
solutions/java/01-cq2/code/pom.xml | 4 ++--
solutions/java/01-cq2/code/your_program.sh | 2 +-
starter_templates/java/code/.codecrafters/run.sh | 2 +-
starter_templates/java/code/pom.xml | 4 ++--
8 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/compiled_starters/java/.codecrafters/run.sh b/compiled_starters/java/.codecrafters/run.sh
index 33828d9..05b9da9 100755
--- a/compiled_starters/java/.codecrafters/run.sh
+++ b/compiled_starters/java/.codecrafters/run.sh
@@ -8,4 +8,4 @@
set -e # Exit on failure
-exec java -jar /tmp/codecrafters-build-grep-java/java_grep.jar "$@"
+exec java -jar /tmp/codecrafters-build-grep-java/codecrafters-grep.jar "$@"
diff --git a/compiled_starters/java/pom.xml b/compiled_starters/java/pom.xml
index f527f97..6d2132b 100644
--- a/compiled_starters/java/pom.xml
+++ b/compiled_starters/java/pom.xml
@@ -5,7 +5,7 @@
4.0.0
io.codecrafters
- build-your-own-grep
+ codecrafters-grep
1.0
@@ -21,7 +21,7 @@
org.apache.maven.plugins
maven-assembly-plugin
- java_grep
+ codecrafters-grep
jar-with-dependencies
diff --git a/compiled_starters/java/your_program.sh b/compiled_starters/java/your_program.sh
index e0e0783..b9834f7 100755
--- a/compiled_starters/java/your_program.sh
+++ b/compiled_starters/java/your_program.sh
@@ -21,4 +21,4 @@ set -e # Exit early if any commands fail
#
# - 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-grep-java/java_grep.jar "$@"
+exec java -jar /tmp/codecrafters-build-grep-java/codecrafters-grep.jar "$@"
diff --git a/solutions/java/01-cq2/code/.codecrafters/run.sh b/solutions/java/01-cq2/code/.codecrafters/run.sh
index 33828d9..05b9da9 100755
--- a/solutions/java/01-cq2/code/.codecrafters/run.sh
+++ b/solutions/java/01-cq2/code/.codecrafters/run.sh
@@ -8,4 +8,4 @@
set -e # Exit on failure
-exec java -jar /tmp/codecrafters-build-grep-java/java_grep.jar "$@"
+exec java -jar /tmp/codecrafters-build-grep-java/codecrafters-grep.jar "$@"
diff --git a/solutions/java/01-cq2/code/pom.xml b/solutions/java/01-cq2/code/pom.xml
index f527f97..6d2132b 100644
--- a/solutions/java/01-cq2/code/pom.xml
+++ b/solutions/java/01-cq2/code/pom.xml
@@ -5,7 +5,7 @@
4.0.0
io.codecrafters
- build-your-own-grep
+ codecrafters-grep
1.0
@@ -21,7 +21,7 @@
org.apache.maven.plugins
maven-assembly-plugin
- java_grep
+ codecrafters-grep
jar-with-dependencies
diff --git a/solutions/java/01-cq2/code/your_program.sh b/solutions/java/01-cq2/code/your_program.sh
index e0e0783..b9834f7 100755
--- a/solutions/java/01-cq2/code/your_program.sh
+++ b/solutions/java/01-cq2/code/your_program.sh
@@ -21,4 +21,4 @@ set -e # Exit early if any commands fail
#
# - 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-grep-java/java_grep.jar "$@"
+exec java -jar /tmp/codecrafters-build-grep-java/codecrafters-grep.jar "$@"
diff --git a/starter_templates/java/code/.codecrafters/run.sh b/starter_templates/java/code/.codecrafters/run.sh
index 33828d9..05b9da9 100755
--- a/starter_templates/java/code/.codecrafters/run.sh
+++ b/starter_templates/java/code/.codecrafters/run.sh
@@ -8,4 +8,4 @@
set -e # Exit on failure
-exec java -jar /tmp/codecrafters-build-grep-java/java_grep.jar "$@"
+exec java -jar /tmp/codecrafters-build-grep-java/codecrafters-grep.jar "$@"
diff --git a/starter_templates/java/code/pom.xml b/starter_templates/java/code/pom.xml
index f527f97..6d2132b 100644
--- a/starter_templates/java/code/pom.xml
+++ b/starter_templates/java/code/pom.xml
@@ -5,7 +5,7 @@
4.0.0
io.codecrafters
- build-your-own-grep
+ codecrafters-grep
1.0
@@ -21,7 +21,7 @@
org.apache.maven.plugins
maven-assembly-plugin
- java_grep
+ codecrafters-grep
jar-with-dependencies