diff --git a/build.gradle b/build.gradle index ffdfc98..c700855 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,41 @@ plugins { id 'java' + id 'org.springframework.boot' version '3.5.8' apply false + id 'io.spring.dependency-management' version '1.1.7' apply false } -group 'me.lenajenichen' -version '1.0-SNAPSHOT' +allprojects { + group 'me.lenajenichen' + version '0.0.1-SNAPSHOT' -repositories { - mavenCentral() + repositories { + mavenCentral() + } } -dependencies { - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' -} +subprojects { -test { - useJUnitPlatform() + apply plugin: 'java' + + // Only the actual service applications (under :services:...) are Spring Boot apps. + // Aggregator/helper projects like :services and :test should not apply Spring Boot. + if (project.path.startsWith(':services:')) { + apply plugin: 'org.springframework.boot' + apply plugin: 'io.spring.dependency-management' + + dependencies { + implementation 'org.springframework.boot:spring-boot-starter' + implementation 'org.springframework.boot:spring-boot-starter-web' + // Ensure R2DBC SPI is on the classpath to satisfy Boot's autoconfiguration checks + implementation 'io.r2dbc:r2dbc-spi' + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + } + } + + tasks.withType(Test).configureEach { + useJUnitPlatform() + } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..d642e7f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/services/analytics-service/build.gradle b/services/analytics-service/build.gradle new file mode 100644 index 0000000..007cc80 --- /dev/null +++ b/services/analytics-service/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'java' +} + +group 'me.lenajenichen' +version '0.0.1-SNAPSHOT' + +springBoot { + mainClass = 'AnalyticsServiceApplication' +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/services/analytics-service/src/main/java/AnalyticsServiceApplication.java b/services/analytics-service/src/main/java/AnalyticsServiceApplication.java new file mode 100644 index 0000000..52c0d30 --- /dev/null +++ b/services/analytics-service/src/main/java/AnalyticsServiceApplication.java @@ -0,0 +1,13 @@ +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AnalyticsServiceApplication { + + public static void main(String[] args) { + + SpringApplication.run(AnalyticsServiceApplication.class, args); + + } + +} diff --git a/services/auth-service/build.gradle b/services/auth-service/build.gradle new file mode 100644 index 0000000..50d4e37 --- /dev/null +++ b/services/auth-service/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'java' +} + +group 'me.lenajenichen' +version '0.0.1-SNAPSHOT' + +springBoot { + mainClass = 'AuthServiceApplication' +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/services/auth-service/src/main/java/AuthServiceApplication.java b/services/auth-service/src/main/java/AuthServiceApplication.java new file mode 100644 index 0000000..f0fcd4c --- /dev/null +++ b/services/auth-service/src/main/java/AuthServiceApplication.java @@ -0,0 +1,13 @@ +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AuthServiceApplication { + + public static void main(String[] args) { + + SpringApplication.run(AuthServiceApplication.class, args); + + } + +} diff --git a/services/redirect-service/build.gradle b/services/redirect-service/build.gradle new file mode 100644 index 0000000..a107f4a --- /dev/null +++ b/services/redirect-service/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'java' +} + +group 'me.lenajenichen' +version '0.0.1-SNAPSHOT' + +springBoot { + mainClass = 'RedirectServiceApplication' +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/services/redirect-service/src/main/java/RedirectServiceApplication.java b/services/redirect-service/src/main/java/RedirectServiceApplication.java new file mode 100644 index 0000000..e7fdafd --- /dev/null +++ b/services/redirect-service/src/main/java/RedirectServiceApplication.java @@ -0,0 +1,13 @@ +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RedirectServiceApplication { + + public static void main(String[] args) { + + SpringApplication.run(RedirectServiceApplication.class, args); + + } + +} diff --git a/services/shortener-service/build.gradle b/services/shortener-service/build.gradle new file mode 100644 index 0000000..3cc81de --- /dev/null +++ b/services/shortener-service/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'java' +} + +group 'me.lenajenichen' +version '0.0.1-SNAPSHOT' + +repositories { + mavenCentral() +} + +springBoot { + mainClass = 'shortener.ShortenerServiceApplication' +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/services/shortener-service/src/main/java/api/HealthController.java b/services/shortener-service/src/main/java/api/HealthController.java new file mode 100644 index 0000000..29bdafb --- /dev/null +++ b/services/shortener-service/src/main/java/api/HealthController.java @@ -0,0 +1,15 @@ +package api; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/health") +public class HealthController { + + @GetMapping + public String health() { + return "OK"; + } +} \ No newline at end of file diff --git a/services/shortener-service/src/main/java/shortener/ShortenerServiceApplication.java b/services/shortener-service/src/main/java/shortener/ShortenerServiceApplication.java new file mode 100644 index 0000000..50ba4cb --- /dev/null +++ b/services/shortener-service/src/main/java/shortener/ShortenerServiceApplication.java @@ -0,0 +1,15 @@ +package shortener; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = {"shortener", "api"}) +public class ShortenerServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(ShortenerServiceApplication.class, args); + } + +} diff --git a/services/shortener-service/src/main/resources/application.yaml b/services/shortener-service/src/main/resources/application.yaml new file mode 100644 index 0000000..020e90a --- /dev/null +++ b/services/shortener-service/src/main/resources/application.yaml @@ -0,0 +1,6 @@ +spring: + application: + name: shortener-service + +server: + port: 8083 \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 527ed80..0e1e8c1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,15 @@ rootProject.name = 'URLShortener' +include 'test' +include 'services' +include 'services:analytics-service' +findProject(':services:analytics-service')?.name = 'analytics-service' + +include 'services:auth-service' +findProject(':services:auth-service')?.name = 'auth-service' + +include 'services:redirect-service' +findProject(':services:redirect-service')?.name = 'redirect-service' + +include 'services:shortener-service' +findProject(':services:shortener-service')?.name = 'shortener-service' \ No newline at end of file