Skip to content

Commit 289145e

Browse files
committed
Refactor Gradle build and publishing configurations
Consolidated Kotlin and publishing conventions into reusable Gradle scripts in `buildSrc`. Removed redundant scripts and updated workflows to align with the new configuration structure. Simplified dependency declarations and standardized plugin usage across modules.
1 parent a374e89 commit 289145e

File tree

11 files changed

+118
-165
lines changed

11 files changed

+118
-165
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ max_line_length = 120
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
1111

12-
[*.gradle.kts]
13-
indent_size = 3
12+
[{*.yml,yaml}]
13+
indent_size = 2

.github/workflows/main.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
- name: run tests
2323
run: ./gradlew test
2424

25-
- name: deploy snapshot
26-
run: ./gradlew publish
25+
- name: deploy to sonatype snapshots
26+
run: ./gradlew publishToMavenCentral
2727

2828
- name: bundle the build report
2929
if: failure()
@@ -38,5 +38,7 @@ jobs:
3838

3939
env:
4040
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
41-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
42-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
41+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
42+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
43+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
44+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
- name: Setup JDK
2626
uses: actions/setup-java@v4
2727
with:
28-
distribution: 'adopt'
29-
java-version: '11'
28+
distribution: 'adopt'
29+
java-version: '11'
3030

3131
- name: deploy to sonatype
3232
run: ./gradlew publish
@@ -39,7 +39,7 @@ jobs:
3939
env:
4040
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
4141
RELEASE_VERSION: ${{ github.event.inputs.version }}
42-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
43-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
44-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
45-
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
42+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
43+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
44+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
45+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}

aedile-core/build.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
plugins {
2+
id("kotlin-conventions")
3+
id("publishing-conventions")
4+
}
5+
16
dependencies {
27
api(libs.caffeine)
8+
api(rootProject.libs.coroutines.core)
9+
api(rootProject.libs.coroutines.jdk8)
310
}
4-
5-
apply("../publish.gradle.kts")

aedile-micrometer/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
plugins {
2+
id("kotlin-conventions")
3+
id("publishing-conventions")
4+
}
5+
16
dependencies {
27
api(projects.aedileCore)
38
api(libs.micrometer.core)
49
}
5-
6-
apply("../publish.gradle.kts")

build.gradle.kts

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

buildSrc/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ repositories {
77
plugins {
88
`kotlin-dsl`
99
}
10+
11+
dependencies {
12+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.21")
13+
implementation("com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.34.0")
14+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
import org.gradle.api.tasks.testing.logging.TestLogEvent
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
5+
6+
plugins {
7+
`java-library`
8+
kotlin("jvm")
9+
}
10+
11+
java {
12+
toolchain {
13+
languageVersion.set(JavaLanguageVersion.of(11))
14+
}
15+
sourceCompatibility = JavaVersion.VERSION_11
16+
targetCompatibility = JavaVersion.VERSION_11
17+
}
18+
19+
kotlin {
20+
compilerOptions {
21+
jvmTarget.set(JvmTarget.JVM_11)
22+
apiVersion.set(KotlinVersion.KOTLIN_1_9)
23+
languageVersion.set(KotlinVersion.KOTLIN_1_9)
24+
}
25+
}
26+
27+
dependencies {
28+
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:2.1.21")
29+
testImplementation("io.kotest:kotest-runner-junit5:5.9.1")
30+
testImplementation("io.kotest:kotest-assertions-core:5.9.1")
31+
testImplementation("io.kotest:kotest-assertions-json:5.9.1")
32+
testImplementation("io.kotest:kotest-framework-datatest:5.9.1")
33+
testImplementation("io.kotest:kotest-property:5.9.1")
34+
}
35+
36+
tasks.named<Test>("test") {
37+
useJUnitPlatform()
38+
filter {
39+
isFailOnNoMatchingTests = false
40+
}
41+
testLogging {
42+
showExceptions = true
43+
showStandardStreams = true
44+
events = setOf(
45+
TestLogEvent.FAILED,
46+
TestLogEvent.PASSED
47+
)
48+
exceptionFormat = TestExceptionFormat.FULL
49+
}
50+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
plugins {
2+
id("com.vanniktech.maven.publish")
3+
}
4+
5+
group = "com.sksamuel.aedile"
6+
version = Ci.version
7+
8+
mavenPublishing {
9+
publishToMavenCentral(automaticRelease = true)
10+
signAllPublications()
11+
pom {
12+
name.set("aedile")
13+
description.set("Kotlin Wrapper for Caffeine")
14+
url.set("http://www.github.com/sksamuel/aedile")
15+
16+
scm {
17+
connection.set("scm:git:http://www.github.com/sksamuel/aedile/")
18+
developerConnection.set("scm:git:http://github.com/sksamuel/")
19+
url.set("http://www.github.com/sksamuel/aedile/")
20+
}
21+
22+
licenses {
23+
license {
24+
name.set("The Apache 2.0 License")
25+
url.set("https://opensource.org/licenses/Apache-2.0")
26+
}
27+
}
28+
29+
developers {
30+
developer {
31+
id.set("sksamuel")
32+
name.set("Stephen Samuel")
33+
email.set("sam@sksamuel.com")
34+
}
35+
}
36+
}
37+
}

publish.gradle.kts

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

0 commit comments

Comments
 (0)