From a011e9469a812999de15fc16adcfd6aeae03a508 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 14 Oct 2024 18:13:56 +0200 Subject: [PATCH 1/3] Code set up script :wip --- .mvn/parent.xml | 8 ++++++ set_up.java | 68 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/.mvn/parent.xml b/.mvn/parent.xml index 852ac55..8fc5fcd 100644 --- a/.mvn/parent.xml +++ b/.mvn/parent.xml @@ -116,6 +116,14 @@ verify + + org.apache.maven.plugins + maven-compiler-plugin + + --enable-preview + + + org.springframework.boot spring-boot-maven-plugin diff --git a/set_up.java b/set_up.java index d521f3d..d8054f8 100755 --- a/set_up.java +++ b/set_up.java @@ -2,27 +2,63 @@ import static java.util.Map.entry; -import java.io.Console; +import java.io.File; +import java.io.IOException; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Comparator; import java.util.List; +import java.util.Optional; +import java.util.Scanner; +import java.util.stream.Stream; -private Console console = System.console(); +Scanner scanner = new Scanner(System.in); +FileSystem fs = FileSystems.getDefault(); void main() { - var options = List.of( - entry("GitHub", prompt("Keep GitHub workflows and templates: (Yn)", "y")), - entry("GitLab", prompt("Keep GitLab workflows and templates: (Yn)", "y")), - entry("GitLab", prompt("Keep 'CODE_OF_CONDUCT.md' file: (Yn)", "y")), - entry("GitLab", prompt("Keep 'CONTRIBUTING.md' file: (Yn)", "y")), - entry("GitLab", prompt("Keep 'LICENSE.md' file: (Yn)", "y")), - entry("GitLab", prompt("Keep this set up file 'set_up.java' file: (Yn)", "y")) - ); - - // Rename artifacts, groups or base package - // Restart Git history (or delete it) + var deletions = + Stream.of( + entry(".github", prompt("Keep GitHub workflows and templates (Yn): ", "y")), + entry(".gitlab*", prompt("Keep GitLab workflows and templates (Yn): ", "y")), + entry("CODE_OF_CONDUCT.md", prompt("Keep 'CODE_OF_CONDUCT.md' file (Yn): ", "y")), + entry("CONTRIBUTING.md", prompt("Keep 'CONTRIBUTING.md' file (Yn): ", "y")), + entry("LICENSE.md", prompt("Keep 'LICENSE.md' file (Yn): ", "y")), +// entry(".git", prompt("Keep Git history (Yn): ", "y")), + entry("set_up.java", prompt("Keep this set up file 'set_up.java' file (Yn): ", "y")) + ) + .filter(it -> it.getValue().equalsIgnoreCase("n")) + .toList(); + + // TODO Rename artifacts, groups or base package + // TODO Show summary before applying changes + + deletions.forEach(it -> delete(it.getKey())); } -public String prompt(String message, String defaultValue) { - console.printf(message); - var v = console.readLine(); +String prompt(String message, String defaultValue) { + System.out.print(message); + var v = scanner.nextLine(); return v == null || v.isBlank() ? defaultValue : v; } + +void delete(String glob) { + var matcher = fs.getPathMatcher("glob:./" + glob); + var cwd = new File("."); + Optional + .ofNullable(cwd.listFiles(it -> matcher.matches(it.toPath()))) + .map(List::of) + .orElse(List.of()) + .forEach(it -> { + try (Stream paths = Files.walk(it.toPath())) { + paths + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(System.out::println); // (File::delete); + } + catch (IOException _) { + System.out.println("Error deleting " + it); + } + }); +} From ee06202a6f6c23d2a5d3c3247e6f808e0d8c015e Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 2 Dec 2024 18:01:56 +0100 Subject: [PATCH 2/3] Update --- .mvn/parent.xml | 78 +++++++++++++++++++++++++++------------------- docker-compose.yml | 6 ++-- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/.mvn/parent.xml b/.mvn/parent.xml index 8fc5fcd..854b56c 100644 --- a/.mvn/parent.xml +++ b/.mvn/parent.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 3.3.4 + 3.4.0 @@ -127,42 +127,13 @@ org.springframework.boot spring-boot-maven-plugin - - - - ${env.REGISTRY_USERNAME} - ${env.REGISTRY_PASSWORD} - - - - ${image.registry}/${image.name}:${project.version} - - ${image.registry}/${image.name}:latest - - - - -XX:+AlwaysPreTouch -XX:+UseParallelGC -XX:+UseNUMA - - true - true - ${java.version} - - - - - - image - - build-image - - verify - - + org.apache.maven.plugins maven-failsafe-plugin + org.jacoco jacoco-maven-plugin @@ -421,5 +392,48 @@ + + + buildpack + + + + org.springframework.boot + spring-boot-maven-plugin + + + + ${env.REGISTRY_USERNAME} + ${env.REGISTRY_PASSWORD} + + + + ${image.registry}/${image.name}:${project.version} + + ${image.registry}/${image.name}:latest + + + + -XX:+AlwaysPreTouch -XX:+UseParallelGC -XX:+UseNUMA + + true + true + ${java.version} + + + + + + image + + build-image + + verify + + + + + + diff --git a/docker-compose.yml b/docker-compose.yml index b366149..e640879 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: - data:/var/lib/postgresql/data - ./src/test/resources/db:/docker-entrypoint-initdb.d ports: - - "15432:5432" + - "127.0.0.1:15432:5432" kafka: image: docker.io/apache/kafka-native:3.8.0 @@ -33,7 +33,7 @@ services: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 KAFKA_LOG_DIRS: /tmp/kraft-combined-logs ports: - - "9092:9092" + - "127.0.0.1:9092:9092" appointments: profiles: [ local ] @@ -49,7 +49,7 @@ services: JDBC_PASSWORD: root KAFKA_SERVER: kafka:19092 ports: - - "18080:8080" + - "127.0.0.1:18080:8080" volumes: data: From e68da79fc592b06f5bdd6fd216b579ae0288db75 Mon Sep 17 00:00:00 2001 From: jaguililla Date: Sat, 7 Dec 2024 20:12:43 +0100 Subject: [PATCH 3/3] Update documentation --- README.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9e71f0..c2edda4 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ configuration options and their default values can be checked [here][gatlingDefa Those parameters can also be overwritten by system properties from the command line. I.e.: `-D gatling.core.encoding=utf-8` -To run the Gatling test, execute `./mvnw gatling:test` at the shell. +To run the Gatling test, execute `./mvnw -P gatling` at the shell. [Gatling settings]: https://docs.gatling.io/reference/script/core/configuration [gatlingDefaults]: https://github.com/gatling/gatling/blob/main/gatling-core/src/main/resources/gatling-defaults.conf diff --git a/pom.xml b/pom.xml index 0b7e91c..227d313 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ appointments - 0.3.8 + 0.3.9 Appointments Application to create appointments (REST API)