Skip to content

Commit e67ace2

Browse files
Merge pull request #5 from flock-community/structure-gradle-project
chore: structure gradle project with version catalog and root plugins
2 parents bdd62bb + 5288ef0 commit e67ace2

File tree

18 files changed

+391
-270
lines changed

18 files changed

+391
-270
lines changed

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: *
2+
3+
# The first command will be invoked with `make` only and should be `all`
4+
all: clean build
5+
6+
build:
7+
./gradlew build
8+
9+
clean:
10+
./gradlew clean
11+
12+
compile:
13+
./gradlew assemble
14+
15+
format:
16+
./gradlew spotlessApply
17+
18+
publish:
19+
./gradlew publish

build.gradle.kts

Lines changed: 11 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
plugins {
2-
id("maven-publish")
3-
id("signing")
4-
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
5-
kotlin("multiplatform") version "1.9.25"
6-
kotlin("plugin.serialization") version "1.5.21"
2+
id("module.publication")
3+
id("module.spotless")
4+
alias(libs.plugins.kotest.multiplatform)
5+
alias(libs.plugins.kotlin.multiplatform)
6+
alias(libs.plugins.kotlinx.serialization)
77
}
88

9-
group = "community.flock.kotlinx.openapi.bindings"
10-
version = "0.1.3"
9+
group = libs.versions.group.id.get()
10+
version = System.getenv(libs.versions.from.env.get()) ?: libs.versions.default.get()
1111

