Mvh, /Leo QBRANCH: CODE http://code.qbranch.se<http://code.qbranch.se/>
On 28 okt 2010, at 17.38, Rene Groeschke wrote: Hi Leonard, Am Do, 28.10.2010, 16:50, schrieb Leonard Axelsson: Thanks for the help! The xml modifications seems to be working for me. One thing though, CsvParser has a method called parseText that takes a String, so no need to down to the bytes and back. Now I'm trying to publish the final 0.2 version and it seems the Sonatype repo requires all jar-files to be GPG signed. I figured out how to sign the files form gradle by calling out to gpg but I'm unsure how I should go about adding the signature files (groovycsv-0.2.jar.asc ...) to the upload. I've been reading the documentation trying to figure out how to add files to artifacts (is that what I should do?) but can only find examples of adding jar- and zip-files. there was a discussion on how to do handle/upload a custom produced file (DLL in this example) with gradle and a maven repo on this mailinglist. Have a look at http://markmail.org/message/niseybxbjynckr2c If you need further support. don't hesitate to ask! Thanks for the tips! I've been trying to do just that but run into the problem that the maven plugin complains when I try to upload an extra artifact wihtout a classifier. It seems I need to add a classifier but if I do the filename will not match that of the artifact. Either I'm doing something wrong or a change to the maven plugin is needed to allow for the addition of the asc files. I will try to spend some time reading the sources of the maven plugin this weekend to see if I can figure out what I should do or if a change to the plugin is needed. This is the code I've been using to try to upload an asc file with my main jar: def jarAsc = new File("build/libs/groovycsv-${version}.jar.asc") println "Adding: $jarAsc" configurations.archives.addArtifact(new DefaultPublishArtifact("com.xlson.groovycsv", 'jar.asc', 'asc', null, new Date(), jarAsc)) The exception being thrown: Caused by: org.gradle.api.InvalidUserDataException: A pom can't have multiple main artifacts. Already assigned artifact: com.xlson.groovycsv#groovycsv;0.2-SNAPSHOT!groovycsv.jar Artifact trying to assign: com.xlson.groovycsv#groovycsv;0.2-SNAPSHOT!com.xlson.groovycsv.jar.asc(asc) at org.gradle.api.internal.artifacts.publish.maven.deploy.DefaultArtifactPom.addArtifact(DefaultArtifactPom.java:86) at org.gradle.api.internal.artifacts.publish.maven.deploy.DefaultArtifactPomContainer.addArtifact(DefaultArtifactPomContainer.java:54) at org.gradle.api.internal.artifacts.publish.maven.deploy.AbstractMavenResolver.publish(AbstractMavenResolver.java:155) at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:281) at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:260) at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyPublisher.publish(DefaultIvyDependencyPublisher.java:54) at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyService.publish(DefaultIvyService.java:144) at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsIvyService.publish(ShortcircuitEmptyConfigsIvyService.java:61) at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService.publish(ErrorHandlingIvyService.java:42) ... 42 more regards, René Any hints would be appreciated. Kindly, /Leo ---------------------------------- Leonard Axelsson Blog: http://xlson.com/ Twitter: xlson On 8 okt 2010, at 02.35, Adam Murdoch wrote: 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%20Rep ository%20Usage%20Guide#SonatypeOSSMavenRepositoryUsageGuide-6.CentralSyn cRequirement 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 NexusT 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<mailto:'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<mailto:'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<http://www.gradle.org/> CTO, Gradle Inc. - Gradle Training, Support, Consulting http://www.gradle.biz --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email