Skip to content

Commit fae349a

Browse files
authored
Switch publication to the central portal (#6581)
* Switch to the central portal * remove intellij-plugin * remove other instance of intellij-plugin * keep versions in sync * update package-lock.json * fix test with Gradle 9
1 parent c8196c4 commit fae349a

File tree

20 files changed

+156
-175
lines changed

20 files changed

+156
-175
lines changed

.github/workflows/preview.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ jobs:
2828
git clone --depth 1 --single-branch --branch ${{ inputs.branch }} https://github.com/$GITHUB_REPOSITORY
2929
cd apollo-kotlin
3030
sed -i .old 's/VERSION_NAME=\([\.0-9]*\).*/VERSION_NAME=\1-${{ inputs.prerelease }}/g' gradle.properties
31-
export GOOGLE_APPLICATION_CREDENTIALS=google-services.json
32-
echo ${GOOGLE_SERVICES_JSON} > $GOOGLE_APPLICATION_CREDENTIALS
33-
./gradlew publishAllPublicationsToApolloPreviewsRepository
31+
./gradlew librarianPublishToGcs
3432
env:
35-
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
33+
LIBRARIAN_GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
3634
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/push.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ jobs:
2323
with:
2424
gradle-home-cache-cleanup: true
2525
- name: Build with Gradle
26-
#--no-configuration-cache for https://youtrack.jetbrains.com/issue/KT-65879
2726
run: |
28-
./gradlew -p tests ciBuild -i
29-
./gradlew :apollo-kdoc:dokkaGeneratePublicationHtml --no-build-cache
30-
./gradlew ciPublishSnapshot --no-configuration-cache
27+
./gradlew nmcpPublishAggregationToCentralPortalSnapshots
3128
env:
32-
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
33-
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
34-
COM_APOLLOGRAPHQL_PROFILE_ID: ${{ secrets.COM_APOLLOGRAPHQL_PROFILE_ID }}
29+
LIBRARIAN_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
30+
LIBRARIAN_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
3531
- name: Collect Diagnostics
3632
if: always()
3733
run: ./scripts/collect-diagnostics.main.kts

.github/workflows/tag.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ jobs:
2424
#--no-configuration-cache for https://youtrack.jetbrains.com/issue/KT-65879
2525
- name: Publish to Maven Central
2626
run: |
27-
./gradlew --no-build-cache ciPublishRelease -Pgradle.publish.key="${{ secrets.GRADLE_PUBLISH_KEY }}" -Pgradle.publish.secret="${{ secrets.GRADLE_PUBLISH_SECRET }}" --no-configuration-cache
27+
./gradlew nmcpPublishAggregationToCentralPortal
2828
env:
29-
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
30-
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
31-
COM_APOLLOGRAPHQL_PROFILE_ID: ${{ secrets.COM_APOLLOGRAPHQL_PROFILE_ID }}
29+
LIBRARIAN_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
30+
LIBRARIAN_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
3231
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
3332
GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }}

