Skip to content

Commit

Permalink
Add Convention Plugins for Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Nov 6, 2024
1 parent aace0f2 commit 20784c9
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ dependencies {
implementation(projects.tatooine)
implementation(libs.guice)
implementation(libs.guice.servlet)
implementation(libs.kotlin.stdlib)
implementation(libs.slf4j.api)
runtimeOnly(libs.slf4j.simple)
providedCompile(libs.jakarta.servlet.api)

mockApiApi(libs.guava)
mockApiImplementation(projects.app)
mockApiImplementation(libs.guava)

testImplementation(libs.junit.jupiter.api)

testEndToEndApi(libs.junit.jupiter.api)
testEndToEndImplementation(projects.app) { capabilities { requireFeature("mock-api") } }
testEndToEndImplementation(libs.guava)
testEndToEndImplementation(libs.junit.jupiter.api)
}
1 change: 1 addition & 0 deletions bespin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins { id("org.example.gradle.component.library") }

dependencies {
api(projects.corellia)
api(libs.kotlin.stdlib)
implementation(projects.coruscant)
implementation(libs.velocity.engine.core)

Expand Down
1 change: 1 addition & 0 deletions corellia/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
}

dependencies {
api(libs.kotlin.stdlib)
api(libs.poi)
implementation(libs.commons.io)
implementation(libs.poi.ooxml)
Expand Down
1 change: 1 addition & 0 deletions coruscant/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies {
api(libs.jackson.annotations)
api(libs.jackson.databind)
api(libs.jakarta.inject.api)
api(libs.kotlin.stdlib)
api(libs.opensaml)
api(libs.org.json)
implementation(libs.httpcomponents.fluent.hc)
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ org.gradle.configuration-cache=true

# activate Gradle build cache - switch between branches/commits without rebuilding every time
org.gradle.caching=true

# control Kotlin standard library dependencies (and their scope) ourselves
kotlin.stdlib.default.dependency=false
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jakarta-mail-impl = { module = "com.sun.mail:jakarta.mail", version.ref = "jakar
jakarta-servlet-api = { module = "jakarta.servlet:jakarta.servlet-api", version.ref = "jakarta-servlet" }
jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" }
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
opensaml = { module = "org.opensaml:opensaml", version.ref = "opensaml" }
org-json = { module = "org.json:json", version.ref = "org-json" }
org-reflections = { module = "org.reflections:reflections", version.ref = "org-reflections" }
Expand Down
1 change: 1 addition & 0 deletions gradle/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
implementation("io.fuchs.gradle.classpath-collision-detector:classpath-collision-detector:1.0.0")
implementation("org.cyclonedx:cyclonedx-gradle-plugin:1.10.0")
implementation("org.gradlex:jvm-dependency-conflict-resolution:2.1.2")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.20")
}

testing.suites.named<JvmTestSuite>("test") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins { id("org.gradle.base") }

// Set the group required to refer to a Module "from outside".
// I.e., when it is published or used in Included Builds.
group = "org.example.product.java"
group = "org.example.product.kotlin"

// Set the version from 'version.txt'
version = providers.fileContents(isolated.rootProject.projectDirectory.file("gradle/version.txt")).asText.getOrElse("")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugins {
id("com.diffplug.spotless")
id("org.example.gradle.base.lifecycle")
}

spotless { kotlin { ktfmt().kotlinlangStyle() } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ plugins {
id("org.example.gradle.check.dependencies")
id("org.example.gradle.check.format-gradle")
id("org.example.gradle.check.format-java")
id("org.example.gradle.check.format-kotlin")
id("org.example.gradle.feature.checksum")
id("org.example.gradle.feature.compile-java")
id("org.example.gradle.feature.compile-kotlin")
id("org.example.gradle.feature.javadoc")
id("org.example.gradle.feature.test")
id("org.example.gradle.feature.test-end-to-end")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ plugins {
id("org.example.gradle.check.dependencies")
id("org.example.gradle.check.format-gradle")
id("org.example.gradle.check.format-java")
id("org.example.gradle.check.format-kotlin")
id("org.example.gradle.feature.compile-java")
id("org.example.gradle.feature.compile-kotlin")
id("org.example.gradle.feature.javadoc")
id("org.example.gradle.feature.test")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import org.gradle.jvm.toolchain.JavaLanguageVersion

plugins {
id("org.jetbrains.kotlin.jvm")
id("org.example.gradle.base.lifecycle")
}

kotlin {
jvmToolchain {
languageVersion =
JavaLanguageVersion.of(
providers
.fileContents(isolated.rootProject.projectDirectory.file("gradle/jdk-version.txt"))
.asText
.get()
.trim()
)
}
}
1 change: 1 addition & 0 deletions kamino/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {

dependencies {
api(projects.coruscant)
api(libs.kotlin.stdlib)
api(libs.resteasy.core)
implementation(libs.resteasy.guice)
implementation(libs.resteasy.jackson2.provider)
Expand Down
1 change: 1 addition & 0 deletions kashyyyk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins { id("org.example.gradle.component.library") }
dependencies {
api(projects.naboo)
api(projects.tatooine)
api(libs.kotlin.stdlib)
implementation(projects.bespin)
implementation(projects.kamino)

Expand Down
1 change: 1 addition & 0 deletions naboo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins { id("org.example.gradle.component.library") }

dependencies {
api(libs.kotlin.stdlib)
implementation(libs.solr.solrj)
implementation(libs.zookeeper.jute)

Expand Down
1 change: 1 addition & 0 deletions tatooine/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins { id("org.example.gradle.component.library") }

dependencies {
api(libs.kotlin.stdlib)
api(libs.typesafeconfig.guice)
implementation(libs.zookeeper)

Expand Down

0 comments on commit 20784c9

Please sign in to comment.