Skip to content

Commit 0600f96

Browse files
authored
Merge pull request #458 from fwcd/convention-plugins
Update to Gradle 8 and migrate to convention plugins
2 parents a10c947 + 4395b76 commit 0600f96

21 files changed

+76
-72
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
- name: Build
2727
run: ./gradlew :server:build :shared:build -PjavaVersion=${{ matrix.java }}
2828
- name: Detekt
29-
run: ./gradlew detekt
29+
run: ./gradlew detekt -PjavaVersion=${{ matrix.java }}

build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ tasks.register<DetektCreateBaselineTask>("createDetektBaseline") {
4141
baseline.set(file("$rootDir/detekt_baseline.xml"))
4242
include("**/*.kt")
4343
include("**/*.kts")
44-
exclude("shared/build/**/*.*")
45-
exclude("server/build/**/*.*")
46-
exclude("gradle/plugins/build/**/*.*")
44+
exclude("**/build/**")
4745
}
4846

4947
tasks.withType<Detekt>().configureEach {
5048
jvmTarget = JavaVersion.VERSION_11.toString()
49+
exclude("**/build/**")
5150
reports {
5251
html.required.set(true)
5352
md.required.set(true)

buildSrc/build.gradle.kts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.util.Properties
2+
import groovy.lang.MissingPropertyException
3+
4+
plugins {
5+
`kotlin-dsl`
6+
}
7+
8+
repositories {
9+
mavenCentral()
10+
gradlePluginPortal()
11+
}
12+
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+
}
27+
28+
kotlin {
29+
jvmToolchain(javaVersion.toInt())
30+
}
31+
32+
dependencies {
33+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
34+
}

buildSrc/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "build-conventions"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
kotlin("jvm")
3+
}
4+
5+
val javaVersion = property("javaVersion") as String
6+
7+
kotlin {
8+
jvmToolchain(javaVersion.toInt())
9+
}

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

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version=1.3.2
2+
javaVersion=11

gradle/plugins/kotlin-plugins/build.gradle.kts

Lines changed: 0 additions & 7 deletions
This file was deleted.

gradle/plugins/settings.gradle.kts

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)