Skip to content

Commit

Permalink
Central Portal support
Browse files Browse the repository at this point in the history
  • Loading branch information
natario1 committed Jul 28, 2024
1 parent dbdc0e4 commit 356ee10
Show file tree
Hide file tree
Showing 21 changed files with 568 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
types: [published]
jobs:
SONATYPE_UPLOAD:
name: Sonatype Upload
name: Maven Central Upload
runs-on: ubuntu-latest
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
Expand All @@ -20,7 +20,7 @@ jobs:
java-version: 17
distribution: temurin
cache: gradle
- name: Publish to Sonatype
run: ./gradlew deploySonatype
- name: Publish to Maven Central
run: ./gradlew deployNexus
- name: Publish to GitHub Packages
run: ./gradlew deployGithub
4 changes: 2 additions & 2 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
java-version: 17
distribution: temurin
cache: gradle
- name: Publish sonatype snapshot
run: ./gradlew deploySonatypeSnapshot
- name: Publish nexus snapshot
run: ./gradlew deployNexusSnapshot
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .idea/runConfigurations/deployNexusSnapshot.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 24 additions & 6 deletions deployer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
plugins {
`kotlin-dsl`
`java-gradle-plugin`
id("io.deepmedia.tools.deployer") version "0.12.0-rc1"
id("io.deepmedia.tools.deployer") version "0.12.0"
kotlin("plugin.serialization") version "1.9.23"
}

Expand Down Expand Up @@ -46,7 +46,7 @@ gradlePlugin {
}

group = "io.deepmedia.tools.deployer"
version = "0.12.0" // on change, update both docs and README
version = "0.13.0-rc1" // on change, update both docs and README

