Skip to content

Commit

Permalink
Remove integration with io.codearte.nexus-staging
Browse files Browse the repository at this point in the history
Its functionality has been already backported (#4, #6).
  • Loading branch information
szpak committed May 17, 2020
1 parent 9ae32f0 commit a1bab79
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 300 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ The plugin does the following:
- Apply the `maven-publish` plugin
- configure a Maven artifact repository for each repository defined in the `nexusPublishing { repositories { ... } }` block
- create a `initialize${repository.name.capitalize()}StagingRepository` task that starts a new staging repository in case the project's version does not end with `-SNAPSHOT` (customizable via the `useStaging` property) and sets the URL of the corresponding Maven artifact repository accordingly. In case of a multi-project build, all subprojects with the same `nexusUrl` will use the same staging repository.
- if the [`io.codearte.nexus-staging` plugin](https://github.com/Codearte/gradle-nexus-staging-plugin) is applied on the root project, the `stagingRepositoryId` on its extension is set to the id of the newly created staging repository, this way it does not depend on exactly one open staging repository being available.
- make all publishing tasks for each configured repository depend on the `initialize${repository.name.capitalize()}StagingRepository` task.
- create a `publishTo${repository.name.capitalize()}` lifecycle task that depends on all publishing tasks for the corresponding Maven artifact repository.

Expand Down Expand Up @@ -100,19 +99,6 @@ nexusPublishing {
}
```

### Integration with the Nexus Staging Plugin

If the [`io.codearte.nexus-staging` plugin](https://github.com/Codearte/gradle-nexus-staging-plugin) is applied on the root project, the following default values change:

| Property | Default value |
| ------------------- | -------------------------------------------- |
| `packageGroup` | `rootProject.nexusStaging.packageGroup` |
| `stagingProfileId` | `rootProject.nexusStaging.stagingProfileId` |
| `username` | `rootProject.nexusStaging.username` |
| `password` | `rootProject.nexusStaging.password` |

This reuses the values specified for the `nexusStaging` block, so you don't have to specify them twice.

### HTTP Timeouts

You can configure the `connectTimeout` and `clientTimeout` properties on the `nexusPublishing` extension to set the connect and read/write timeouts (both default to 1 minute). Good luck!
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ dependencies {
shadowed("com.squareup.retrofit2:converter-gson:2.8.1")
shadowed("net.jodah:failsafe:2.3.5")

val nexusStagingPlugin = create("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.2")
compileOnly(nexusStagingPlugin)
testImplementation(nexusStagingPlugin)

testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
testImplementation("com.github.tomakehurst:wiremock:2.26.3")
testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,112 +352,6 @@ class NexusPublishPluginTests {
assertUploaded("/b/staging/deployByRepositoryId/orgexample-b/org/example/b/0.0.1/b-0.0.1.jar")
}

@Test
fun `configures staging repository id in staging plugin`() {
projectDir.resolve("settings.gradle").write("""
rootProject.name = 'sample'
""")
projectDir.resolve("build.gradle").write("""
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.20.0"
classpath files($pluginClasspathAsString)
}
}
plugins {
id('java-library')
}
apply plugin: 'io.codearte.nexus-staging'
apply plugin: 'io.github.gradle-nexus.publish-plugin'
group = 'org.example'
version = '0.0.1'
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
}
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl = uri('${server.baseUrl()}')
}
}
}
nexusStaging {
serverUrl = uri('${server.baseUrl()}')
stagingProfileId = '$STAGING_PROFILE_ID'
}
""")

stubCreateStagingRepoRequest("/staging/profiles/$STAGING_PROFILE_ID/start", STAGED_REPOSITORY_ID)
server.stubFor(post(urlEqualTo("/staging/bulk/close"))
.withRequestBody(matchingJsonPath("\$.data[?(@.stagedRepositoryIds[0] == '$STAGED_REPOSITORY_ID')]"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{}")))
server.stubFor(get(urlEqualTo("/staging/repository/$STAGED_REPOSITORY_ID"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"transitioning\":false,\"type\":\"CLOSED\"}")))

val result = run("initializeSonatypeStagingRepository", "closeRepository")

assertSuccess(result, ":initializeSonatypeStagingRepository")
assertSuccess(result, ":closeRepository")
assertCloseOfStagingRepo()
}

@Test
fun `warns about too old staging plugin`() {
projectDir.resolve("settings.gradle").write("""
rootProject.name = 'sample'
""")
projectDir.resolve("build.gradle").write("""
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.12.0"
classpath files($pluginClasspathAsString)
}
}
plugins {
id('java-library')
}
apply plugin: 'io.codearte.nexus-staging'
apply plugin: 'io.github.gradle-nexus.publish-plugin'
group = 'org.example'
version = '0.0.1'
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
}
}
}
nexusPublishing {
repositories {
myNexus {
nexusUrl = uri('${server.baseUrl()}')
snapshotRepositoryUrl = uri('${server.baseUrl()}/snapshots/')
}
}
}
nexusStaging {
stagingProfileId = '$STAGING_PROFILE_ID'
}
""")

stubCreateStagingRepoRequest("/staging/profiles/$STAGING_PROFILE_ID/start", STAGED_REPOSITORY_ID)

val result = run("initializeMyNexusStagingRepository")

assertSuccess(result, ":initializeMyNexusStagingRepository")
assertThat(result.output).contains("at least 0.20.0")
}

@Test
fun `uses configured timeout`() {
projectDir.resolve("settings.gradle").write("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.github.gradlenexus.publishplugin

import io.codearte.gradle.nexus.NexusStagingExtension
import io.github.gradlenexus.publishplugin.internal.NexusClient
import org.gradle.api.GradleException
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
Expand Down Expand Up @@ -59,19 +58,6 @@ constructor(
logger.info("Creating staging repository for stagingProfileId '{}'", stagingProfileId)
val stagingRepositoryIdAsString = client.createStagingRepository(stagingProfileId)
stagingRepositoryId.invoke(stagingRepositoryIdAsString)

//TODO: To be removed in next iteration
project.rootProject.plugins.withId("io.codearte.nexus-staging") {
val nexusStagingExtension = project.rootProject.the<NexusStagingExtension>()
try {
nexusStagingExtension.stagingRepositoryId.set(stagingRepositoryIdAsString)
} catch (e: NoSuchMethodError) {
logger.warn("For increased publishing reliability please update the io.codearte.nexus-staging plugin to at least version 0.20.0.\n" +
"If your version is at least 0.20.0, try to update the io.github.gradle-nexus.publish-plugin plugin to its latest version.\n" +
"If this also does not make this warning go away, please report an issue for io.github.gradle-nexus.publish-plugin.")
logger.debug("getStagingRepositoryId method not found on nexusStagingExtension", e)
}
}
client.getStagingRepositoryUri(stagingRepositoryIdAsString)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.github.gradlenexus.publishplugin

import io.codearte.gradle.nexus.NexusStagingExtension
import java.net.URI
import java.util.concurrent.ConcurrentHashMap
import org.gradle.BuildAdapter
Expand Down Expand Up @@ -94,23 +93,6 @@ class NexusPublishPlugin : Plugin<Project> {
configureTaskDependencies(project, publishToNexusTask, initializeTask, closeTask, releaseTask, mavenRepo)
}
}

project.rootProject.plugins.withId("io.codearte.nexus-staging") {
val nexusStagingExtension = project.rootProject.the<NexusStagingExtension>()

extension.packageGroup.set(project.provider {
if (nexusStagingExtension.packageGroup.isNullOrBlank()) {
project.group.toString()
} else {
nexusStagingExtension.packageGroup
}
})
extension.repositories.configureEach {
stagingProfileId.set(project.provider { nexusStagingExtension.stagingProfileId })
username.set(project.provider { nexusStagingExtension.username })
password.set(project.provider { nexusStagingExtension.password })
}
}
}

private fun addMavenRepositories(project: Project, extension: NexusPublishExtension): Map<NexusRepository, MavenArtifactRepository> {
Expand Down

This file was deleted.

0 comments on commit a1bab79

Please sign in to comment.