Skip to content

Commit 6a45851

Browse files
authored
Gradle cleanup (#59)
* Fail on warnings * Move versions to toml * Move repositories to settings * Lazy build * Remove unnecessary-looking deps
1 parent 6dbe818 commit 6a45851

File tree

5 files changed

+76
-39
lines changed

5 files changed

+76
-39
lines changed

build.gradle.kts

+22-39
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,52 @@
11
plugins {
2-
id("org.jetbrains.kotlin.jvm") version "1.7.20"
3-
}
4-
5-
repositories {
6-
mavenCentral()
2+
@Suppress("DSL_SCOPE_VIOLATION")
3+
alias(libs.plugins.kotlin)
74
}
85

96
dependencies {
10-
implementation("org.jetbrains.kotlin:kotlin-stdlib")
11-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
12-
implementation("org.jetbrains.kotlin:kotlin-reflect")
13-
implementation("org.seleniumhq.selenium:selenium-java:4.5.0")
14-
implementation("io.github.bonigarcia:webdrivermanager:5.3.0")
15-
// TODEL when upgrading webdrivermanager Listed because they have vulnerabilities.
16-
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.4")
17-
implementation("commons-io:commons-io:2.11.0")
18-
implementation("org.bouncycastle:bcprov-jdk15on:1.70")
7+
implementation(libs.kotlin.stdlib8)
8+
implementation(libs.kotlin.reflect)
199

20-
val log4jVersion = "2.19.0"
21-
implementation("org.apache.logging.log4j:log4j-iostreams:$log4jVersion")
22-
implementation("org.assertj:assertj-core:3.23.1")
10+
implementation(libs.selenium)
11+
implementation(libs.webdrivermanager)
2312

24-
val junitVersion = "5.9.1"
25-
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
26-
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
27-
28-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
29-
testRuntimeOnly("org.junit.platform:junit-platform-console:1.9.1")
30-
testRuntimeOnly("org.slf4j:jul-to-slf4j:2.0.3")
31-
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl:$log4jVersion")
32-
testRuntimeOnly("org.apache.logging.log4j:log4j-core:$log4jVersion")
33-
}
13+
implementation(libs.log4j.iostreams)
14+
implementation(libs.assertj)
3415

35-
val javaVersion = JavaVersion.VERSION_1_8
16+
testImplementation(libs.junit.api)
17+
testImplementation(libs.junit.params)
18+
testRuntimeOnly(libs.junit.engine)
3619

37-
java {
38-
sourceCompatibility = javaVersion
39-
targetCompatibility = javaVersion
20+
testRuntimeOnly(libs.log4j)
21+
testRuntimeOnly(libs.log4j.slf4j)
22+
testRuntimeOnly(libs.slf4j.jul)
4023
}
4124

42-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
25+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
4326
kotlinOptions {
4427
verbose = true
45-
jvmTarget = javaVersion.toString()
28+
jvmTarget = libs.versions.java.get()
4629
allWarningsAsErrors = true
4730
}
4831
}
4932

5033
// Configure JUnit 5
51-
tasks.withType<Test> {
34+
tasks.withType<Test>().configureEach {
5235
useJUnitPlatform {
5336
}
5437
}
5538

5639
// Configure Console logging
57-
tasks.withType<Test> {
40+
tasks.withType<Test>().configureEach {
5841
testLogging {
5942
events("passed", "skipped", "failed")
6043
}
6144
}
6245

6346
// Configure logging
64-
tasks.withType<Test> {
47+
tasks.withType<Test>().configureEach {
6548
jvmArgs(
66-
"-Djava.util.logging.config.file=${rootProject.file("config/logging.properties")}"
49+
"-Djava.util.logging.config.file=${rootProject.file("config/jul.properties")}"
6750
)
6851
}
6952
project.tasks {
@@ -78,13 +61,13 @@ project.tasks {
7861
from(rootProject.file("config/log4j2.xml"))
7962
into(java.sourceSets["test"].resources.srcDirs.first())
8063
}
81-
"processTestResources"{
64+
"processTestResources" {
8265
dependsOn(copyLoggingTestResources)
8366
}
8467
}
8568

8669
// Configure global test parameters.
87-
tasks.withType<Test> {
70+
tasks.withType<Test>().configureEach {
8871
val propertyNamesToExposeToJUnitTests = listOf(
8972
"net.twisterrob.test.selenium.headless"
9073
)

config/logging.properties renamed to config/jul.properties

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# suppress inspection "UnusedProperty" for whole file
2+
13
# JUL configuration file override. JUnit 5 uses JUL, Selenium uses JUL.
24
# Use it with -Djava.util.logging.config.file=...
35

gradle.properties

+7
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1+
org.gradle.caching=true
2+
org.gradle.parallel=true
3+
org.gradle.configureondemand=true
4+
org.gradle.warning.mode=fail
5+
6+
kotlin.stdlib.default.dependency=false
7+
18
net.twisterrob.test.selenium.headless=false

gradle/libs.versions.toml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[versions]
2+
java = "1.8"
3+
kotlin = "1.7.20"
4+
5+
selenium = "4.5.0"
6+
webdrivermanager = "5.3.0"
7+
8+
slf4j = "2.0.3"
9+
log4j = "2.19.0"
10+
11+
junit = "5.9.1"
12+
assertj = "3.23.1"
13+
14+
[libraries]
15+
kotlin-pom = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
16+
kotlin-stdlib8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
17+
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
18+
19+
selenium = { module = "org.seleniumhq.selenium:selenium-java", version.ref = "selenium" }
20+
webdrivermanager = { module = "io.github.bonigarcia:webdrivermanager", version.ref = "webdrivermanager" }
21+
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
22+
23+
junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
24+
junit-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" }
25+
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
26+
27+
log4j = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
28+
log4j-slf4j = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version.ref = "log4j" }
29+
log4j-iostreams = { module = "org.apache.logging.log4j:log4j-iostreams", version.ref = "log4j" }
30+
31+
slf4j-jul = { module = "org.slf4j:jul-to-slf4j", version.ref = "slf4j" }
32+
33+
[bundles]
34+
35+
[plugins]
36+
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

settings.gradle.kts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
rootProject.name = "net-twisterrob-healthcheck"
2+
3+
@Suppress("UnstableApiUsage")
4+
dependencyResolutionManagement {
5+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
6+
repositories {
7+
mavenCentral()
8+
}
9+
}

0 commit comments

Comments
 (0)