From a8c24ba2efa6c5ccde387903cad752c36a63391e Mon Sep 17 00:00:00 2001 From: Daniel Mass Date: Fri, 16 Feb 2024 10:42:16 +0100 Subject: [PATCH 1/3] feat: easy project checkout --- build.gradle | 2 +- src/main/resources/application.yaml | 11 ++++++----- .../example/roommate/tests/application/MainTest.java | 1 - 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index c0700558..95185ea2 100644 --- a/build.gradle +++ b/build.gradle @@ -56,7 +56,7 @@ dependencies { testImplementation 'ognl:ognl' testImplementation 'com.tngtech.archunit:archunit-junit5-engine:1.2.1' - runtimeOnly 'org.postgresql:postgresql:42.7.1' + runtimeOnly 'com.h2database:h2' } tasks.named('test') { diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index edd6b01c..ad5aeb46 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,6 +1,7 @@ logging: level: ROOT: Warn + org.flywaydb: DEBUG spring: main: banner-mode: "off" @@ -13,9 +14,9 @@ spring: client-secret: ${CLIENT_SECRET} scope: read:public_repo - + datasource: - url: jdbc:postgresql://localhost:5432/postgres - username: user - password: 1234 - driver-class-name: org.postgresql.Driver \ No newline at end of file + url: jdbc:h2:mem:postgres + username: sa + password: + driver-class-name: org.h2.Driver diff --git a/src/test/java/com/example/roommate/tests/application/MainTest.java b/src/test/java/com/example/roommate/tests/application/MainTest.java index 4caf0450..20003dbb 100644 --- a/src/test/java/com/example/roommate/tests/application/MainTest.java +++ b/src/test/java/com/example/roommate/tests/application/MainTest.java @@ -9,7 +9,6 @@ @TestClass public class MainTest { @Test - @Disabled // postgres database required so it always fails @DisplayName("Main can be run") public void test_1() { RoomMateApplication.main(new String[]{}); From bac67084db3e37bd17686ce820904c81416471be Mon Sep 17 00:00:00 2001 From: Daniel Mass Date: Fri, 16 Feb 2024 16:31:23 +0100 Subject: [PATCH 2/3] bug: keymaster gradle integration, as keymaster shouldnt be a docker compose dependency, that would eliminate the purpose of h2 for development --- build.gradle | 10 +++++++++ docker-compose.yml | 3 +++ src/main/resources/application.yaml | 32 +++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 95185ea2..bb642459 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,16 @@ repositories { mavenCentral() } +tasks.register('runOtherSpringApp', Exec) { + exec { + executable 'java' + args '-jar keymaster.jar' + workingDir "${buildDir}/foo" + commandLine 'bash', '-c', "echo 'Hello world!'" + } +} + + dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation('org.springframework.boot:spring-boot-starter-validation') diff --git a/docker-compose.yml b/docker-compose.yml index a48e115e..6e64507b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,12 @@ services: build: context: . dockerfile: Dockerfile.RoomMate + always_build: true image: team-propra/roommate:v1 ports: - "8081:8081" + environment: + - "SPRING_PROFILES_ACTIVE=docker" keymaster: diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ad5aeb46..f619dd01 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -1,8 +1,14 @@ logging: level: - ROOT: Warn + ROOT: WARN org.flywaydb: DEBUG + org.springframework.jdbc: DEBUG + org.hibernate.SQL: DEBUG spring: + config: + activate: + on-profile: default # Set this to 'docker' when running in Docker + main: banner-mode: "off" security: @@ -15,8 +21,30 @@ spring: scope: read:public_repo + + +--- + +spring: + config: + activate: + on-profile: local + datasource: - url: jdbc:h2:mem:postgres + url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE username: sa password: driver-class-name: org.h2.Driver + +--- + +spring: + config: + activate: + on-profile: docker + + datasource: + url: jdbc:postgresql://postgres:5432 + username: user + password: 1234 + driver-class-name: org.postgresql.Driver From 79ae827cb5003f7afdd3ea44d794c6a6a526880f Mon Sep 17 00:00:00 2001 From: Daniel Mass Date: Sun, 18 Feb 2024 14:10:56 +0100 Subject: [PATCH 3/3] feat: keymaster task --- build.gradle | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index bb642459..42a5270e 100644 --- a/build.gradle +++ b/build.gradle @@ -36,13 +36,12 @@ repositories { mavenCentral() } -tasks.register('runOtherSpringApp', Exec) { - exec { - executable 'java' - args '-jar keymaster.jar' - workingDir "${buildDir}/foo" - commandLine 'bash', '-c', "echo 'Hello world!'" - } +tasks.register('keymaster', Exec) { + executable 'java' + args '-jar', "keymaster.jar" + workingDir "${projectDir}" + inputs.file("${projectDir}/keymaster.jar") + outputs.dir("${projectDir}") }