Ah, right. The problem is that settings.xml does not contain urls. It matches based on a "server id" from the pom.

I leveraged that in the current code by naming the repos in the Gradle build file. E.g.:

   uploadArchives {
      repositories.mavenDeployer {
         ...
repository(id: "jboss-releases-repository", url: "https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/";) snapshotRepository(id: "jboss-snapshots-repository", url: "https://repository.jboss.org/nexus/content/repositories/snapshots";)
      }
   }

As you can see, I use the id element of those repository definitions to be the link.

However, there does not see to be any such notion on the new API (MavenArtifactRepository does not expose id).

So, as far as I can tell I will not be able port this functionality to the new publishing API. Unless I am missing something (very possible).


On Tue 16 Apr 2013 08:17:51 AM CDT, Steve Ebersole wrote:

In rough that works:


// This is the kind of malarkey this plugin tries to address ~~~~~~
if ( ! hasProperty( "JBOSS_REPO_USER" ) ) {
JBOSS_REPO_USER = "";
}
if ( ! hasProperty( "JBOSS_REPO_PASS" ) ) {
JBOSS_REPO_PASS = "";
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

publishing {
repositories {
maven {
if ( project.version.endsWith( "SNAPSHOT" ) ) {
url snapshot-url
}
else {
url production-url
}

credentials {
username = JBOSS_REPO_USER
password = JBOSS_REPO_PASS
}
}
}
}

Now I just need to figure out:
1) how to apply this programatically
2) in such a way that does not trigger the lazy init of the publishing
block.

As far as (2), the way I did this in the initial plugin code was to
use an Action that I applied as a doFirst to all
'project.getTasks().withType( Upload.class )'. I think something
similar could be done against all 'project.getTasks().withType(
PublishToMavenRepository.class )'. Do you see a better option?

Btw, the code is at
https://github.com/sebersole/gradle-upload-auth-plugin. The plugin
class which drives the processing is
org.hibernate.build.gradle.upload.UploadAuthenticationManager. The
Action class is org.hibernate.build.gradle.upload.AuthenticationHandler



On Tue 16 Apr 2013 07:44:20 AM CDT, Steve Ebersole wrote:


On Tue 16 Apr 2013 07:38:38 AM CDT, Luke Daley wrote:




Look, I just want to know what I need to do in order to apply a set
of credentials to a maven repository to be used for upload. Is that
possible? If so how?



I'm having a lot of trouble understanding exactly what you are asking
for.

What have you tried? What didn't work (in concrete terms)? What was
the stack trace?

In what way does this not work for you:

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
url …
credentials {
username = "foo"
password = "bar"
}
}
}
}



Finally! :)

I have not tried anything, because I had no idea what to try. The
documentation makes no (obvious) mention that I can apply credentials
in this script block.

I will try that now.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to