Skip to content

Commit 1fd9807

Browse files
committed
Added artifacts validation
1 parent 832fe83 commit 1fd9807

24 files changed

+1399
-9
lines changed

.github/workflows/artifacts.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Verify Artifacts
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
verify-platforms-table:
11+
name: Run Verification
12+
runs-on: macos-latest
13+
steps:
14+
- name: Checkout Sources
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Gradle
20+
uses: gradle/actions/setup-gradle@v4
21+
22+
- name: Validate published artifacts
23+
run: chmod +x validatePublishedArtifacts.sh && ./validatePublishedArtifacts.sh -v

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
paths:
66
- 'docs/pages/**'
77
- '.github/workflows/**'
8+
types: [auto_merge_enabled]
89
workflow_dispatch:
910
inputs:
1011
build_id:

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ allprojects {
2121
version = rootProject.libs.versions.kotlinx.rpc.get()
2222
}
2323

24-
println("[Core] kotlinx.rpc project version: $version, Kotlin version: $kotlinVersion, Compiler: $kotlinCompiler")
24+
logger.lifecycle("[Core] kotlinx.rpc project version: $version, Kotlin version: $kotlinVersion, Compiler: $kotlinCompiler")
2525

2626
// If the prefix of the kPRC version is not Kotlin gradle plugin version – you have a problem :)
2727
// Probably some dependency brings kotlin with the later version.

compiler-plugin/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ allprojects {
2222
}
2323
}
2424

