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

Backend - introduce gradle (no CI, no deployment) #78

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ front-visualize-bundle:
BACKEND_DIR := backend
BACKEND_CONFIGURATION_FOLDER=$(shell pwd)/infra/configurations/backend/

.PHONY: back-show-dependencies back-local

back-show-dependencies:
cd $(BACKEND_DIR) && ./gradlew dependencies

back-start-local:
cd $(BACKEND_DIR) && ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=$(BACKEND_CONFIGURATION_FOLDER)'


.PHONY: back-clean-install back-check-dependencies back-test back-sonar
back-clean-install:
Expand Down
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
HELP.md

### Gradle ###
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
Expand Down
43 changes: 34 additions & 9 deletions backend/HELP.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
# Getting Started

### Reference Documentation

For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.1/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.1/maven-plugin/reference/html/#build-image)
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.1.1/reference/htmlsingle/#web)
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.1.1/reference/htmlsingle/#data.sql.jpa-and-spring-data)
* [Rest Repositories](https://docs.spring.io/spring-boot/docs/3.1.1/reference/htmlsingle/#howto.data-access.exposing-spring-data-repositories-as-rest)
* [Official Gradle documentation](https://docs.gradle.org)
* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.2.1/gradle-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.2.1/gradle-plugin/reference/html/#build-image)
* [Spring Boot Testcontainers support](https://docs.spring.io/spring-boot/docs/3.2.1/reference/html/features.html#features.testing.testcontainers)
* [Testcontainers Postgres Module Reference Guide](https://java.testcontainers.org/modules/databases/postgres/)
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.2.1/reference/htmlsingle/index.html#web)
* [Spring for GraphQL](https://docs.spring.io/spring-boot/docs/3.2.1/reference/htmlsingle/index.html#web.graphql)
* [Spring Security](https://docs.spring.io/spring-boot/docs/3.2.1/reference/htmlsingle/index.html#web.security)
* [Testcontainers](https://java.testcontainers.org/)
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.2.1/reference/htmlsingle/index.html#data.sql.jpa-and-spring-data)
* [Flyway Migration](https://docs.spring.io/spring-boot/docs/3.2.1/reference/htmlsingle/index.html#howto.data-initialization.migration-tool.flyway)

### Guides

The following guides illustrate how to use some features concretely:

* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
* [Building a GraphQL service](https://spring.io/guides/gs/graphql-server/)
* [Securing a Web Application](https://spring.io/guides/gs/securing-web/)
* [Spring Boot and OAuth2](https://spring.io/guides/tutorials/spring-boot-oauth2/)
* [Authenticating a User with LDAP](https://spring.io/guides/gs/authenticating-ldap/)
* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)
* [Accessing JPA Data with REST](https://spring.io/guides/gs/accessing-data-rest/)
* [Accessing Neo4j Data with REST](https://spring.io/guides/gs/accessing-neo4j-data-rest/)
* [Accessing MongoDB Data with REST](https://spring.io/guides/gs/accessing-mongodb-data-rest/)

### Additional Links

These additional references should also help you:

* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle)

### Testcontainers support

This project
uses [Testcontainers at development time](https://docs.spring.io/spring-boot/docs/3.2.1/reference/html/features.html#features.testing.testcontainers.at-development-time).

Testcontainers has been configured to use the following Docker images:

* [`postgres:latest`](https://hub.docker.com/_/postgres)

Please review the tags of the used images and set them to the same as you're running in production.

117 changes: 117 additions & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "fr.gouv.dgampa"
version = "VERSION_TO_CHANGE"
description = "RapportNav"

val kotlinVersion by extra("1.9.0")
val serializationVersion by extra("1.6.2")
val springVersion by extra("3.2.0")
val testcontainersVersion by extra("1.19.2")

plugins {
`java-library`
`maven-publish`
kotlin("jvm") version "1.9.0"
kotlin("plugin.spring") version "1.9.0"
kotlin("plugin.jpa") version "1.9.0"
id("org.springframework.boot") version "3.2.0"
id("io.spring.dependency-management") version "1.1.4"
id("org.owasp.dependencycheck") version "8.4.0"
}

springBoot {
mainClass.set("fr.gouv.dgampa.rapportnav.RapportNavApplicationKt")
}

repositories {
mavenCentral()
}

configurations.all {
exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")
}

dependencyManagement {
imports {
mavenBom("org.testcontainers:testcontainers-bom:$testcontainersVersion")
}
dependencies {
dependency("com.graphql-java:graphql-java:21.1")
}
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-data-rest:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-web:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-graphql:$springVersion")
implementation("org.springframework.boot:spring-boot-autoconfigure:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-log4j2:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-security:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server:$springVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
runtimeOnly("org.postgresql:postgresql:42.7.0")
implementation("org.flywaydb:flyway-core:9.22.3")
implementation("org.n52.jackson:jackson-datatype-jts:1.2.10") {
exclude(group = "org.locationtech.jts", module = "jts-core")
}
implementation("io.jsonwebtoken:jjwt-api:0.12.3")
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation("org.springframework.security:spring-security-oauth2-jose:6.2.0")
implementation("org.locationtech.jts:jts-core:1.19.0")
implementation("io.swagger.core.v3:swagger-core:2.2.19")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
implementation("io.sentry:sentry-spring-boot-starter-jakarta:7.0.0")
implementation("io.sentry:sentry-log4j2:7.0.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework:spring-webflux")
testImplementation("org.springframework.graphql:spring-graphql-test")
testImplementation("org.testcontainers:testcontainers")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:postgresql")
}

java {
sourceCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}

//val sonarOrganization by extra("mtes-mct")
//val sonarProjectKey by extra("MTES-MCT_rapportnav2")
//
//configure<org.sonarqube.gradle.SonarQubeExtension> {
// properties {
// property("sonar.organization", sonarOrganization)
// property("sonar.projectKey", sonarProjectKey)
// }
//}

//configure<org.owasp.dependencycheck.dependencycheckBasePluginExtension> {
// skip = true
//}

//val ci by profiles.creating {
// val flywayEnabled by extra(false)
// properties["flyway.enabled"] = flywayEnabled
// configure<org.springframework.boot.gradle.plugin.SpringBootPluginExtension> {
// isEnabled = false
// }
//}

//val sonar by profiles.creating {
// properties["sonar.organization"] = sonarOrganization
// properties["sonar.projectKey"] = sonarProjectKey
//}
Binary file added backend/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions backend/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading