Skip to content

Commit 9a5414a

Browse files
committed
chore: new central publishing
1 parent c11e664 commit 9a5414a

File tree

10 files changed

+74
-77
lines changed

10 files changed

+74
-77
lines changed

backend/jvm/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import kotlin.io.path.Path
44

55
plugins {
66
plugins.kotlin.jvm
7-
plugins.publishing
87
application
98
alias(libs.plugins.ktor)
109
alias(libs.plugins.exposed)
1110
com.google.cloud.tools.jib
1211
gg.jte.gradle
12+
plugins.publishing
1313
}
1414

1515
description = "Ktor backend jvm application"

gradle/build-logic/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ dependencies {
155155
implementation(libs.build.kotlin)
156156
// OR implementation(kotlin("gradle-plugin"))
157157
implementation(libs.build.kotlin.ksp)
158-
implementation(libs.build.powerassert)
159158
implementation(libs.build.kotlinx.atomicfu)
160159
implementation(libs.build.kotlin.allopen)
161160
implementation(libs.build.kotlinx.serialization)
@@ -166,6 +165,7 @@ dependencies {
166165
implementation(libs.build.dokka.base)
167166
implementation(libs.build.redacted.plugin)
168167
implementation(libs.build.gradle.enterprise)
168+
implementation(libs.build.nmcp.plugin)
169169
implementation(libs.build.nexus.plugin)
170170
implementation(libs.build.spotless.plugin)
171171
implementation(libs.build.shadow.plugin)
@@ -176,8 +176,6 @@ dependencies {
176176
implementation(libs.build.foojay.resolver)
177177
implementation(libs.build.nativeimage.plugin)
178178
implementation(libs.build.modulegraph.plugin)
179-
implementation(libs.build.cash.molecule.plugin)
180-
implementation(libs.build.npm.publish.plugin)
181179
implementation(libs.build.mokkery.plugin)
182180
implementation(libs.build.jte.plugin)
183181
// implementation(libs.jte.native)

gradle/build-logic/src/main/kotlin/common/ProjectExtns.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ val Project.isKotlinJvmProject
112112
val Project.isKotlinJsProject
113113
get() = plugins.hasPlugin("org.jetbrains.kotlin.js")
114114

115+
val Project.isRootProject
116+
get() = this == rootProject
117+
115118
val Project.githubUser
116119
get() = libs.versions.dev.name.get().lowercase()
117120

@@ -154,6 +157,7 @@ fun Project.jvmArguments(appRun: Boolean = false, headless: Boolean = true) = bu
154157
"-XX:+UseStringDeduplication",
155158
"-XX:+UnlockExperimentalVMOptions",
156159
"-XX:MaxRAMPercentage=0.8",
160+
"-XX:LockingMode=2",
157161
// "-XX:+UseEpsilonGC",
158162
// "-XX:+AlwaysPreTouch",
159163
// os+thread,gc+heap=trace,
@@ -340,7 +344,6 @@ fun KotlinCommonCompilerOptions.configureKotlinCommon() {
340344
buildList {
341345
add("-Xcontext-receivers")
342346
add("-Xexpect-actual-classes")
343-
add("-Xallow-result-return-type")
344347
if (composeReportsEnabled) {
345348
val reportPath = layout.buildDirectory.dir("compose_compiler").get().asFile.absolutePath
346349
add("-P")
@@ -388,7 +391,6 @@ fun KotlinJvmCompilerOptions.configureKotlinJvm() {
388391
"-Xjvm-default=all",
389392
"-Xassertions=jvm",
390393
"-Xcontext-receivers",
391-
"-Xallow-result-return-type",
392394
"-Xemit-jvm-type-annotations",
393395
"-Xjspecify-annotations=strict",
394396
"-Xextended-compiler-checks",

gradle/build-logic/src/main/kotlin/common/Repo.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ object Repo {
1616

1717
const val KOBWEB = "https://us-central1-maven.pkg.dev/varabyte-repos/public"
1818

19+
/** For publishing to [Maven Central](https://central.sonatype.com/account) */
20+
val MAVEN_CENTRAL_USER = System.getenv("MAVEN_CENTRAL_USER").orEmpty()
21+
22+
val MAVEN_CENTRAL_PASSWORD = System.getenv("MAVEN_CENTRAL_PASSWORD").orEmpty()
23+
1924
/** The GitHub username */
2025
val GITHUB_USER = System.getenv("GITHUB_USER").orEmpty()
2126

gradle/build-logic/src/main/kotlin/plugins/kotlin.benchmark.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ plugins {
1818
`kotlin-allopen`
1919
}
2020

21+
group = libs.versions.group.get()
22+
2123
description = "Kotlin benchmarking tests"
2224

2325
allOpen { annotation("org.openjdk.jmh.annotations.State") }
@@ -27,6 +29,7 @@ benchmark {
2729
register("jvm") { configureJmh() }
2830
// register("desktop") { configureJmh() }
2931
// register("js")
32+
// register("wasmJs")
3033
}
3134

3235
configurations {

gradle/build-logic/src/main/kotlin/plugins/kotlin.docs.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins {
1818
}
1919

2020
// The following plugins and config apply only to a root project.
21-
if (project == rootProject) {
21+
if (isRootProject) {
2222
apply(plugin = "org.hildan.github.changelog")
2323
apply(plugin = "org.jetbrains.kotlinx.binary-compatibility-validator")
2424

gradle/build-logic/src/main/kotlin/plugins/kotlin.jvm.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ plugins {
1515
`kotlinx-serialization`
1616
`kotlinx-atomicfu`
1717
dev.zacsweers.redacted
18-
// kotlin("plugin.power-assert")
19-
// com.bnorm.power.`kotlin-power-assert`
2018
id("plugins.kotlin.docs")
19+
// kotlin("plugin.power-assert")
2120
// `test-suite-base`
2221
}
2322

@@ -68,7 +67,10 @@ ksp {
6867

6968
// powerAssert { functions = listOf("kotlin.require", "kotlin.check") }
7069

71-
redacted { replacementString = "" }
70+
redacted {
71+
enabled = true
72+
replacementString = ""
73+
}
7274

7375
kover {
7476
// useJacoco()

gradle/build-logic/src/main/kotlin/plugins/kotlin.mpp.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ plugins {
1919
com.google.devtools.ksp
2020
`kotlinx-atomicfu`
2121
dev.zacsweers.redacted
22-
// kotlin("plugin.power-assert")
23-
// com.bnorm.power.`kotlin-power-assert`
2422
id("plugins.kotlin.docs")
23+
// kotlin("plugin.power-assert")
2524
// org.gradle.kotlin.`kotlin-dsl`
2625
// app.cash.molecule
2726
// dev.mokkery
@@ -70,7 +69,10 @@ atomicfu {
7069

7170
// powerAssert { functions = listOf("kotlin.require", "kotlin.check") }
7271

73-
redacted { replacementString = "" }
72+
redacted {
73+
enabled = true
74+
replacementString = ""
75+
}
7476

7577
kover {
7678
// useJacoco()

gradle/build-logic/src/main/kotlin/plugins/publishing.gradle.kts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package plugins
22

3-
import common.Repo
4-
import common.githubRepo
3+
import common.*
54
import common.libs
65

76
plugins {
87
`maven-publish`
98
signing
9+
com.gradleup.nmcp
1010
// org.cyclonedx.bom
1111
}
1212

1313
// Nexus plugin needs to apply to the root project only
14-
if (project == rootProject) {
14+
if (isRootProject) {
1515
apply(plugin = "io.github.gradle-nexus.publish-plugin")
1616
}
1717

@@ -30,6 +30,18 @@ signing {
3030
sign(publishing.publications)
3131
}
3232

33+
nmcp {
34+
when (isRootProject) {
35+
true ->
36+
publishAggregation {
37+
username = findProperty("mavenCentralUser")?.toString() ?: Repo.MAVEN_CENTRAL_USER
38+
password = findProperty("mavenCentralPassword")?.toString() ?: Repo.MAVEN_CENTRAL_PASSWORD
39+
publicationType = "USER_MANAGED"
40+
}
41+
else -> publishAllPublications {}
42+
}
43+
}
44+
3345
publishing {
3446
repositories {
3547
maven {
@@ -71,11 +83,12 @@ publishing {
7183
configurePom()
7284
}
7385

74-
// 2. Add executable jar as an artifact
75-
if (project == rootProject) {
76-
withType<MavenPublication>().configureEach {
77-
// artifact(tasks.buildExecutable)
78-
}
86+
// Add an executable artifact if exists
87+
withType<MavenPublication>().configureEach {
88+
// val execJar = tasks.findByName("buildExecutable") as? ReallyExecJar
89+
// if (execJar != null) {
90+
// artifact(execJar.execJarFile)
91+
// }
7992
}
8093
}
8194

0 commit comments

Comments
 (0)