View on GitHub

Gradle Manipulator @ Red Hat

Standardize Your Builds

Artifact Publishing

Overview

The manipulation plugin tries to detect a publishing plugin used by a project. It currently recognizes two plugins:

If one of the above plugins is detected, it is configured to support publication of project artifacts in PNC environment.

Following properties need to be given either as system properties or as environment variables:

In PNC above would be already defined as environment variables.

Legacy Maven Plugin

If the project uses the legacy maven plugin, use the uploadArchives task to publish artifacts.

Following changes are made automatically:

Loosely equivalent groovy configuration would be:

tasks.withType(Upload) {
  repositories.withType(MavenResolver) {
    pom.withXml(new PomTransfomer(...))
  }
}

uploadArchives {
  repositories {
    maven {
      url = System.getProperty('AProxDeployUrl')
      credentials(HttpHeaderCredentials) {
        name = "Authorization"
        value = "Bearer " + System.getProperty('accessToken')
      }
      authentication {
        header(HttpHeaderAuthentication)
      }
    }
  }
}

Maven-publish Plugin

If the project uses maven-publish plugin, use the publish task to publish artifacts.

Following changes are made automatically:

Loosely equivalent groovy configuration would be:

publishing {
  publications {
    mavenJava(MavenPublication) {
      from components.java
      pom.withXml(new PomTransfomer(...))
    }
  }
}

publishing {
  repositories {
    maven {
      url = System.getProperty('AProxDeployUrl')
      credentials(HttpHeaderCredentials) {
        name = "Authorization"
        value = "Bearer " + System.getProperty('accessToken')
      }
      authentication {
        header(HttpHeaderAuthentication)
      }
    }
  }
}

Manifest Handling

The custom action to update the version will also ensure that the information is correct within the MANIFEST.MF files. The following fields are updated:

Versions are updated for:

The JDK is added under:

If the following are not already present then the are updated with the project artifactId:

If the following are not already present then the are updated with the project groupId:

Examples

On local machine, you can try following to trigger publication.

For legacy maven plugin:

./gradlew uploadArchives -DAProxDeployUrl=file:///tmp/repo

For maven-publish plugin:

./gradlew publish -DAProxDeployUrl=file:///tmp/repo

Project artifacts should be published in /tmp/repo where you can review them.

In PNC, AProxDeployUrl is already defined as environment variable, so it can be omitted.