25-
println(
25+
logger.lifecycle(
2626
"[Compiler Plugin] kotlinx.rpc project version: $version, " +
2727
"Kotlin version: $kotlinLangVersion, " +
2828
"Compiler version: $kotlinCompilerVersion"
2929
)
3030

3131
whenForIde {
32-
println("[Compiler Plugin] For-ide project mode enabled")
32+
logger.lifecycle("[Compiler Plugin] For-ide project mode enabled")
3333
}

docs/environment.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ Before pushing, run (maybe separately):
153153
```
154154

155155
Beware, that `detekt` doesn't fail the build, but outputs messages into the console.
156-
Makes sense to run it separately. You can also see generated reports
156+
Makes sense to run it separately. You can also see generated reports
157+
158+
Also, artifact checks: `./validatePublishedArtifacts.sh -s`.
159+
See the [section](#tasks-to-know-about) below.
157160

158161
### How to work with the compiler plugin
159162

@@ -486,6 +489,11 @@ usually after Kotlin version update.
486489
- `clean` - everything
487490
- `cleanTest` - JVM test results
488491
- `cleanAllTests` - KMP test results
492+
- `validatePublishedArtifacts` task and more importantly `./validatePublishedArtifacts.sh` script.
493+
494+
They are used to validate published artifacts and ensure you didn't delete or published something accidentally.
495+
496+
Available options: `--dump` - update files, `-s` - no Gradle output except for errors, `-v` - verbose output.
489497

490498
## Other
491499

dokka-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010
group = "org.jetbrains.kotlinx"
1111
version = libs.versions.kotlinx.rpc.get()
1212

13-
println("[Dokka Plugin] kotlinx.rpc project version: $version, Kotlin version: ${libs.versions.kotlin.lang.get()}")
13+
logger.lifecycle("[Dokka Plugin] kotlinx.rpc project version: $version, Kotlin version: ${libs.versions.kotlin.lang.get()}")
1414

1515
kotlin {
1616
jvmToolchain(8)

gradle-conventions/src/main/kotlin/conventions-publishing.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.gradle.kotlin.dsl.registering
66
import util.*
77
import util.other.getSensitiveProperty
88
import util.other.isPublicModule
9+
import util.tasks.ValidatePublishedArtifactsTask
910

1011
val isGradlePlugin = project.name == "gradle-plugin"
1112
val publishingExtension = project.extensions.findByType<PublishingExtension>()
@@ -166,6 +167,10 @@ fun configureEmptyJavadocArtifact(): TaskProvider<Jar?> {
166167
}
167168

168169
fun MavenPublication.signPublicationIfKeyPresent() {
170+
if (gradle.startParameter.taskNames.contains(ValidatePublishedArtifactsTask.NAME)) {
171+
return
172+
}
173+
169174
val keyId = project.getSensitiveProperty("libs.sign.key.id")
170175
val signingKey = project.getSensitiveProperty("libs.sign.key.private")
171176
val signingKeyPassphrase = project.getSensitiveProperty("libs.sign.passphrase")

gradle-conventions/src/main/kotlin/conventions-root.gradle.kts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
import util.other.isPublicModule
56
import util.other.libs
7+
import util.other.maybeNamed
8+
import util.tasks.ValidatePublishedArtifactsTask
69
import util.tasks.configureNpm
710
import util.tasks.registerChangelogTask
811
import util.tasks.registerDumpPlatformTableTask
@@ -27,6 +30,17 @@ allprojects {
2730
plugins.apply("project-report")
2831
}
2932

33+
tasks.register<ValidatePublishedArtifactsTask>(ValidatePublishedArtifactsTask.NAME) {
34+
dependsOn(subprojects.filter { it.isPublicModule })
35+
}
36+
37+
// Remove then first Jvm Only public module is created
38+
val publishMavenPublicationToBuildRepoRepository = "publishMavenPublicationToBuildRepoRepository"
39+
tasks.maybeNamed(publishMavenPublicationToBuildRepoRepository)
40+
?: tasks.register(publishMavenPublicationToBuildRepoRepository) {
41+
group = PublishingPlugin.PUBLISH_TASK_GROUP
42+
}
43+
3044
dokka {
3145
val libVersion = libs.versions.kotlinx.rpc.get()
3246

@@ -84,7 +98,7 @@ registerDumpPlatformTableTask()
8498
registerVerifyPlatformTableTask()
8599
registerChangelogTask()
86100

87-
fun Project.forEachSubproject(action: (String, Path, Path) -> Unit) {
101+
fun Project.forEachIncludedProject(action: (String, Path, Path) -> Unit) {
88102
val globalRootDir: String by extra
89103
val root = Path.of(globalRootDir)
90104
val rootProperties = root.resolve("gradle.properties").readText()
@@ -100,7 +114,7 @@ fun Project.forEachSubproject(action: (String, Path, Path) -> Unit) {
100114
}
101115

102116
val updateProperties = tasks.register("updateProperties") {
103-
forEachSubproject { rootProperties, _, subProjectProperties ->
117+
forEachIncludedProject { rootProperties, _, subProjectProperties ->
104118
if (!subProjectProperties.exists()) {
105119
subProjectProperties.createFile()
106120
}
@@ -114,7 +128,7 @@ gradle.afterProject {
114128
return@afterProject
115129
}
116130

117-
forEachSubproject { rootProperties, parent, subProjectProperties ->
131+
forEachIncludedProject { rootProperties, parent, subProjectProperties ->
118132
if (!subProjectProperties.exists() || subProjectProperties.readText() != rootProperties) {
119133
throw GradleException(
120134
"'gradle.properties' file in ${parent.name} included project is not up-to-date with root. " +
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package util.other
6+
7+
fun String.capitalized() = replaceFirstChar(Char::titlecase)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package util.other
6+
7+
import org.gradle.api.NamedDomainObjectCollection
8+
import org.gradle.api.NamedDomainObjectProvider
9+
10+
internal fun <T> NamedDomainObjectCollection<T>.maybeNamed(name: String): NamedDomainObjectProvider<T>? {
11+
return if (name in names) named(name) else null
12+
}
13+
14+
internal fun <T> NamedDomainObjectCollection<T>.maybeNamed(name: String, configure: T.() -> Unit) {
15+
if (name in names) named(name).configure(configure)
16+
}

0 commit comments

Comments
 (0)