Maven publishing plugin doesn't upload generated POM file


(Benjamin Muschko) #1

I was trying out the new Maven publishing plugin for one of my projects. The binary repository I use is a local Artifactory instance with version 3.0.1. The project declares a single Java publication and applies some minor modifications to the POM of this publication. When executing the publish task only the JAR file is uploaded, as shown in the following command line output:

$ gradle publish
:generatePomFileForPluginPublication
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:publishPluginPublicationToMavenRepository
Uploading: org/gradle/api/plugins/gradle-cloudbees-plugin/0.1/gradle-cloudbees-plugin-0.1.jar to repository remote at http://localhost:8080/artifactory/libs-release-local
Transferring 179K from remote
Uploaded 179K
:publish

When I have a look at the published POM file on Artifactory the content doesn’t reflect my configuration.

<dependency>
    <groupId>org.gradle.api.plugins</groupId>
    <artifactId>gradle-cloudbees-plugin</artifactId>
    <version>0.1</version>
    <type>pom</type>
</dependency>

Shouldn’t the POM get uploaded as well. Is there anything missing from my configuration below? If I publish the artifact to Maven Local I can see the correct POM file.

apply plugin: 'maven-publish'
  publishing {
     publications {
        plugin(MavenPublication) {
            from components.java
     pom.withXml {
    def root = asNode()
    root.appendNode('name', 'Gradle CloudBees plugin')
    root.appendNode('description', 'Gradle plugin for managing applications and databases on CloudBees RUN@cloud.')
    root.appendNode('url', 'https://github.com/bmuschko/gradle-cloudbees-plugin')
    root.appendNode('inceptionYear', '2013')
          def scm = root.appendNode('scm')
    scm.appendNode('url', 'https://github.com/bmuschko/gradle-cloudbees-plugin')
    scm.appendNode('connection', 'scm:https://bmuschko@github.com/bmuschko/gradle-cloudbees-plugin.git')
    scm.appendNode('developerConnection', 'scm:git://github.com/bmuschko/gradle-cloudbees-plugin.git')
          def license = root.appendNode('licenses').appendNode('license')
    license.appendNode('name', 'The Apache Software License, Version 2.0')
    license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
    license.appendNode('distribution', 'repo')
          def developer = root.appendNode('developers').appendNode('developer')
    developer.appendNode('id', 'bmuschko')
    developer.appendNode('name', 'Benjamin Muschko')
    developer.appendNode('email', 'benjamin.muschko@gmail.com')
   }
        }
    }
   repositories {
  maven {
   url project.version.endsWith('-SNAPSHOT') ? artifactorySnapshotRepositoryUrl : artifactoryReleaseRepositoryUrl
        credentials {
    username = artifactoryUsername
    password = artifactoryPassword
   }
  }
 }
}

#2

Don’t trust the logs to tell you what files are uploaded. POM files should definitely be uploading, and we have tests that verify this (but not to Artifactory).

First step would be to check the content of the generated POM file: it should be located something like ‘build/publications/plugin/pom-default.xml’.


(Benjamin Muschko) #3

The content of the file ‘build/publications/plugin/pom-default.xml’ looks correct:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.manning.gia</groupId>
  <artifactId>gradle-cloudbees-plugin</artifactId>
  <version>0.1</version>
  <dependencies>
    <dependency>
      <groupId>org.gradle.api.plugins</groupId>
      <artifactId>cloudbees-api-client</artifactId>
      <version>1.4.0</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  <name>Gradle CloudBees plugin</name>
  <description>Gradle plugin for managing applications and databases on CloudBees RUN@cloud.</description>
  <url>https://github.com/bmuschko/gradle-cloudbees-plugin</url>
  <inceptionYear>2013</inceptionYear>
  <scm>
    <url>https://github.com/bmuschko/gradle-cloudbees-plugin</url>
    <connection>scm:https://bmuschko@github.com/bmuschko/gradle-cloudbees-plugin.git</connection>
    <developerConnection>scm:git://github.com/bmuschko/gradle-cloudbees-plugin.git</developerConnection>
  </scm>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>bmuschko</id>
      <name>Benjamin Muschko</name>
      <email>benjamin.muschko@gmail.com</email>
    </developer>
  </developers>
</project>

#4

Hmmm. So we’re still delegating the task of uploading to the Maven Ant Tasks. Not sure why your POM isn’t uploading correctly to Artifactory. Anything interesting show up in the debug logs?


(Benjamin Muschko) #5

Sorry my bet. This works just fine. Thanks for responding.