Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reuploadArtifactsToMavenCentral task #1727

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions mpp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import androidx.build.jetbrains.ArtifactRedirecting
import androidx.build.jetbrains.artifactRedirecting
import org.jetbrains.compose.internal.publishing.*

plugins {
signing
}

buildscript {
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/internal")
maven("https://maven.pkg.jetbrains.space/public/p/space/maven")
}
dependencies {
val buildHelpersVersion = System.getProperty("BUILD_HELPERS_VERSION") ?: "0.1.16"
classpath("org.jetbrains.compose.internal.build-helpers:publishing:$buildHelpersVersion")
}
}

open class ComposePublishingTask : AbstractComposePublishingTask() {
Expand All @@ -24,8 +15,6 @@ open class ComposePublishingTask : AbstractComposePublishingTask() {
}
}

val composeProperties = ComposeProperties(project)

// TODO: Align with other modules
val viewModelPlatforms = ComposePlatforms.ALL_AOSP - ComposePlatforms.WINDOWS_NATIVE

Expand Down Expand Up @@ -266,82 +255,9 @@ tasks.register("testComposeModules") { // used in https://github.com/JetBrains/a
// android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined.
}

val mavenCentral = MavenCentralProperties(project)
val mavenCentralGroup = project.providers.gradleProperty("maven.central.group")
val mavenCentralStage = project.providers.gradleProperty("maven.central.stage")
if (mavenCentral.signArtifacts) {
signing.useInMemoryPgpKeys(
mavenCentral.signArtifactsKey.get(),
mavenCentral.signArtifactsPassword.get()
)
}

val publishingDir = project.layout.buildDirectory.dir("publishing")
val originalArtifactsRoot = publishingDir.map { it.dir("original") }
val preparedArtifactsRoot = publishingDir.map { it.dir("prepared") }
val modulesFile = publishingDir.map { it.file("modules.txt") }

val findComposeModules by tasks.registering(FindModulesInSpaceTask::class) {
requestedGroupId.set(mavenCentralGroup)
requestedVersion.set(mavenCentral.version)
spaceInstanceUrl.set("https://public.jetbrains.space")
spaceClientId.set(System.getenv("COMPOSE_REPO_USERNAME") ?: "")
spaceClientSecret.set(System.getenv("COMPOSE_REPO_KEY") ?: "")
spaceProjectId.set(System.getenv("COMPOSE_DEV_REPO_PROJECT_ID") ?: "")
spaceRepoId.set(System.getenv("COMPOSE_DEV_REPO_REPO_ID") ?: "")
modulesTxtFile.set(modulesFile)
}

val downloadArtifactsFromComposeDev by tasks.registering(DownloadFromSpaceMavenRepoTask::class) {
dependsOn(findComposeModules)
modulesToDownload.set(project.provider {
readComposeModules(
modulesFile,
originalArtifactsRoot
)
})
spaceRepoUrl.set("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

val fixModulesBeforePublishing by tasks.registering(FixModulesBeforePublishingTask::class) {
dependsOn(downloadArtifactsFromComposeDev)
inputRepoDir.set(originalArtifactsRoot)
outputRepoDir.set(preparedArtifactsRoot)
}

val reuploadArtifactsToMavenCentral by tasks.registering(UploadToSonatypeTask::class) {
dependsOn(fixModulesBeforePublishing)

version.set(mavenCentral.version)
modulesToUpload.set(project.provider { readComposeModules(modulesFile, preparedArtifactsRoot) })

sonatypeServer.set("https://oss.sonatype.org")
user.set(mavenCentral.user)
password.set(mavenCentral.password)
autoCommitOnSuccess.set(mavenCentral.autoCommitOnSuccess)
stagingProfileName.set(mavenCentralStage)
}

fun readComposeModules(
modulesFile: Provider<out FileSystemLocation>,
repoRoot: Provider<out FileSystemLocation>
): List<ModuleToUpload> =
modulesFile.get().asFile.readLines()
.filter { it.isNotBlank() }
.map { line ->
val (group, artifact, version) = line.split(":")
ModuleToUpload(
groupId = group,
artifactId = artifact,
version = version,
localDir = repoRoot.get().asFile.resolve("$group/$artifact/$version")
)
}

fun allTasksWith(name: String) =
rootProject.subprojects.flatMap { it.tasks.filter { it.name == name } }


// ./gradlew printAllArtifactRedirectingVersions -PfilterProjectPath=lifecycle
// or just ./gradlew printAllArtifactRedirectingVersions
val printAllArtifactRedirectingVersions = tasks.register("printAllArtifactRedirectingVersions") {
Expand Down