Codearte / gradle-nexus-staging-plugin

Automatize releasing Gradle projects to Maven Central.
Apache License 2.0
173 stars 26 forks source link

Execution failed for task ':closeRepository'. #217

Open softknife2021 opened 2 years ago

softknife2021 commented 2 years ago

Configure build.gradle and ran this command but has a failure below, what I am doing wrong? ./gradlew closeAndReleaseRepository

Configure project :

Task :closeRepository FAILED GET request failed. 401: , body:

FAILURE: Build failed with an exception.

BUILD FAILED in 3s 1 actionable task: 1 executed

szpak commented 2 years ago

Are you sure, you have the credentials configured properly? Have you tried to re-run it with --info? It should display something like:

"Using username 'xxx' and password from repository 'yyy'"

If no, you can - temporarily - put your username and password/key directly in the build.gradle to check if it helps (just locally, do NOT commit it to GitHub!).

softknife2021 commented 2 years ago

image yes it looks ok, have password and user set correctly. Not sure what I is wrong

szpak commented 2 years ago

You print some properties, but the closeRepository task doesn't print them on its own, so they might not be properly set in the plugin. Please paste the way how you configure gradle-nexus-staging-plugin, especially credentials.

softknife2021 commented 2 years ago

you mean just sent you an example of my build.gradle?

On Sun, Aug 7, 2022 at 2:04 PM Marcin Zajączkowski @.***> wrote:

You print some properties, but the closeRepository task doesn't print them on its own, so they might not be properly set in the plugin. Please paste the way how you configure gradle-nexus-staging-plugin, especially credentials.

— Reply to this email directly, view it on GitHub https://github.com/Codearte/gradle-nexus-staging-plugin/issues/217#issuecomment-1207485014, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXMRFEO2JLWE6XZY75SNOWLVYAQE5ANCNFSM53IFXRLQ . You are receiving this because you authored the thread.Message ID: @.***>

softknife2021 commented 2 years ago

here is my build.gradle

/*

plugins { // Apply the java-library plugin to add support for Java Library id 'java-library' id 'idea' id "com.adarshr.test-logger" version "2.1.0" id 'signing' id 'maven-publish' id 'io.codearte.nexus-staging' version '0.30.0' id "io.freefair.lombok" version "5.0.0-rc4" id "io.github.gradle-nexus.publish-plugin" version "1.0.0" }

repositories { // Use jcenter for resolving dependencies. // You can declare any Maven/Ivy/file repository here. //TODO jcenter will be sunset soon - find another option jcenter() mavenCentral() }

compileJava { sourceCompatibility = 1.8 targetCompatibility = 1.8 }

group = 'com.softknife' description = 'Quality, Release and Automation support' version = '0.0.1'

dependencies { api 'com.squareup.okhttp3:okhttp:5.0.0-alpha.2' implementation 'com.squareup.okhttp3:mockwebserver:5.0.0-alpha.2' implementation 'org.slf4j:slf4j-api:1.7.28' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' implementation group: 'org.aeonbits.owner', name: 'owner', version: '1.0.10'// implementation group: 'org.apache.commons', name: 'commons-exec', version: '1.3' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'

//json/models
implementation group: 'com.fasterxml.jackson.core', name:

'jackson-core', version: '2.11.2' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.2' implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'

//jira
api 'io.atlassian.fugue:fugue:4.7.2'
api 'com.atlassian.jira:jira-rest-java-client-core:5.2.1'
api 'com.atlassian.jira:jira-rest-java-client-api:5.2.1'

//apache
implementation group: 'org.apache.commons', name: 'commons-text',

version: '1.8' implementation group: 'org.apache.directory.studio', name: ' org.apache.commons.io', version: '2.4' implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'

// This dependency is used internally, and not exposed to consumers on

their own compile classpath. implementation 'com.google.guava:guava:28.0-jre'

//swagger
implementation group: 'io.swagger', name: 'swagger-core', version:

'2.0.0-rc2' implementation group: 'io.swagger', name: 'swagger-parser', version: '2.0.0-rc1' //openapi implementation group: 'io.swagger.core.v3', name: 'swagger-core', version: '2.1.5' implementation group: 'io.swagger.core.v3', name: 'swagger-models', version: '2.1.5' implementation group: 'io.swagger.parser.v3', name: 'swagger-parser-v3', version: '2.0.23'

//for creating request body
implementation group: 'io.swagger', name: 'swagger-inflector', version:

'2.0.5'

//lombok
implementation group: 'org.projectlombok', name: 'lombok', version:

'1.18.12'

//templates
implementation group: 'org.freemarker', name: 'freemarker', version:

'2.3.30' implementation group: 'org.jtwig', name: 'jtwig-json-extension', version: '5.86.1.RELEASE'

//mocking
implementation group: 'com.github.tomakehurst', name:

'wiremock-standalone', version: '2.27.2'

//needed for data provider
implementation group: 'org.testng', name: 'testng', version: '7.4.0'

// Use TestNG framework, also requires calling test.useTestNG() below
testImplementation group: 'org.testng', name: 'testng', version: '7.4.0'

}

configurations { childJars }

dependencies { subprojects.each { childJars project(it.path) } }

jar { dependsOn configurations.childJars from { configurations.childJars.collect { zipTree(it) } } exclude "META-INF/.SF" exclude "META-INF/.DSA" exclude "META-INF/*.RSA" }

task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir }

if (JavaVersion.current().isJava8Compatible()) { allprojects { tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') } } }

test { // Use TestNG for unit tests useTestNG() testLogging { events "passed", "skipped", "failed", "standardOut", "standardError" } }

ext.admin = hasProperty('sonatypeUsername') println("hie") println(hasProperty('sonatypeUsername'))

artifacts { archives jar archives sourcesJar archives javadocJar }

signing { required { false } sign publishing.publications }

nexusPublishing { //packageGroup = "com.example.mycompany.myproject" //defaults to 'project.group'

repositories {
    sonatype {   //or custom repository name
        //stagingProfileId = "yourStagingProfileId" //can reduce

execution time by even 10 seconds

        //defaults to project properties 'sonatypeUsername' and

'sonatypePassword', where 'sonatype' is name of configured repository username = project.findProperty("sonatypeUsername") password = project.findProperty("sonatypePassword") } }

clientTimeout = Duration.ofSeconds(300)
connectTimeout = Duration.ofSeconds(60)

transitionCheckOptions {
    maxRetries.set(40)
    delayBetween.set(java.time.Duration.ofMillis(3000))
}

}

//publishing { // publications { // mavenJava(MavenPublication) { // from components.java // customizePom(pom, rootProject) // // artifact sourcesJar // artifact javadocJar // } // } // repositories { // maven { // //url " https://oss.sonatype.org/service/local/staging/deploy/maven2" // url "https://s01.oss.sonatype.org/service/local/" // if (admin) { // credentials { // username 'sonatypeUsername' // password 'sonatypePassword' // } // } // } // } //}

model { tasks.publish { dependsOn(project.tasks.build) } tasks.install { dependsOn(project.tasks.build) } }

def customizePom(pom, gradleProject) { pom.withXml { def root = asNode() // modify POM and add optional flag where needed root.dependencies.'*'.findAll {

        ext.artifactId = it.artifactId.text()
        ext.fulldep = it.groupId.text() + ':' + it.artifactId.text() +

':' + it.version.text() }

    // add all items necessary for maven central publication
    root.children().last() + {
        println("Name:" + gradleProject.name)
        description gradleProject.description// moduleDescription
        resolveStrategy = Closure.DELEGATE_FIRST

        name 'Repo Qreasp'
        description gradleProject.description
        url 'https://github.com/softknife2021/qreasp'
        organization {
            name 'Softknife'
            url 'https://softknife.com'
        }
        issueManagement {
            system 'GitHub'
            url 'https://github.com/softknife2021/qreasp/issues'
        }
        licenses {
            license {
                name 'The Apache Software License, Version 2.0'
                url '

https://github.com/softknife2021/qreasp/blob/master/LICENSE' distribution 'repo' } } scm { url 'https://github.com/softknife/qreasp' connection 'scm:git:git:// github.com/softknife2021/qreasp.git' developerConnection 'scm:git:ssh:// @./softknife2021/qreasp.git' } developers { developer { id 'Alex' name 'Alexander Matsaylo' email @.' timezone '+1' } } } } }

testlogger { theme 'mocha' // project level slowThreshold 5000 }

task install(dependsOn: publishToMavenLocal) { group = 'Publishing' description = 'Installs artifacts to local Maven repository' }

// // RELEASE //

task release() { group 'Project' description 'Builds everything for the release.'

dependsOn build
dependsOn javadoc
//dependsOn jacocoTestReport

}

On Mon, Oct 10, 2022 at 4:30 PM alex softknife @.***> wrote:

you mean just sent you an example of my build.gradle?

On Sun, Aug 7, 2022 at 2:04 PM Marcin Zajączkowski < @.***> wrote:

You print some properties, but the closeRepository task doesn't print them on its own, so they might not be properly set in the plugin. Please paste the way how you configure gradle-nexus-staging-plugin, especially credentials.

— Reply to this email directly, view it on GitHub https://github.com/Codearte/gradle-nexus-staging-plugin/issues/217#issuecomment-1207485014, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXMRFEO2JLWE6XZY75SNOWLVYAQE5ANCNFSM53IFXRLQ . You are receiving this because you authored the thread.Message ID: @.***>

szpak commented 2 years ago
plugins {
    ....
    id 'io.codearte.nexus-staging' version '0.30.0'
    ...
    id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
}

You mix two plugins doing (almost) the same. As mentioned in the README, io.github.gradle-nexus.publish-plugin is a successor of io.codearte.nexus-staging. In addition, you configure only the second plugin, but call tasks from the first one...

So, remove id 'io.codearte.nexus-staging' version '0.30.0' completely and try to call closeSonatypeStagingRepository (as suggested in the documentation - https://github.com/gradle-nexus/publish-plugin#behind-the-scenes .