On 07/10/2010, at 7:08 AM, Rene Groeschke wrote: > Hi Leonard, > I had a short look at your project on github and on the build.gradle file. > > Am 06.10.10 15:15, schrieb Leonard Axelsson: >> Hi, >> >> Has anyone here successfully used Gradle to do maven deploys to Sonatypes >> maven repo? This is my first external maven deploy so I guess I should have >> just gone the easy path and used maven but I'd rather use Gradle if it's >> possible. They have a set of fairly strict rules when it comes to what >> information needs to be available and I can't seem to be able to add it all. >> Reqs: >> https://docs.sonatype.org/display/Repository/Sonatype%20OSS%20Maven%20Repository%20Usage%20Guide#SonatypeOSSMavenRepositoryUsageGuide-6.CentralSyncRequirement >> >> My main problem right now is that I can figure out how to add the packaging >> and developers information to the pom. I've tried adding packaging to the >> builder but nothing happens. The rest of the information seems to be added >> correctly. >> > I've retested the build with "Sonatype Nexus™ Professional Edition, > Version: 1.8.0" and the following uploadArchives configuration: > > ------------------ > uploadArchives { > repositories.mavenDeployer { > configuration = configurations.archives > repository(url: "http://localhost:8081/nexus/content/repositories/test") { > authentication(userName: "admin", password: "admin123") > } > pom.project { > name 'GroovyCSV' > packaging 'jar' // not working > description 'Library for parsing csv in Groovy' > url 'http://github.com/xlson/groovycsv' > inceptionYear '2010' > > scm { > url 'http://github.com/xlson/groovycsv' > connection 'http://github.com/xlson/groovycsv' > } > > licenses { > license { > name 'The Apache Software License, Version 2.0' > url 'http://www.apache.org/licenses/LICENSE-2.0.txt' > distribution 'repo' > } > } > > developers { > developer { > id 'donald' > name 'donald duck' > email 'don...@duck.org' > url 'http://www.donaldduck.org' > organization 'acme' > organizationUrl 'http://acme.org' > roles{ > role 'architect' > } > timezone '-6' > } > } > } > } > } > ------------------ > I've detected two problems with the setup above: > > 1. It seems that gradle (or Ivy?) has a problem with the packaging > information. The model during the build is updated correctly, but it > seems that the info is never written into the pom.xml. > > 2. Using the defined developer informations above, the resulting pom > snippet is: > > ----- > <developers> > <developer> > <id>donald</id> > <name>donald duck</name> > <email>don...@duck.org</email> > <url>http://duck.org</url> > <organization>org.apache.maven.model.organizat...@4532b038</organization> > <organizationUrl>http://acme.org</organizationUrl> > <roles> > <role>architect</role> > </roles> > <timezone>-6</timezone> > </developer> > </developers> > ----- > > As you can see the organization isn't displayed correctly. It seems the > builder used to create that pom mixes up the organization model of > project with the plain string "organization" property of developer. > > Maybe Adam or Hans know a workaround to get your upload running!?
It looks like both those issues are problems in the maven code that Gradle uses to do the pom generation. Gradle passes the correct packaging to the maven code. When the packaging is 'jar', the maven code ignores the packaging as it generates the pom. For the organisation, there seems to be a problem in the maven polygot configuration code, so that the organisation is set to the string value of project.organization instead of 'acme' Here's what I ended up with, with some workaround for both those problems: configure(install.repositories.mavenInstaller) { pom.project { name 'GroovyCSV' // packaging 'jar' description 'Library for parsing csv in Groovy' url 'http://github.com/xlson/groovycsv' inceptionYear '2010' scm { url 'http://github.com/xlson/groovycsv' connection 'http://github.com/xlson/groovycsv' } licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' distribution 'repo' } } developers { developer { id 'donald' name 'donald duck' email 'don...@duck.org' url 'http://www.donaldduck.org' organization = 'acme' // <-- note we use assignment here organizationUrl 'http://acme.org' roles { role 'architect' } timezone '-6' } } } // Mess with the generated xml to add the packaging back in // This could probably be cleaner, if I knew the Groovy xml classes better pom.withXml { XmlProvider xmlProvider -> def xml = xmlProvider.asString() def pomXml = new XmlParser().parse(new ByteArrayInputStream(xml.toString().bytes)) pomXml.version[0] + { packaging('jar') } def newXml = new StringWriter() def printer = new XmlNodePrinter(new PrintWriter(newXml)) printer.preserveWhitespace = true printer.print(pomXml) xml.setLength(0) xml.append(newXml.toString()) } } If you want, you could raise some JIRA issues for these problems. -- Adam Murdoch Gradle Developer http://www.gradle.org CTO, Gradle Inc. - Gradle Training, Support, Consulting http://www.gradle.biz