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

[Tech] Utilisation de gradle #2618

Merged
merged 9 commits into from
Oct 19, 2023
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
10 changes: 9 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
sig/layersdata/** filter=lfs diff=lfs merge=lfs -text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je n'avais même pas remarqué qu'on utilisait LFS. J'en profite du coup pour te demander ce que sont layersdata et pourquoi on les retire?

Et si on utilise plus LFS, ça vaut peut être le coup de cleaner l'historique LFS de Git mais à vérifier si c'est utile ou non (ça ne l'est pas si le clone/pull ne prend pas l'historique LFS).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On n'utilise plus LFS !
Normalement le but c'est justement de ne pas polluer l'historique .git avec cet outil

#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ datascience/docs/build
frontend/public/service-worker.js



# Ignore Gradle project-specific cache directory
backend/.gradle

# Ignore Gradle build output directory
backend/build
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ run-front:
cd ./frontend && npm run dev
run-back: run-stubbed-apis
docker compose up -d --quiet-pull --wait db
cd backend && ./mvnw spring-boot:run -Dspring-boot.run.arguments="--spring.config.additional-location=$(INFRA_FOLDER)" -Dspring-boot.run.profiles="local" -Dmaven.test.skip=true
cd backend && ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=$(INFRA_FOLDER)'
run-stubbed-apis:
docker compose stop geoserver-monitorenv-stubs
docker compose up -d --quiet-pull --wait geoserver-monitorenv-stubs
Expand All @@ -23,14 +23,14 @@ check-clean-archi:
test: test-back
cd frontend && CI=true npm run test:unit -- --coverage
test-back: check-clean-archi
cd backend && ./mvnw clean && ./mvnw test
cd backend && ./gradlew clean test
clean:
make erase-db
rm -Rf ./backend/target
dev: clean
make run-back
lint-back:
cd ./backend && ./mvnw antrun:run@ktlint-format | grep -v \
cd ./backend && ./gradlew ktlintFormat | grep -v \
-e "Exceeded max line length" \
-e "Package name must not contain underscore" \
-e "Wildcard import"
Expand Down
128 changes: 128 additions & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
plugins {
`java-library`
`maven-publish`
id("org.springframework.boot") version "3.1.3"
id("org.jetbrains.kotlin.plugin.spring") version "1.9.10"
kotlin("jvm") version "1.9.10"
id("org.jetbrains.kotlin.plugin.allopen") version "1.9.10"
kotlin("plugin.noarg") version "1.9.10"
kotlin("plugin.jpa") version "1.9.10"
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
kotlin("plugin.serialization") version "1.9.10"
}

repositories {
mavenCentral()
}

kotlin {
jvmToolchain(17)
}

noArg {
invokeInitializers = true
}

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

tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
compilerOptions {
freeCompilerArgs.add("-Xjsr305=strict")
// jvmTarget.set(JvmTarget.JVM_17)
// javaParameters.set(true)
}
}

dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
api("io.ktor:ktor-client-core-jvm:2.3.3")
api("io.ktor:ktor-client-java-jvm:2.3.3")
api("io.ktor:ktor-client-mock-jvm:2.3.3")
api("io.ktor:ktor-client-content-negotiation-jvm:2.3.3")
api("io.ktor:ktor-serialization-kotlinx-json-jvm:2.3.3")
api("org.springframework.boot:spring-boot-starter-web:3.1.3")
api("org.springframework.security:spring-security-oauth2-resource-server:6.1.5")
api("org.springframework.security:spring-security-oauth2-jose:6.1.4")
api("org.hibernate.validator:hibernate-validator:8.0.1.Final")
api("jakarta.validation:jakarta.validation-api:3.0.2")
api("org.springframework.boot:spring-boot-starter-actuator:3.1.3")
api("org.springframework.boot:spring-boot-starter-json:3.1.3")
api("org.springframework.boot:spring-boot-starter-security:3.1.3")
api("org.springframework.boot:spring-boot-starter-data-jpa:3.1.3")
api("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.3")
api("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
api("org.flywaydb:flyway-core:9.22.3")
api("org.springdoc:springdoc-openapi-ui:1.7.0")
api("org.jetbrains.kotlin:kotlin-reflect:1.9.10")
api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10")
api("org.springframework.boot:spring-boot-configuration-processor:3.1.3")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
api("com.neovisionaries:nv-i18n:1.29")
api("org.springframework.boot:spring-boot-starter-cache:3.1.3")
api("com.github.ben-manes.caffeine:caffeine:3.1.8")
api("org.springframework.security:spring-security-test:6.1.5")
api("org.testcontainers:testcontainers:1.19.1")
api("io.hypersistence:hypersistence-utils-hibernate-62:3.5.3")
api("org.assertj:assertj-core:3.24.2")
api("org.testcontainers:postgresql:1.19.1")
api("org.springframework.boot:spring-boot-starter-log4j2:3.1.3")
api("org.locationtech.jts:jts-core:1.19.0")
api("org.hibernate:hibernate-spatial:6.1.7.Final")
api("io.sentry:sentry:6.31.0")
api("io.sentry:sentry-log4j2:6.31.0")
runtimeOnly("org.springframework.boot:spring-boot-devtools:3.1.3")
runtimeOnly("org.postgresql:postgresql:42.6.0")
testImplementation("jakarta.servlet:jakarta.servlet-api:6.0.0")
testImplementation("com.squareup.okhttp3:mockwebserver:4.11.0")
testImplementation("org.springframework.boot:spring-boot-starter-test:3.1.3")
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc:3.0.0")
testImplementation("org.testcontainers:junit-jupiter:1.19.1")
}

group = "fr.gouv.cnsp"
version = "VERSION_TO_CHANGE"
description = "MonitorFish"
java.sourceCompatibility = JavaVersion.VERSION_17

publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
}
}

springBoot {
mainClass.set("fr.gouv.cnsp.monitorfish.MonitorFishApplicationKt")

buildInfo {
properties {
additional = mapOf(
"commit.hash" to "COMMIT_TO_CHANGE"
)
}
}
}

tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
}

tasks.withType<Javadoc>() {
options.encoding = "UTF-8"
}

configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
verbose.set(true)
android.set(false)
outputToConsole.set(true)
ignoreFailures.set(true)
}

tasks.named<Test>("test") {
useJUnitPlatform()

testLogging {
events("passed")
}
}
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.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading