From ea47b5a8a2d38018ce1f834f7f0e039b27ba93ac Mon Sep 17 00:00:00 2001 From: Carl-Philipp Harmant Date: Thu, 23 Apr 2020 22:51:55 -0500 Subject: [PATCH] Add buildSrc for better version handling --- build.gradle.kts | 10 +++++----- buildSrc/build.gradle.kts | 11 ++++++++++ buildSrc/src/main/kotlin/Dependencies.kt | 20 +++++++++++++++++++ compliance-logging-common/build.gradle.kts | 12 ++++++----- compliance-logging-common/lombok.config | 2 ++ compliance-logging-log4j2/build.gradle.kts | 4 ++-- compliance-logging-logback/build.gradle.kts | 6 +++--- .../build.gradle.kts | 9 +++++---- .../build.gradle.kts | 5 ++--- 9 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/Dependencies.kt create mode 100644 compliance-logging-common/lombok.config diff --git a/build.gradle.kts b/build.gradle.kts index 26903c6..e80ecfd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ plugins { subprojects { group = "com.slalom" - version = "0.0.1-SNAPSHOT" + version = Version.project apply(plugin = "java-library") apply(plugin = "maven-publish") @@ -25,8 +25,8 @@ subprojects { } dependencies { - "testImplementation"(platform("org.junit:junit-bom:5.6.2")) - "testImplementation"(group = "org.assertj", name = "assertj-core", version = "3.15.0") + "testImplementation"(platform("org.junit:junit-bom:${Version.junit}")) + "testImplementation"(group = "org.assertj", name = "assertj-core", version = Version.assertj) } publishing { @@ -67,8 +67,8 @@ subprojects { } tasks.withType { - sourceCompatibility = JavaVersion.VERSION_1_8.toString() - targetCompatibility = JavaVersion.VERSION_1_8.toString() + sourceCompatibility = Version.java + targetCompatibility = Version.java } tasks.withType { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..27e857e --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} + +kotlinDslPluginOptions { + experimentalWarning.set(false) +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt new file mode 100644 index 0000000..cb7da77 --- /dev/null +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -0,0 +1,20 @@ +import org.gradle.api.JavaVersion + +object Version { + // Project + val java = JavaVersion.VERSION_1_8.toString() + const val project = "0.0.1-SNAPSHOT" + + // Dependencies + const val assertj = "3.15.0" + const val guava = "29.0-jre" + const val jackson = "2.10.3" + const val junit = "5.6.2" + const val log4j2 = "2.13.1" + const val logback = "1.2.3" + const val spring = "2.2.6.RELEASE" + const val slf4j = "1.7.30" + + // Gradle plugins + const val lombok_gradle_plugin = "5.0.0" +} \ No newline at end of file diff --git a/compliance-logging-common/build.gradle.kts b/compliance-logging-common/build.gradle.kts index 588e466..0dcc88a 100644 --- a/compliance-logging-common/build.gradle.kts +++ b/compliance-logging-common/build.gradle.kts @@ -1,11 +1,13 @@ +plugins { + id("io.freefair.lombok") version Version.lombok_gradle_plugin +} + description = "Common compliance library containing the masking logic" dependencies { - implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30") + implementation(group = "org.slf4j", name = "slf4j-api", version = Version.slf4j) testImplementation(group = "org.junit.jupiter", name = "junit-jupiter") - testImplementation(group = "com.google.guava", name = "guava", version = "29.0-jre") - testImplementation(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = "2.10.3") - testCompileOnly(group = "org.projectlombok", name = "lombok", version = "1.18.12") - testAnnotationProcessor(group = "org.projectlombok", name = "lombok", version = "1.18.12") + testImplementation(group = "com.google.guava", name = "guava", version = Version.guava) + testImplementation(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = Version.jackson) } \ No newline at end of file diff --git a/compliance-logging-common/lombok.config b/compliance-logging-common/lombok.config new file mode 100644 index 0000000..6aa51d7 --- /dev/null +++ b/compliance-logging-common/lombok.config @@ -0,0 +1,2 @@ +# This file is generated by the 'io.freefair.lombok' Gradle plugin +config.stopBubbling = true diff --git a/compliance-logging-log4j2/build.gradle.kts b/compliance-logging-log4j2/build.gradle.kts index 73af657..6a75667 100644 --- a/compliance-logging-log4j2/build.gradle.kts +++ b/compliance-logging-log4j2/build.gradle.kts @@ -1,11 +1,11 @@ plugins { - id("io.freefair.lombok") version "5.0.0" + id("io.freefair.lombok") version Version.lombok_gradle_plugin } description = "Compliance Log4j2 library" dependencies { - implementation(platform("org.apache.logging.log4j:log4j-bom:2.13.1")) + implementation(platform("org.apache.logging.log4j:log4j-bom:${Version.log4j2}")) api(project(":compliance-logging-common")) implementation(group = "org.apache.logging.log4j", name = "log4j-api") diff --git a/compliance-logging-logback/build.gradle.kts b/compliance-logging-logback/build.gradle.kts index 1012d88..e2ed95f 100644 --- a/compliance-logging-logback/build.gradle.kts +++ b/compliance-logging-logback/build.gradle.kts @@ -1,13 +1,13 @@ plugins { - id("io.freefair.lombok") version "5.0.0" + id("io.freefair.lombok") version Version.lombok_gradle_plugin } description = "Compliance Logback library" dependencies { api(project(":compliance-logging-common")) - implementation(group = "ch.qos.logback", name = "logback-core", version = "1.2.3") - implementation(group = "ch.qos.logback", name = "logback-classic", version = "1.2.3") + implementation(group = "ch.qos.logback", name = "logback-core", version = Version.logback) + implementation(group = "ch.qos.logback", name = "logback-classic", version = Version.logback) testImplementation(group = "org.junit.jupiter", name = "junit-jupiter") } \ No newline at end of file diff --git a/examples/spring-boot-log4j2-example/build.gradle.kts b/examples/spring-boot-log4j2-example/build.gradle.kts index 04b2282..7a6cf35 100644 --- a/examples/spring-boot-log4j2-example/build.gradle.kts +++ b/examples/spring-boot-log4j2-example/build.gradle.kts @@ -1,13 +1,14 @@ plugins { - id("io.freefair.lombok") version "5.0.0" + id("io.freefair.lombok") version Version.lombok_gradle_plugin } dependencies { - implementation(platform("org.springframework.boot:spring-boot-dependencies:2.2.6.RELEASE")) - implementation(platform("org.apache.logging.log4j:log4j-bom:2.13.1")) - implementation(project(":compliance-logging-log4j2")) + implementation(platform("org.springframework.boot:spring-boot-dependencies:${Version.spring}")) + implementation(platform("org.apache.logging.log4j:log4j-bom:${Version.log4j2}")) + implementation(group = "org.springframework.boot", name = "spring-boot-starter-web") implementation(group = "org.springframework.boot", name = "spring-boot-starter-log4j2") + implementation(project(":compliance-logging-log4j2")) } // Do not publish artifact diff --git a/examples/spring-boot-logback-example/build.gradle.kts b/examples/spring-boot-logback-example/build.gradle.kts index 1894ee3..3967cb5 100644 --- a/examples/spring-boot-logback-example/build.gradle.kts +++ b/examples/spring-boot-logback-example/build.gradle.kts @@ -1,10 +1,9 @@ plugins { - id("io.freefair.lombok") version "5.0.0" + id("io.freefair.lombok") version Version.lombok_gradle_plugin } dependencies { - implementation(platform("org.springframework.boot:spring-boot-dependencies:2.2.6.RELEASE")) - implementation(platform("org.apache.logging.log4j:log4j-bom:2.13.1")) + implementation(platform("org.springframework.boot:spring-boot-dependencies:${Version.spring}")) implementation(group = "org.springframework.boot", name = "spring-boot-starter-web") implementation(project(":compliance-logging-logback")) }