build-logic/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131
// See https://github.com/gradle/gradle/issues/4741
3232
implementation(libs.android.plugin)
3333
implementation(libs.gradle.japicmp.plugin)
34-
implementation(libs.vespene)
34+
implementation(libs.librarian)
3535
implementation(libs.kotlinx.serialization.json)
3636
implementation(libs.poet.java)
3737
implementation(libs.poet.kotlin)
@@ -49,7 +49,6 @@ dependencies {
4949
runtimeOnly(libs.atomicfu.plugin)
5050

5151
runtimeOnly(libs.sqldelight.plugin)
52-
runtimeOnly(libs.gradle.publish.plugin)
5352
runtimeOnly(libs.benmanes.versions)
5453
runtimeOnly(libs.gratatouille)
5554
runtimeOnly(libs.kotlinx.binarycompatibilityvalidator)

build-logic/src/main/kotlin/Publishing.kt

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import com.android.build.api.dsl.LibraryExtension
22
import com.android.build.gradle.BaseExtension
3-
import kotlinx.coroutines.runBlocking
4-
import net.mbonnin.vespene.lib.NexusStagingClient
53
import org.gradle.api.Project
64
import org.gradle.api.attributes.Usage
75
import org.gradle.api.internal.file.FileOperations
8-
import org.gradle.api.plugins.ExtraPropertiesExtension
96
import org.gradle.api.plugins.JavaPluginExtension
107
import org.gradle.api.publish.PublishingExtension
118
import org.gradle.api.publish.maven.MavenPublication
@@ -44,7 +41,7 @@ fun Project.configurePublishing(isAggregateKdoc: Boolean = false) {
4441
if (isAggregateKdoc) {
4542
configureDokkaAggregate()
4643
}
47-
configurePublishingInternal()
44+
configureModulePublishingInternal()
4845
}
4946

5047
fun Project.configureDokkaCommon(): DokkaExtension {
@@ -171,33 +168,7 @@ fun Project.configureDokkaAggregate() {
171168

172169
private abstract class FileOperationsHolder @Inject constructor(val fileOperations: FileOperations)
173170

174-
private fun Project.getOssStagingUrl(): String {
175-
val url = try {
176-
this.extensions.extraProperties["ossStagingUrl"] as String?
177-
} catch (e: ExtraPropertiesExtension.UnknownPropertyException) {
178-
null
179-
}
180-
if (url != null) {
181-
return url
182-
}
183-
val baseUrl = "https://s01.oss.sonatype.org/service/local/"
184-
val client = NexusStagingClient(
185-
baseUrl = baseUrl,
186-
username = System.getenv("SONATYPE_NEXUS_USERNAME"),
187-
password = System.getenv("SONATYPE_NEXUS_PASSWORD"),
188-
)
189-
val repositoryId = runBlocking {
190-
client.createRepository(
191-
profileId = System.getenv("COM_APOLLOGRAPHQL_PROFILE_ID"),
192-
description = "apollo-kotlin $version"
193-
)
194-
}
195-
return "${baseUrl}staging/deployByRepositoryId/${repositoryId}/".also {
196-
this.extensions.extraProperties["ossStagingUrl"] = it
197-
}
198-
}
199-
200-
private fun Project.configurePublishingInternal() {
171+
private fun Project.configureModulePublishingInternal() {
201172
val emptyJavadocJar = tasks.register("emptyJavadocJar", org.gradle.jvm.tasks.Jar::class.java) {
202173
archiveClassifier.set("javadoc")
203174

@@ -325,34 +296,11 @@ private fun Project.configurePublishingInternal() {
325296
name = "pluginTest"
326297
url = uri(rootProject.layout.buildDirectory.dir("localMaven"))
327298
}
328-
329-
maven {
330-
name = "ossSnapshots"
331-
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
332-
credentials {
333-
username = System.getenv("SONATYPE_NEXUS_USERNAME")
334-
password = System.getenv("SONATYPE_NEXUS_PASSWORD")
335-
}
336-
}
337-
338-
maven {
339-
name = "ossStaging"
340-
setUrl {
341-
uri(rootProject.getOssStagingUrl())
342-
}
343-
credentials {
344-
username = System.getenv("SONATYPE_NEXUS_USERNAME")
345-
password = System.getenv("SONATYPE_NEXUS_PASSWORD")
346-
}
347-
}
348-
349-
maven {
350-
name = "apolloPreviews"
351-
setUrl("gcs://apollo-previews/m2")
352-
}
353299
}
354300
}
355301

302+
pluginManager.apply("com.gradleup.nmcp")
303+
356304
// See https://youtrack.jetbrains.com/issue/KT-46466/Kotlin-MPP-publishing-Gradle-7-disables-optimizations-because-of-task-dependencies#focus=Comments-27-7102038.0-0
357305
val signingTasks = tasks.withType(Sign::class.java)
358306
tasks.withType(AbstractPublishToMaven::class.java).configureEach {
@@ -370,7 +318,7 @@ private fun Project.configurePublishingInternal() {
370318
isEnabled = !System.getenv("GPG_PRIVATE_KEY").isNullOrBlank()
371319
}
372320

373-
// https://github.com/gradle/gradle/issues/26132
321+
// https://github.com/gradle/gradle/issues/26091
374322
afterEvaluate {
375323
tasks.all {
376324
if (name.startsWith("compileTestKotlin")) {

build-logic/src/main/kotlin/api.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import app.cash.licensee.LicenseeExtension
22
import app.cash.licensee.UnusedAction
3+
import com.gradleup.librarian.gradle.Librarian
4+
import nmcp.NmcpAggregationExtension
35
import org.gradle.api.Project
46
import org.gradle.api.Task
57
import org.gradle.api.tasks.TaskProvider
@@ -131,5 +133,27 @@ fun Project.apolloTest(
131133
fun Project.apolloRoot(ciBuild: TaskProvider<Task>) {
132134
configureNode()
133135
rootSetup(ciBuild)
136+
137+
pluginManager.apply("com.gradleup.nmcp.aggregation")
138+
val nmcpAggregation = extensions.getByType(NmcpAggregationExtension::class.java)
139+
nmcpAggregation.apply {
140+
centralPortal {
141+
username.set(System.getenv("LIBRARIAN_SONATYPE_USERNAME"))
142+
password.set(System.getenv("LIBRARIAN_SONATYPE_PASSWORD"))
143+
publishingType.set("USER_MANAGED")
144+
}
145+
}
146+
147+
Librarian.registerGcsTask(
148+
this,
149+
provider { "apollo-previews" },
150+
provider { "m2" },
151+
provider { System.getenv("LIBRARIAN_GOOGLE_SERVICES_JSON") },
152+
nmcpAggregation.allFiles
153+
)
154+
155+
subprojects.forEach {
156+
configurations.getByName("nmcpAggregation").dependencies.add(dependencies.create(it))
157+
}
134158
}
135159

build.gradle.kts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,6 @@ fun shouldPublishSnapshots(): Boolean {
3030
return eventName == "push" && (ref == "refs/heads/main")
3131
}
3232

33-
tasks.register("ciPublishSnapshot") {
34-
description = "Publishes a SNAPSHOT"
35-
36-
if (shouldPublishSnapshots()) {
37-
dependsOn(subprojectTasks("publishAllPublicationsToOssSnapshotsRepository"))
38-
} else {
39-
doFirst {
40-
error("We are not on a branch, fail snapshots publishing")
41-
}
42-
}
43-
}
44-
45-
tasks.register("ciPublishRelease") {
46-
description = "Publishes all artifacts to OSSRH and the Gradle Plugin Portal"
47-
48-
if (isTag()) {
49-
dependsOn(subprojectTasks("publishAllPublicationsToOssStagingRepository"))
50-
// Only publish plugins to the Gradle portal if everything else succeeded
51-
finalizedBy(":apollo-gradle-plugin:publishPlugins")
52-
} else {
53-
doFirst {
54-
error("We are not on a tag, fail release publishing")
55-
}
56-
}
57-
58-
}
5933

6034
tasks.register("ciTestsGradle") {
6135
description = "Execute the Gradle tests (slow)"
@@ -71,7 +45,7 @@ tasks.register("ciTestsNoGradle") {
7145

7246

7347
subprojects {
74-
if (name !in setOf("apollo-gradle-plugin", "intellij-plugin")) {
48+
if (name !in setOf("apollo-gradle-plugin")) {
7549
dependsOn(tasks.matching { it.name == "test" })
7650
}
7751
dependsOn(tasks.matching { it.name == "jvmTest" })
@@ -136,8 +110,6 @@ configure<kotlinx.validation.ApiValidationExtension> {
136110
"com.apollographql.apollo.runtime.java.network.http.internal",
137111
)
138112
)
139-
140-
ignoredProjects.add("intellij-plugin")
141113
ignoredProjects.add("apollo-testing-support-internal")
142114
}
143115

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Publishing defaults, could ultimately be moved to build scripts
22
GROUP=com.apollographql.apollo
3-
VERSION_NAME=5.0.0-SNAPSHOT
3+
VERSION_NAME=5.0.0-alpha.0-SNAPSHOT
44

55
POM_URL=https://github.com/apollographql/apollo-kotlin/
66
POM_SCM_URL=https://github.com/apollographql/apollo-kotlin/

gradle/libraries.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ android-sdkversion-benchmark-min = "24"
1515
android-sdkversion-target = "30"
1616
androidx-sqlite = "2.3.1"
1717
# This is used by the gradle integration tests to get the artifacts locally
18-
apollo = "5.0.0-SNAPSHOT"
18+
apollo = "5.0.0-alpha.0-SNAPSHOT"
1919
apollo-execution = "0.1.0"
2020
apollo-normalizedcache-incubating = "1.0.0-alpha.3"
2121
# Used by the apollo-tooling project which uses a published version of Apollo
@@ -108,7 +108,6 @@ gratatouille = { group = "com.gradleup.gratatouille", name = "gratatouille-gradl
108108
# Keep in sync with MIN_GRADLE_VERSION
109109
gradle-api-min = { group = "dev.gradleplugins", name = "gradle-api", version = "8.0" }
110110
gradle-japicmp-plugin = { group = "me.champeau.gradle", name = "japicmp-gradle-plugin", version = "0.2.8" }
111-
gradle-publish-plugin = { group = "com.gradle.publish", name = "plugin-publish-plugin", version = "1.1.0" }
112111
guava-jre = { group = "com.google.guava", name = "guava", version.ref = "guava" }
113112
http4k-bom = "org.http4k:http4k-bom:5.8.0.0"
114113
http4k-core = { module = "org.http4k:http4k-core" }
@@ -188,7 +187,7 @@ androidx-test-runner = "androidx.test:runner:1.6.2"
188187
truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
189188
turbine = { group = "app.cash.turbine", name = "turbine", version = "1.1.0" }
190189
uuid = { group = "com.benasher44", name = "uuid", version = "0.8.2" }
191-
vespene = { group = "net.mbonnin.vespene", name = "vespene-lib", version = "0.5" }
190+
librarian = "com.gradleup.librarian:librarian-gradle-plugin:0.0.8-SNAPSHOT-30f5819e9747430b54e96ebb8d680e0fbe30f563"
192191
slf4j-simple = "org.slf4j:slf4j-simple:2.0.13"
193192
slf4j-nop = "org.slf4j:slf4j-nop:2.0.13"
194193
licensee = "app.cash.licensee:licensee-gradle-plugin:1.12.0"

gradle/repositories.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@ listOf(pluginManagement.repositories, dependencyResolutionManagement.repositorie
3232
}
3333
}
3434

35+
exclusiveContent {
36+
forRepository { maven("https://storage.googleapis.com/gradleup/m2") }
37+
filter {
38+
includeGroup("com.gradleup.librarian")
39+
}
40+
}
41+
3542
exclusiveContent {
3643
forRepository(::gradlePluginPortal)
3744
filter {
38-
includeModule("org.gradle.kotlin.embedded-kotlin", "org.gradle.kotlin.embedded-kotlin.gradle.plugin")
39-
includeModule("org.gradle.kotlin", "gradle-kotlin-dsl-plugins")
4045
includeModule("me.champeau.gradle", "japicmp-gradle-plugin")
4146
includeModule("org.jetbrains.kotlinx", "kotlinx-benchmark-plugin")
42-
includeModule("com.gradle.publish", "plugin-publish-plugin")
4347
includeModule("com.github.ben-manes", "gradle-versions-plugin")
4448
includeModule("com.gradle", "develocity-gradle-plugin")
4549
}

0 commit comments

Comments
 (0)