Skip to content

Commit 1a2b157

Browse files
committed
Load default Java version in buildSrc/build.gradle.kts
1 parent 41f65c4 commit 1a2b157

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

buildSrc/build.gradle.kts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import java.util.Properties
2+
import groovy.lang.MissingPropertyException
3+
14
plugins {
25
`kotlin-dsl`
36
}
@@ -7,10 +10,23 @@ repositories {
710
gradlePluginPortal()
811
}
912

10-
// Use JDK 11 for compiling the convention plugins (this is NOT the project!)
13+
// Use the same Java version for compiling the convention plugins as for the main project
14+
// For this we need to manually load the gradle.properties, since variables from the main
15+
// project are generally not visible from buildSrc.
16+
17+
val javaVersionProperty = "javaVersion"
18+
val javaVersion = try {
19+
project.property(javaVersionProperty) as String
20+
} catch (e: MissingPropertyException) {
21+
Properties().also { properties ->
22+
File("$rootDir/../gradle.properties").inputStream().use { stream ->
23+
properties.load(stream)
24+
}
25+
}[javaVersionProperty] as String
26+
}
1127

1228
kotlin {
13-
jvmToolchain(11)
29+
jvmToolchain(javaVersion.toInt())
1430
}
1531

1632
dependencies {

detekt.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
config:
22
validation: true # verifies that this config file is valid
33
warningsAsErrors: false
4+
5+
exceptions:
6+
SwallowedException:
7+
ignoredExceptionTypes:
8+
- InterruptedException
9+
- MalformedURLException
10+
- NumberFormatException
11+
- ParseException
12+
- MissingPropertyException

server/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import groovy.lang.MissingPropertyException
2-
31
plugins {
42
kotlin("jvm")
53
id("maven-publish")

shared/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import groovy.lang.MissingPropertyException
2-
31
plugins {
42
id("maven-publish")
53
kotlin("jvm")

0 commit comments

Comments
 (0)