diff options
author | 2023-04-08 23:22:02 +0200 | |
---|---|---|
committer | 2023-04-08 23:22:02 +0200 | |
commit | 9c327a95dfa844f22f21fe99a8b45cace36567df (patch) | |
tree | 38841b46d86e184d9714a80e8a5fb8c650346e44 /buildSrc | |
parent | chore(deps): bump dependencies (diff) | |
download | refinery-9c327a95dfa844f22f21fe99a8b45cace36567df.tar.gz refinery-9c327a95dfa844f22f21fe99a8b45cace36567df.tar.zst refinery-9c327a95dfa844f22f21fe99a8b45cace36567df.zip |
build: always prefer slf4j instead of log4j 1.x
Make sure we get slf4j in every test source set and every application by
default. Saves configuration effort when creating a new library that tests
VIATRA or other dependencies that require log4j.
Diffstat (limited to 'buildSrc')
-rw-r--r-- | buildSrc/src/main/kotlin/refinery-java-application.gradle.kts | 14 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts | 7 |
2 files changed, 21 insertions, 0 deletions
diff --git a/buildSrc/src/main/kotlin/refinery-java-application.gradle.kts b/buildSrc/src/main/kotlin/refinery-java-application.gradle.kts index b3fab1fa..65409acf 100644 --- a/buildSrc/src/main/kotlin/refinery-java-application.gradle.kts +++ b/buildSrc/src/main/kotlin/refinery-java-application.gradle.kts | |||
@@ -1,3 +1,5 @@ | |||
1 | import org.gradle.accessors.dm.LibrariesForLibs | ||
2 | |||
1 | plugins { | 3 | plugins { |
2 | application | 4 | application |
3 | id("com.github.johnrengelman.shadow") | 5 | id("com.github.johnrengelman.shadow") |
@@ -5,6 +7,18 @@ plugins { | |||
5 | 7 | ||
6 | apply(plugin = "refinery-java-conventions") | 8 | apply(plugin = "refinery-java-conventions") |
7 | 9 | ||
10 | // Use log4j-over-slf4j instead of log4j 1.x when running the application. | ||
11 | configurations.named("runtimeClasspath") { | ||
12 | exclude(group = "log4j", module = "log4j") | ||
13 | } | ||
14 | |||
15 | val libs = the<LibrariesForLibs>() | ||
16 | |||
17 | dependencies { | ||
18 | implementation(libs.slf4j.simple) | ||
19 | implementation(libs.slf4j.log4j) | ||
20 | } | ||
21 | |||
8 | for (taskName in listOf("distTar", "distZip", "shadowDistTar", "shadowDistZip")) { | 22 | for (taskName in listOf("distTar", "distZip", "shadowDistTar", "shadowDistZip")) { |
9 | tasks.named(taskName) { | 23 | tasks.named(taskName) { |
10 | enabled = false | 24 | enabled = false |
diff --git a/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts b/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts index 2d5ce8b5..3f9b4208 100644 --- a/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts | |||
@@ -17,6 +17,11 @@ repositories { | |||
17 | } | 17 | } |
18 | } | 18 | } |
19 | 19 | ||
20 | // Use log4j-over-slf4j instead of log4j 1.x in the tests. | ||
21 | configurations.testRuntimeClasspath { | ||
22 | exclude(group = "log4j", module = "log4j") | ||
23 | } | ||
24 | |||
20 | val libs = the<LibrariesForLibs>() | 25 | val libs = the<LibrariesForLibs>() |
21 | 26 | ||
22 | dependencies { | 27 | dependencies { |
@@ -28,6 +33,8 @@ dependencies { | |||
28 | testImplementation(libs.junit.params) | 33 | testImplementation(libs.junit.params) |
29 | testImplementation(libs.mockito.core) | 34 | testImplementation(libs.mockito.core) |
30 | testImplementation(libs.mockito.junit) | 35 | testImplementation(libs.mockito.junit) |
36 | testImplementation(libs.slf4j.simple) | ||
37 | testImplementation(libs.slf4j.log4j) | ||
31 | } | 38 | } |
32 | 39 | ||
33 | java.toolchain { | 40 | java.toolchain { |