deployer {
verbose = true
Expand Down Expand Up @@ -75,15 +75,15 @@ deployer {
// directory.set(layout.buildDirectory.get().dir("inspect"))
}

// use "deploySonatype" to deploy to OSSRH / maven central
sonatypeSpec {
// use "deployNexus" to deploy to OSSRH / maven central
nexusSpec {
auth.user = secret("SONATYPE_USER")
auth.password = secret("SONATYPE_PASSWORD")
syncToMavenCentral = true
}

// use "deploySonatypeSnapshot" to deploy to sonatype snapshots repo
sonatypeSpec("snapshot") {
// use "deployNexusSnapshot" to deploy to sonatype snapshots repo
nexusSpec("snapshot") {
auth.user = secret("SONATYPE_USER")
auth.password = secret("SONATYPE_PASSWORD")
repositoryUrl = ossrhSnapshots1
Expand All @@ -99,4 +99,22 @@ deployer {
token = secret("GHUB_PERSONAL_ACCESS_TOKEN")
}
}

// Just for testing centralPortal
/* centralPortalSpec {
auth.user = secret("CENTRAL_PORTAL_USERNAME")
auth.password = secret("CENTRAL_PORTAL_PASSWORD")
allowMavenCentralSync = false
projectInfo.groupId.set("io.github.natario1")
content {
inherit.set(false)
component {
fromMavenPublication("pluginMaven", clone = true)
packaging.set("jar")
kotlinSources()
emptyDocs()
}
}
} */
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ open class DeployerExtension @Inject constructor(private val objects: ObjectFact
internal val mavenCentralSync = objects.newInstance<SonatypeMavenCentralSync>()
internal fun mavenCentralSync(action: Action<SonatypeMavenCentralSync>) { action.execute(mavenCentralSync) }

internal val centralPortalSettings = objects.newInstance<CentralPortalSettings>()
internal fun centralPortalSettings(action: Action<CentralPortalSettings>) { action.execute(centralPortalSettings) }

@Deprecated("DeployerExtension now *is* the default spec. Simply use `this`.")
val defaultSpec get() = this

Expand All @@ -37,6 +40,7 @@ open class DeployerExtension @Inject constructor(private val objects: ObjectFact
registerFactory(LocalDeploySpec::class.java) { LocalDeploySpec(objects, it).apply { fallback(this@DeployerExtension) } }
registerFactory(GithubDeploySpec::class.java) { GithubDeploySpec(objects, it).apply { fallback(this@DeployerExtension) } }
registerFactory(SonatypeDeploySpec::class.java) { SonatypeDeploySpec(objects, it).apply { fallback(this@DeployerExtension) } }
registerFactory(CentralPortalDeploySpec::class.java) { CentralPortalDeploySpec(objects, it).apply { fallback(this@DeployerExtension) } }
}

private fun specName(current: String, default: String): String {
Expand All @@ -47,6 +51,7 @@ open class DeployerExtension @Inject constructor(private val objects: ObjectFact
specs.register(specName(name, "local"), LocalDeploySpec::class.java, configure)
}

@Deprecated("sonatypeSpec is ambiguous. Use either nexusSpec (for OSSRH) or centralPortalSpec (for Central Portal).")
fun sonatypeSpec(name: String = "sonatype", configure: Action<SonatypeDeploySpec> = Action { }) {
specs.register(specName(name, "sonatype"), SonatypeDeploySpec::class.java, configure)
}
Expand All @@ -58,4 +63,8 @@ open class DeployerExtension @Inject constructor(private val objects: ObjectFact
fun githubSpec(name: String = "github", configure: Action<GithubDeploySpec> = Action { }) {
specs.register(specName(name, "github"), GithubDeploySpec::class.java, configure)
}

fun centralPortalSpec(name: String = "centralPortal", configure: Action<CentralPortalDeploySpec> = Action { }) {
specs.register(specName(name, "centralPortal"), CentralPortalDeploySpec::class.java, configure)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import io.deepmedia.tools.deployer.specs.GithubDeploySpec
import io.deepmedia.tools.deployer.specs.LocalDeploySpec
import io.deepmedia.tools.deployer.specs.SonatypeDeploySpec
import io.deepmedia.tools.deployer.model.*
import io.deepmedia.tools.deployer.ossrh.OssrhService
import io.deepmedia.tools.deployer.specs.NexusDeploySpec
import io.deepmedia.tools.deployer.central.ossrh.OssrhService
import io.deepmedia.tools.deployer.central.portal.CentralPortalService
import io.deepmedia.tools.deployer.specs.CentralPortalDeploySpec
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
Expand Down Expand Up @@ -54,6 +55,13 @@ class DeployerPlugin : Plugin<Project> {
parameters.verboseLogging.set(deployer.verbose)
}
}
if (this is CentralPortalDeploySpec) {
target.gradle.sharedServices.registerIfAbsent(CentralPortalService.Name, CentralPortalService::class) {
parameters.timeout.set(deployer.centralPortalSettings.timeout.map { it.inWholeMilliseconds })
parameters.pollingDelay.set(deployer.centralPortalSettings.pollingDelay.map { it.inWholeMilliseconds })
parameters.verboseLogging.set(deployer.verbose)
}
}

val deployThis = registerDeployTasks(log.child(name), this, target)
deployAll.configure { dependsOn(deployThis) }
Expand All @@ -71,6 +79,7 @@ class DeployerPlugin : Plugin<Project> {
is LocalDeploySpec -> "local maven repository"
is SonatypeDeploySpec -> "Sonatype/Nexus repository"
is GithubDeploySpec -> "GitHub packages"
is CentralPortalDeploySpec -> "Central Portal uploads"
else -> error("Unexpected spec type: ${spec::class}")
}
})."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.deepmedia.tools.deployer.ossrh
package io.deepmedia.tools.deployer.central.ossrh

import com.android.tools.r8.internal.Bo
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.deepmedia.tools.deployer.ossrh
package io.deepmedia.tools.deployer.central.ossrh

internal data class OssrhInfo(
val server: OssrhServer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package io.deepmedia.tools.deployer.ossrh
package io.deepmedia.tools.deployer.central.ossrh

import io.deepmedia.tools.deployer.Logger
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.getAndUpdate
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.flow.updateAndGet
import kotlinx.coroutines.time.withTimeout
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds

internal class OssrhInvocation(
logger: Logger,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.deepmedia.tools.deployer.ossrh
package io.deepmedia.tools.deployer.central.ossrh


// OSSRH: Nexus-powered repositories provided by Sonatype to OSS projects for
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.deepmedia.tools.deployer.ossrh
package io.deepmedia.tools.deployer.central.ossrh

import io.deepmedia.tools.deployer.Logger
import kotlinx.coroutines.*
import org.gradle.api.provider.Property
import org.gradle.api.services.BuildService
import org.gradle.api.services.BuildServiceParameters
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds


Expand Down
Loading

0 comments on commit 356ee10

Please sign in to comment.