Overview
The manipulation
plugin tries to detect a publishing plugin used by a project. It currently recognizes two plugins:
- the legacy
maven
plugin - the
maven-publish
plugin - the
gradle-nexus
plugin, here, which is a wrapper around the legacymaven
plugin
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:
AProxDeployUrl
- deployment repository URL,accessToken
- authorization access token (optional)
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:
- custom
Action
is added to all maven repositories of allUpload
tasks, which overrides versions in generated POM files, - if
uploadArchives
task doesn’t exist, it is created, uploadArchives
task is made to depend oninstall
task, so that the former is able to consumepom.xml
generated by the latter,- publishing repository is added.
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:
- new
MavenPublication
is created, - custom
Action
is added to all publications of typeMavenPublications
, which overrides versions in generated pom files, - publishing repository is added.
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:
- Implementation-Version
- Specification-Version
- Bundle-Version
The JDK is added under:
- Build-Jdk
If the following are not already present then the are updated with the project artifactId:
- Implementation-Title
- Specification-Title
- Bundle-Name
If the following are not already present then the are updated with the project groupId:
- Specification-Vendor
- Implementation-Vendor
- Implementation-Vendor-Id
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.