How to specify username/password for Gradle uploadArchives

4,365 views
Skip to first unread message

Tim Fox

unread,
Oct 24, 2012, 3:44:05 PM10/24/12
to ve...@googlegroups.com
Trying to get the jars onto Maven.

Execution failed for task ':vertx-core:uploadArchives'.
> Could not publish configuration ':vertx-core:archives'.
> Error deploying artifact 'org.vert-x:vertx-core:jar': Error
deploying artifact: Failed to transfer file:
https://oss.sonatype.org/service/local/staging/deploy/maven2/org/vert-x/vertx-core/1.3.0.final/vertx-core-1.3.0.final.jar.
Return code is: 401

Looks like I'm not authenticated.

I believe there is a file in which I need to put a username/password but
don't know where.

Gradle docs aren't much help:
http://www.gradle.org/docs/current/userguide/maven_plugin.html

I suspect it's the same file that Maven uses, so perhaps any Maven users
can help me here?

As you know, anything Gradle/Maven is a mystery to me.

--
Tim Fox

Vert.x - effortless polyglot asynchronous application development
http://vertx.io
twitter:@timfox

Cédric Champeau

unread,
Oct 24, 2012, 4:36:28 PM10/24/12
to ve...@googlegroups.com
You need to specify credentials in the uploadArchive configuration.
Something like this would read them from system properties for example :

uploadArchives {
repositories {
mavenDeployer {
def credentials = [
userName: System.getProperty('deploy.username'),
password: System.getProperty('deploy.password')
]
repository(id:'codehaus.org',url:
uri('dav:https://dav.codehaus.org/repository/groovy'), authentication:
credentials)
snapshotRepository(id:'codehaus.org',url:
uri('dav:https://dav.codehaus.org/snapshots.repository/groovy'),
authentication: credentials)
}
}
}

Le 24/10/2012 21:44, Tim Fox a �crit :
> Trying to get the jars onto Maven.
>
> Execution failed for task ':vertx-core:uploadArchives'.
> > Could not publish configuration ':vertx-core:archives'.
> > Error deploying artifact 'org.vert-x:vertx-core:jar': Error
> deploying artifact: Failed to transfer file:
> https://oss.sonatype.org/service/local/staging/deploy/maven2/org/vert-x/vertx-core/1.3.0.final/vertx-core-1.3.0.final.jar.
> Return code is: 401
>
> Looks like I'm not authenticated.
>
> I believe there is a file in which I need to put a username/password
> but don't know where.
>
> Gradle docs aren't much help:
> http://www.gradle.org/docs/current/userguide/maven_plugin.html
>
> I suspect it's the same file that Maven uses, so perhaps any Maven
> users can help me here?
>
> As you know, anything Gradle/Maven is a mystery to me.
>


--
C�dric Champeau
SpringSource - A Division Of VMware
http://www.springsource.com/
http://twitter.com/CedricChampeau

Tim Fox

unread,
Oct 24, 2012, 4:56:40 PM10/24/12
to ve...@googlegroups.com
Hi Cedric,

The Gradle build file currently says this:

buildscript {
repositories {
mavenLocal()
maven { url
'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
}

I don't see how this maps to your example. Where would I add the
username and password?

Also... previously I had this working before and it would automatically
pick up some config file from somewhere (iirc in a directory in my home?).

Cédric Champeau

unread,
Oct 24, 2012, 5:14:23 PM10/24/12
to ve...@googlegroups.com
Right. I should have checked the vert.x repo first. You have a file named gradle/maven.gradle which gets included. Inside, you find this:

uploadArchives {
group 'build'
description = "Does a maven deploy of archives artifacts"
repositories {
mavenDeployer {
configuration = configurations.archives
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
if (isReleaseVersion) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
configurePom(pom)
}
}
}
So it looks for properties named "sonatypeUsername" and "sonatypePassword" which are defined this way:

if (!hasProperty('sonatypeUsername')) {
ext.sonatypeUsername = ''
}
if (!hasProperty('sonatypePassword')) {
ext.sonatypePassword = ''
}
Which means to me that the only thing you need is to declare them when you start the build:

./gradlew -PsonatypeUsername=foo -PsonatypePassword=pass uploadArchives




Le 24/10/2012 22:56, Tim Fox a écrit :
Hi Cedric,

The Gradle build file currently says this:

buildscript {
    repositories {
        mavenLocal()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        mavenCentral()
    }
}

I don't see how this maps to your example. Where would I add the username and password?

Also... previously I had this working before and it would automatically pick up some config file from somewhere (iirc in a directory in my home?).

On 24/10/12 21:36, Cédric Champeau wrote:
You need to specify credentials in the uploadArchive configuration. Something like this would read them from system properties for example :

uploadArchives {
        repositories {
            mavenDeployer {
                def credentials = [
                        userName: System.getProperty('deploy.username'),
                        password: System.getProperty('deploy.password')
                ]
                repository(id:'codehaus.org',url: uri('dav:https://dav.codehaus.org/repository/groovy'), authentication: credentials)
                snapshotRepository(id:'codehaus.org',url: uri('dav:https://dav.codehaus.org/snapshots.repository/groovy'), authentication: credentials)
            }
        }
    }

Le 24/10/2012 21:44, Tim Fox a écrit :
Trying to get the jars onto Maven.

Execution failed for task ':vertx-core:uploadArchives'.
> Could not publish configuration ':vertx-core:archives'.
   > Error deploying artifact 'org.vert-x:vertx-core:jar': Error deploying artifact: Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/org/vert-x/vertx-core/1.3.0.final/vertx-core-1.3.0.final.jar. Return code is: 401

Looks like I'm not authenticated.

I believe there is a file in which I need to put a username/password but don't know where.

Gradle docs aren't much help: http://www.gradle.org/docs/current/userguide/maven_plugin.html

I suspect it's the same file that Maven uses, so perhaps any Maven users can help me here?

As you know, anything Gradle/Maven is a mystery to me.







-- 
Cédric Champeau
SpringSource - A Division Of VMware
http://www.springsource.com/
http://twitter.com/CedricChampeau

Scott Frederick

unread,
Oct 24, 2012, 5:23:07 PM10/24/12
to ve...@googlegroups.com
 You should also be able to set these properties in a file were gradle will pick them up, as Tim seems to recall. Try creating the file ~/.gradle/init.gradle, with the properties set there:

sonatypeUsername=foo
sonatypePassword=pass


See http://gradle.org/docs/current/userguide/init_scripts.html.

Scott

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To post to this group, send an email to ve...@googlegroups.com.
To unsubscribe from this group, send email to vertx+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/vertx?hl=en-GB.

Tim Fox

unread,
Oct 24, 2012, 5:25:41 PM10/24/12
to ve...@googlegroups.com
Yay! That works :)

Now, iirc, the next step is to log-in to the Sonatype (or is it Nexus?)
Maven web interface thingy where I have to press a few buttons to
graduate the release from staging.

Only problem is I can't remember the URL (again). Anyone?

On 24/10/12 22:14, CīŋŊdric Champeau wrote:
> Right. I should have checked the vert.x repo first. You have a file
> named gradle/maven.gradle which gets included. Inside, you find this:
>
> uploadArchives {
> group 'build'
> description = "Does a maven deploy of archives artifacts"
> repositories {
> mavenDeployer {
> configuration = configurations.archives
> repository(url:
> "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
> authentication(*userName:****sonatypeUsername**,****password:****sonatypePassword*)
> }
> snapshotRepository(url:
> "https://oss.sonatype.org/content/repositories/snapshots/") {
> authentication(userName: sonatypeUsername, password: sonatypePassword)
> }
> if (isReleaseVersion) {
> beforeDeployment { MavenDeployment deployment ->
> signing.signPom(deployment) }
> }
> configurePom(pom)
> }
> }
> }
> So it looks for properties named "sonatypeUsername" and
> "sonatypePassword" which are defined this way:
>
> if (!hasProperty('sonatypeUsername')) {
> ext.sonatypeUsername = ''
> }
> if (!hasProperty('sonatypePassword')) {
> ext.sonatypePassword = ''
> }
> Which means to me that the only thing you need is to declare them when
> you start the build:
>
> |./gradlew -PsonatypeUsername=foo -PsonatypePassword=pass uploadArchives|
>
>
>
> Le 24/10/2012 22:56, Tim Fox a īŋŊcrit :
>> Hi Cedric,
>>
>> The Gradle build file currently says this:
>>
>> buildscript {
>> repositories {
>> mavenLocal()
>> maven { url
>> 'https://oss.sonatype.org/content/repositories/snapshots' }
>> mavenCentral()
>> }
>> }
>>
>> I don't see how this maps to your example. Where would I add the
>> username and password?
>>
>> Also... previously I had this working before and it would
>> automatically pick up some config file from somewhere (iirc in a
>> directory in my home?).
>>
>> On 24/10/12 21:36, CīŋŊdric Champeau wrote:
>>> You need to specify credentials in the uploadArchive configuration.
>>> Something like this would read them from system properties for
>>> example :
>>>
>>> uploadArchives {
>>> repositories {
>>> mavenDeployer {
>>> def credentials = [
>>> userName:
>>> System.getProperty('deploy.username'),
>>> password: System.getProperty('deploy.password')
>>> ]
>>> repository(id:'codehaus.org',url:
>>> uri('dav:https://dav.codehaus.org/repository/groovy'),
>>> authentication: credentials)
>>> snapshotRepository(id:'codehaus.org',url:
>>> uri('dav:https://dav.codehaus.org/snapshots.repository/groovy'),
>>> authentication: credentials)
>>> }
>>> }
>>> }
>>>
>>> Le 24/10/2012 21:44, Tim Fox a īŋŊcrit :
>>>> Trying to get the jars onto Maven.
>>>>
>>>> Execution failed for task ':vertx-core:uploadArchives'.
>>>> > Could not publish configuration ':vertx-core:archives'.
>>>> > Error deploying artifact 'org.vert-x:vertx-core:jar': Error
>>>> deploying artifact: Failed to transfer file:
>>>> https://oss.sonatype.org/service/local/staging/deploy/maven2/org/vert-x/vertx-core/1.3.0.final/vertx-core-1.3.0.final.jar.
>>>> Return code is: 401
>>>>
>>>> Looks like I'm not authenticated.
>>>>
>>>> I believe there is a file in which I need to put a
>>>> username/password but don't know where.
>>>>
>>>> Gradle docs aren't much help:
>>>> http://www.gradle.org/docs/current/userguide/maven_plugin.html
>>>>
>>>> I suspect it's the same file that Maven uses, so perhaps any Maven
>>>> users can help me here?
>>>>
>>>> As you know, anything Gradle/Maven is a mystery to me.
>>>>
>>>
>>>
>>
>>
>
>
> --
> CīŋŊdric Champeau
> SpringSource - A Division Of VMware
> http://www.springsource.com/
> http://twitter.com/CedricChampeau
> --
> You received this message because you are subscribed to the Google
> Groups "vert.x" group.
> To post to this group, send an email to ve...@googlegroups.com.
> To unsubscribe from this group, send email to
> vertx+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/vertx?hl=en-GB.


Pid

unread,
Oct 25, 2012, 4:29:51 AM10/25/12
to ve...@googlegroups.com
On 24/10/2012 22:25, Tim Fox wrote:
> Yay! That works :)
>
> Now, iirc, the next step is to log-in to the Sonatype (or is it Nexus?)
> Maven web interface thingy where I have to press a few buttons to
> graduate the release from staging.
>
> Only problem is I can't remember the URL (again). Anyone?

https://oss.sonatype.org/index.html#welcome

I am logging in now to close & release.


p
>> Cédric Champeau
>> SpringSource - A Division Of VMware
>> http://www.springsource.com/
>> http://twitter.com/CedricChampeau
>> --
>> You received this message because you are subscribed to the Google
>> Groups "vert.x" group.
>> To post to this group, send an email to ve...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> vertx+un...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/vertx?hl=en-GB.
>
>


--

[key:62590808]

signature.asc
Reply all
Reply to author
Forward
0 new messages