Move publishing from bintray to Maven central
MODIFY
asciidoctorj-api/build.gradle
asciidoctorj-api/build.gradle
apply plugin: 'biz.aQute.bnd.builder'
+apply plugin: 'de.marcphilipp.nexus-publish'
dependencies {
compileOnly "org.osgi:osgi.annotation:$osgiVersion"
@@ -12,4 +13,13 @@ jar {
)
}
+ext.publicationName = "mavenAsciidoctorJApi"
+apply from: rootProject.file('gradle/publish.gradle')
+apply from: rootProject.file('gradle/signing.gradle')
+
+publishing {
+ publications.findByName(project.ext.publicationName).each {
+ it.from(components.java)
+ }
+}

MODIFY
asciidoctorj-arquillian-extension/build.gradle
asciidoctorj-arquillian-extension/build.gradle
+apply plugin: 'de.marcphilipp.nexus-publish'
+
dependencies {
compileOnly project(':asciidoctorj')
compile project(':asciidoctorj-test-support')
@@ -7,9 +9,20 @@ dependencies {
compile "org.jboss.arquillian.container:arquillian-container-test-impl-base:$arquillianVersion"
}
-def javaApiUrl = "https://docs.oracle.com/javase/6/docs/api"
-def junitURL = "http://junit.org/javadoc/latest/"
+def javaApiUrl = "https://docs.oracle.com/javase/8/docs/api/"
+def junitURL = "https://junit.org/junit4/javadoc/latest"
javadoc {
options.links( javaApiUrl, junitURL )
}
+
+project.ext.publicationName = "mavenAsciidoctorJArquillianExtension"
+
+apply from: rootProject.file('gradle/publish.gradle')
+apply from: rootProject.file('gradle/signing.gradle')
+
+publishing {
+ publications.findByName(project.ext.publicationName).each {
+ it.from(rootProject.project('asciidoctorj-arquillian-extension').components.java)
+ }
+}

MODIFY
asciidoctorj-core/build.gradle
asciidoctorj-core/build.gradle
+apply plugin: 'java'
+apply plugin: 'groovy'
apply plugin: 'biz.aQute.bnd.builder'
dependencies {
@@ -118,3 +120,14 @@ task pollutedTest(type: Test) {
test.dependsOn pollutedTest
+project.ext.publicationName = "mavenAsciidoctorJ"
+
+apply from: rootProject.file('gradle/publish.gradle')
+apply from: rootProject.file('gradle/signing.gradle')
+
+publishing {
+ publications.findByName(project.ext.publicationName).each {
+ it.from(components.java)
+ }
+}
+

MODIFY
asciidoctorj-distribution/build.gradle
asciidoctorj-distribution/build.gradle
@@ -32,27 +32,6 @@ dependencies {
}
jar.enabled = false
-if ( !project.hasProperty('skip.signing') ) {
- signPom.enabled = false
-}
-
-/*
-UGLY HACK to workaround gradle-bintray-plugin compatibility with Gradle 5+
-
-https://github.com/asciidoctor/asciidoctorj/issues/861
-https://github.com/bintray/gradle-bintray-plugin/issues/300
-
-WARNING: since the Groovy Gradle API is modified, this breaks build isolation when sharing a common Gradle daemon instance
-
-This works because gradle-bintray-plugin is using Groovy dynamic compilation hence it is affected by Groovy runtime meta-programming
-
-Tested with: Gradle 5.6.3 / gradle-bintray-plugin 1.8.4
-
-TODO: remove as soon as bintray/gradle-bintray-plugin#300 is fixed and integrated
-*/
-Signature.metaClass.getToSignArtifact = { ->
- return (delegate as Signature).source
-}
configurations.archives.with {
//We need to remove the (non-existing) jar artifact, otherwise signing will fail
@@ -76,3 +55,11 @@ startScripts {
'-Xverify:none', '-XX:+TieredCompilation', '-XX:TieredStopAtLevel=1', '-XX:+DisableExplicitGC', '-Djruby.compile.mode=OFF'
]
}
+
+project.ext.publicationName = "mavenAsciidoctorJ"
+
+publishing {
+ publications.findByName(project.ext.publicationName).each {
+ it.artifact(distZip)
+ }
+}

MODIFY
asciidoctorj-test-support/build.gradle
asciidoctorj-test-support/build.gradle
+apply plugin: 'java'
+
dependencies {
compile 'junit:junit:4.12'
}
-def javaApiUrl = "https://docs.oracle.com/javase/6/docs/api"
-def junitURL = "http://junit.org/javadoc/latest/"
+def javaApiUrl = "https://docs.oracle.com/javase/8/docs/api/"
+def junitURL = "https://junit.org/junit4/javadoc/latest"
javadoc {
options.links(javaApiUrl, junitURL)

MODIFY
build.gradle
build.gradle
@@ -11,10 +11,9 @@ buildscript {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
+ maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
- classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
- classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.10"
classpath "gradle.plugin.io.sdkman:gradle-sdkvendor-plugin:1.1.0"
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:4.3.0"
}
@@ -22,9 +21,14 @@ buildscript {
// modern plugins config
plugins {
+ id "signing"
+ id "io.codearte.nexus-staging" version "0.22.0"
+ id "de.marcphilipp.nexus-publish" version "0.4.0"
id 'com.github.jruby-gradle.base' version '2.0.0'
}
+apply plugin: 'io.codearte.nexus-staging'
+
// TIP use -PpublishRelease=true to active release behavior regardless of the version
status = project.hasProperty('publishRelease') && project.publishRelease.toBoolean() ?
'release' : ((version == 'unspecified' || version.endsWith('-SNAPSHOT')) ? 'snapshot' : 'release')
@@ -32,6 +36,17 @@ status = project.hasProperty('publishRelease') && project.publishRelease.toBoole
// using ExpandoMetaClass to add isDistribution() Method to Project instances...
Project.metaClass.isDistribution = { delegate.getName().endsWith("-distribution") }
+nexusStaging {
+ if (project.hasProperty("sonatypeUsername")) {
+ username = project.sonatypeUsername
+ }
+ if (project.hasProperty("sonatypePassword")) {
+ password = project.sonatypePassword
+ }
+ repositoryDescription = "Release ${project.group} ${project.version}"
+}
+
+
ext {
buildDateTime = new Date()
(buildDateOnly, buildTimeOnly) = new java.text.SimpleDateFormat('yyyy-MM-dd HH:mm:ss.SSSZ').format(buildDateTime).split(' ')
@@ -50,8 +65,8 @@ ext {
jcommanderVersion = '1.72'
jrubyVersion = '9.2.13.0'
jsoupVersion = '1.12.1'
- junitVersion = '4.12'
- nettyVersion = '4.0.33.Final'
+ junitVersion = '4.13.1'
+ nettyVersion = '4.1.58.Final'
saxonVersion = '9.9.0-2'
xmlMatchersVersion = '1.0-RC1'
pdfboxVersion = '1.8.10'
@@ -85,19 +100,6 @@ subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
- if (!it.name.endsWith('-documentation') && !it.name.endsWith('-wildfly-integration-test')) {
-
- apply from: rootProject.file('gradle/signing.gradle')
- if (!it.isDistribution()){
- apply from: rootProject.file('gradle/publish.gradle')
- }
- if (statusIsRelease) {
- apply from: rootProject.file('gradle/deploy.gradle')
- } else if (it.version.endsWith('SNAPSHOT')) {
- apply from: rootProject.file('gradle/deploySnapshot.gradle')
- }
- }
-
status = _status
// NOTE sourceCompatibility & targetCompatibility are set in gradle.properties to meet requirements of Gradle
@@ -125,8 +127,7 @@ subprojects {
if (project.hasProperty('useMavenLocal') && project.useMavenLocal.toBoolean()) {
mavenLocal()
}
-
- jcenter()
+ mavenCentral()
}
apply plugin: 'codenarc'
@@ -207,21 +208,9 @@ configure(subprojects.findAll { !it.isDistribution() }) {
configure(subprojects.findAll { !it.name.endsWith('-distribution') && ! it.name.endsWith('-documentation')}) {
- task sourcesJar(type: Jar, dependsOn: classes, group: 'Release') {
- description 'Assembles a jar archive containing the main source code.'
- from sourceSets.main.allSource
- classifier 'sources'
- }
-
- task javadocJar(type: Jar, dependsOn: javadoc, group: 'Release') {
- description 'Assembles a jar archive containing the Javadoc API documentation for the main source code.'
- from javadoc.destinationDir
- classifier 'javadoc'
- }
-
- // jcenter & Maven Central requires sources & javadoc jars (even if empty), so give 'em what they want
- artifacts {
- archives sourcesJar, javadocJar
+ java {
+ withJavadocJar()
+ withSourcesJar()
}
jruby {

DELETE
gradle/deploy.gradle
-apply plugin: 'com.jfrog.bintray'
-
-bintray {
- user = System.env['BINTRAY_USER'] ?: (project.hasProperty('bintrayUsername') ? project.bintrayUsername : '')
- key = System.env['BINTRAY_KEY'] ?: (project.hasProperty('bintrayApiKey') ? project.bintrayApiKey : '')
-
- if ( !project.isDistribution() ) {
- publications = ['jars']
- }
- else {
- configurations = ['archives']
- }
-
- if ( !project.hasProperty('skip.signing') ) {
- // Copy the signed pom to bintrayDestination
- filesSpec {
- from signPom
- into signPom.bintrayDestination
- }
- bintrayUpload.dependsOn signPom
- }
-
- dryRun = project.hasProperty('dryRun') && project.dryRun.toBoolean()
- publish = project.statusIsRelease
-
- pkg {
- repo = System.env['BINTRAY_REPO'] ?: (project.hasProperty('bintrayRepo') ? project.bintrayRepo : 'maven')
- if (!project.hasProperty('bintrayPersonal')) {
- userOrg = 'asciidoctor'
- }
-
- if (project.name.endsWith('-distribution')) {
- name = project(':asciidoctorj').name
- desc = project(':asciidoctorj').description
- }
- else {
- name = project.name
- desc = project.description
- }
-
- // NOTE use this instead if we want to list all artifacts under the same package
- //name = project(':asciidoctorj').name
- //desc = project(':asciidoctorj').description
-
- licenses = ['Apache-2.0']
- labels = ['asciidoctor', 'asciidoctorj', 'asciidoc']
- websiteUrl = 'http://asciidoctor.org/docs/asciidoctorj'
- issueTrackerUrl = 'https://github.com/asciidoctor/asciidoctorj/issues'
- vcsUrl = 'https://github.com/asciidoctor/asciidoctorj'
- publicDownloadNumbers = true
-
- version {
- name = project.version
- // NOTE customize the vcsTag if you're only releasing a subproject
- vcsTag = "${rootProject.name}-${rootProject.version}"
- //released = "$buildDateOnly"
- // desc = ...
- }
- }
-}
-
-bintrayUpload.dependsOn build

DELETE
gradle/deploySnapshot.gradle
-apply plugin: 'com.jfrog.artifactory'
-
-artifactory {
- contextUrl = 'https://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver
- publish {
- repository {
- repoKey = 'oss-snapshot-local'
- username = System.env['BINTRAY_USER'] ?: (project.hasProperty('bintrayUsername') ? project.bintrayUsername : '')
- password = System.env['BINTRAY_KEY'] ?: (project.hasProperty('bintrayApiKey') ? project.bintrayApiKey : '')
- maven = true
- }
- defaults {
-
- if ( !project.isDistribution() && !project.name.endsWith('-documentation') ) {
- publications('jars')
- }
- else {
- publicConfigs('archives')
- }
-
- def dryRun = project.hasProperty('dryRun') && project.dryRun.toBoolean()
- publishBuildInfo = !dryRun //Publish build-info to Artifactory (true by default)
- publishArtifacts = !dryRun //Publish artifacts to Artifactory (true by default)
- publishPom = !dryRun && !project.isDistribution() //Publish generated POM files to Artifactory (true by default).
- publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default).
-
- }
- }
-}
-
-artifactoryPublish.dependsOn build

MODIFY
gradle/publish.gradle
gradle/publish.gradle
-// NOTE replace deficient built-in publishing plugin with nebula-publishing,
-// which does a better job generating the POM and properly aggregates signature files for upload to Bintray
-apply plugin: 'maven-publish'
+nexusPublishing {
+ repositories {
+ sonatype()
+ }
+}
+
+publishing {
+ publications.create(project.ext.publicationName, MavenPublication) {
+ pom {
+ name = project.name
+ description = project.description
+ url = 'https://github.com/asciidoctor/asciidoctorj'
-def projectMeta = {
- resolveStrategy = groovy.lang.Closure.DELEGATE_FIRST
- name project.name
- description project.description
- url 'https://github.com/asciidoctor/asciidoctorj'
- inceptionYear '2013'
licenses {
license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- issueManagement {
- system 'github'
- url 'https://github.com/asciidoctor/asciidoctorj/issues'
+ name = 'The Apache Software License, Version 2.0'
+ url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ distribution = 'repo'
}
- scm {
- url 'https://github.com/asciidoctor/asciidoctorj'
}
developers {
developer {
- id 'asotobu'
- name 'Alex Soto Bueno'
- email 'asotobu@gmail.com'
- timezone '1'
- roles {
- role 'Contributor'
- }
+ id = 'asotobu'
+ name = 'Alex Soto Bueno'
+ email = 'asotobu@gmail.com'
+ timezone = '1'
+ roles = ['Contributor']
}
developer {
- id 'mojavelinux'
- name 'Dan Allen'
- email 'dan.j.allen@gmail.com'
- timezone '-7'
- roles {
- role 'Contributor'
- }
+ id = 'mojavelinux'
+ name = 'Dan Allen'
+ email = 'dan.j.allen@gmail.com'
+ timezone = '-7'
+ roles = ['Contributor']
}
developer {
- id 'abelsromero'
- name 'Abel Salgado Romero'
- email 'abelromero@gmail.com'
- timezone '1'
- roles {
- role 'Contributor'
- }
+ id = 'abelsromero'
+ name = 'Abel Salgado Romero'
+ email = 'abelromero@gmail.com'
+ timezone = '1'
+ roles = ['Contributor']
}
developer {
- id 'robertpanzer'
- name 'Robert Panzer'
- email 'robert.panzer.pb@gmail.com'
- timezone '1'
- roles {
- role 'Project Lead'
- }
- }
- }
-}
-
-afterEvaluate {
- publishing.publications {
- jars(MavenPublication) {
-
- // NOTE only build sources and javadoc jars when releasing
- if (project.statusIsRelease) {
- if (project.tasks.withType(Jar).findByName('sourcesJar')) {
- artifact sourcesJar
- }
- if (project.tasks.withType(Jar).findByName('javadocJar')) {
- artifact javadocJar
- }
- }
-
- pom.withXml {
- asNode().children().last() + projectMeta
+ id = 'robertpanzer'
+ name = 'Robert Panzer'
+ email = 'robert.panzer.pb@gmail.com'
+ timezone = '1'
+ roles = ['Project Lead']
}
-
- if (!project.isDistribution()) {
- from components.java
}
}
}
}
-if ( !project.hasProperty('skip.signing') ) {
- task addSignaturesToPublication(dependsOn: signArchives) {
- group "publishing"
- description "add all signatures to the publication"
-
- doLast {
- publishing.publications {
- jars(MavenPublication) {
- configurations.signatures.getArtifacts().each { sig ->
- logger.debug "adding signature to jars publication: $sig"
- artifact(sig) {
- extension "jar.asc"
- }
- }
- }
- }
- }
- }
-
- tasks["signPom"].finalizedBy addSignaturesToPublication
-}
-
// QUESTION should we move manifest creation to general Java plugin config?
jar {
manifest {
@@ -125,3 +68,16 @@ jar {
'Implementation-Vendor': 'asciidoctor.org'
}
}
+
+publishing {
+ repositories {
+ maven {
+ name = "local"
+ // change URLs to point to your repos, e.g. http://my.org/repo
+ def releasesRepoUrl = "${rootProject.buildDir}/repos/releases"
+ def snapshotsRepoUrl = "${rootProject.buildDir}/repos/snapshots"
+ url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
+ }
+ }
+}
+

MODIFY
gradle/signing.gradle
gradle/signing.gradle
-if ( !project.hasProperty('skip.signing') ){
+def hasSigningKey = project.hasProperty("signing.keyId") || project.findProperty("signingKey")
+if(hasSigningKey && !project.hasProperty('skip.signing')) {
apply plugin: 'signing'
-
- signing {
- sign configurations.archives
- }
-
- if ( !signing.signatory ) {
- logger.warn "No Signatory configured for project $project.name. Skip signing! See https://docs.gradle.org/current/userguide/signing_plugin.html"
- signArchives.enabled = false
- ext."skip.signing" = true
- }
-
- task signPom(type: Sign) {
- group "publishing"
- description "Sign the projects pom file"
-
- ext.pom = file("$buildDir/publications/jars/pom-default.xml")
- ext.signedPom = file("$buildDir/publications/jars/${project.name}-${project.version}.pom.asc")
- ext.bintrayDestination = "${project.group.replace(".","/")}/${project.name}/${project.version}"
-
- inputs.file pom
- outputs.file signedPom
-
- doLast{
-
- def input = pom.newInputStream()
- def output = signedPom.newOutputStream()
- try{
- signatory.sign(input, output)
- }
- catch (Exception e){
- logger.error e.message
- }
- finally {
- input.close()
- output.close()
- }
- }
- }
-
- /**
- * The signPom Task depends on the GenerateMavenPom task which gets dynamically added
- * with a name derived from a publication. In our case 'jars'.
- *
- * Our jars publication registers the signed pom as artifact.
- * If the task does not run before publishJarsPublicationToMavenLocal this task will fail.
- */
- tasks.whenTaskAdded {
-
- switch (it.name) {
- case "generatePomFileForJarsPublication":
- signPom.dependsOn it
- break
- case "publishJarsPublicationToMavenLocal":
- it.dependsOn signPom
- break
- }
+ sign(project)
+}
+void sign(Project project) {
+ project.signing {
+ required { project.gradle.taskGraph.hasTask("required") }
+ def signingKeyId = project.findProperty("signingKeyId")
+ def signingKey = project.findProperty("signingKey")
+ def signingPassword = project.findProperty("signingPassword")
+ if (signingKeyId) {
+ useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
+ } else if (signingKey) {
+ useInMemoryPgpKeys(signingKey, signingPassword)
+ }
+ sign publishing.publications[project.ext.publicationName]
}
}
\ No newline at end of file

MODIFY
gradle/wrapper/gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Move publishing from bintray to Maven central