1212
repositories {
1313
mavenCentral()
@@ -26,84 +26,21 @@ kotlin {
2626
withJava()
2727
java {
2828
toolchain {
29-
languageVersion.set(JavaLanguageVersion.of(17))
29+
languageVersion.set(JavaLanguageVersion.of(libs.versions.java.get()))
3030
}
3131
}
3232
}
3333
}
3434
sourceSets {
3535
commonMain {
3636
dependencies {
37-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
37+
implementation(libs.kotlinx.serialization)
3838
}
3939
}
4040
commonTest {
4141
dependencies {
42-
implementation(kotlin("test-common"))
43-
implementation(kotlin("test-annotations-common"))
44-
implementation(kotlin("test-junit"))
45-
implementation("io.kotest:kotest-framework-engine:5.6.1")
46-
implementation("io.kotest:kotest-assertions-core:5.6.1")
47-
implementation("io.kotest:kotest-assertions-json:5.6.1")
48-
}
49-
}
50-
}
51-
}
52-
53-
nexusPublishing {
54-
repositories {
55-
sonatype {
56-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
57-
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
58-
username.set(System.getenv("SONATYPE_USERNAME"))
59-
password.set(System.getenv("SONATYPE_PASSWORD"))
60-
stagingProfileId.set(System.getenv("SONATYPE_STAGING_PROFILE_ID"))
61-
}
62-
}
63-
}
64-
65-
signing {
66-
setRequired { System.getenv("GPG_PRIVATE_KEY") != null }
67-
useInMemoryPgpKeys(
68-
System.getenv("GPG_PRIVATE_KEY"),
69-
System.getenv("GPG_PASSPHRASE"),
70-
)
71-
sign(publishing.publications)
72-
}
73-
74-
publishing {
75-
publications {
76-
withType<MavenPublication> {
77-
artifact(
78-
tasks.register("${name}JavadocJar", Jar::class) {
79-
archiveClassifier.set("javadoc")
80-
archiveAppendix.set(this@withType.name)
81-
},
82-
)
83-
pom {
84-
name.set("Flock. community")
85-
description.set("Kotlin openapi bindings")
86-
licenses {
87-
license {
88-
name.set("MIT")
89-
url.set("https://opensource.org/licenses/MIT")
90-
}
91-
}
92-
url.set("https://flock.community")
93-
issueManagement {
94-
system.set("Github")
95-
url.set("https://github.com/flock-community/kotlin-openapi-bindings/issues")
96-
}
97-
scm {
98-
connection.set("https://github.com/flock-community/kotlin-openapi-bindings.git")
99-
url.set("https://github.com/flock-community/kotlin-openapi-bindings")
100-
}
101-
developers {
102-
developer {
103-
name.set("Willem Veelenturf")
104-
email.set("[email protected]")
105-
}
106-
}
42+
implementation(libs.bundles.kotlin.test)
43+
implementation(libs.bundles.kotest)
10744
}
10845
}
10946
}

gradle/libs.versions.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[versions]
2+
default = "0.1.4"
3+
from_env = "VERSION"
4+
group_id = "community.flock.kotlinx.openapi.bindings"
5+
java = "17"
6+
kotest = "5.9.1"
7+
kotlin = "1.9.25"
8+
kotlinx_serialization = "1.5.0"
9+
nexus-publish = "2.0.0"
10+
spotless = "7.0.4"
11+
12+
[libraries]
13+
nexus_publish = { module = "io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin", version.ref = "nexus-publish" }
14+
kotest_assertions = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
15+
kotest_assertions_json = { module = "io.kotest:kotest-assertions-json", version.ref = "kotest" }
16+
kotlin_test_common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" }
17+
kotlin_test_annotations_common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" }
18+
kotlin_test_junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
19+
kotlinx_serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx_serialization" }
20+
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }
21+
22+
[bundles]
23+
kotlin_test = ["kotlin_test_common", "kotlin_test_annotations_common", "kotlin_test_junit"]
24+
kotest = [ "kotest_assertions", "kotest_assertions_json"]
25+
26+
[plugins]
27+
kotest_multiplatform = { id ="io.kotest.multiplatform", version.ref = "kotest" }
28+
kotlin_multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
29+
kotlinx_serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
dependencies {
6+
implementation(libs.nexus.publish)
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
apply(from = "../shared-settings.gradle.kts")
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import org.gradle.api.publish.maven.MavenPublication
2+
import org.gradle.api.tasks.bundling.Jar
3+
import org.gradle.kotlin.dsl.`maven-publish`
4+
5+
plugins {
6+
`maven-publish`
7+
signing
8+
id("io.github.gradle-nexus.publish-plugin")
9+
}
10+
11+
nexusPublishing {
12+
repositories {
13+
sonatype {
14+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
15+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
16+
username.set(System.getenv("SONATYPE_USERNAME"))
17+
password.set(System.getenv("SONATYPE_PASSWORD"))
18+
stagingProfileId.set(System.getenv("SONATYPE_STAGING_PROFILE_ID"))
19+
}
20+
}
21+
}
22+
23+
publishing {
24+
publications {
25+
withType<MavenPublication> {
26+
artifact(
27+
tasks.register("${name}JavadocJar", Jar::class) {
28+
archiveClassifier.set("javadoc")
29+
archiveAppendix.set(this@withType.name)
30+
},
31+
)
32+
pom {
33+
name.set("Flock. community")
34+
description.set("Kotlin openapi bindings")
35+
licenses {
36+
license {
37+
name.set("MIT")
38+
url.set("https://opensource.org/licenses/MIT")
39+
}
40+
}
41+
url.set("https://flock.community")
42+
issueManagement {
43+
system.set("Github")
44+
url.set("https://github.com/flock-community/kotlin-openapi-bindings/issues")
45+
}
46+
scm {
47+
connection.set("https://github.com/flock-community/kotlin-openapi-bindings.git")
48+
url.set("https://github.com/flock-community/kotlin-openapi-bindings")
49+
}
50+
developers {
51+
developer {
52+
name.set("Willem Veelenturf")
53+
email.set("[email protected]")
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
61+
signing {
62+
setRequired { System.getenv("GPG_PRIVATE_KEY") != null }
63+
useInMemoryPgpKeys(
64+
System.getenv("GPG_PRIVATE_KEY"),
65+
System.getenv("GPG_PASSPHRASE"),
66+
)
67+
sign(publishing.publications)
68+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
pluginManagement {
2+
repositories {
3+
gradlePluginPortal()
4+
mavenCentral()
5+
mavenLocal()
6+
}
7+
}
8+
9+
dependencyResolutionManagement {
10+
repositories {
11+
gradlePluginPortal()
12+
mavenCentral()
13+
mavenLocal()
14+
}
15+
16+
versionCatalogs {
17+
create("libs") {
18+
from(files("../libs.versions.toml"))
19+
}
20+
}
21+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
dependencies {
6+
implementation(libs.spotless)
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
apply(from = "../shared-settings.gradle.kts")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
plugins {
2+
id("com.diffplug.spotless")
3+
}
4+
5+
spotless {
6+
val exclude = listOf(
7+
"**/build/**",
8+
"**/generated/**",
9+
"**/generated-sources/**",
10+
"**/resources/**",
11+
).toTypedArray()
12+
13+
kotlin {
14+
target("**/*.kt", "**/*.kts")
15+
targetExclude(*exclude)
16+
ktlint().editorConfigOverride(
17+
mapOf("ktlint_code_style" to "intellij_idea"),
18+
)
19+
suppressLintsFor {
20+
step = "ktlint"
21+
shortCode = "standard:enum-entry-name-case"
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)