-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from robertpanzer/maven-central
Publish to Maven Central
- Loading branch information
Showing
7 changed files
with
133 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
version=1.6.0 | ||
sourceCompatibility=1.7 | ||
targetCompatibility=1.7 | ||
sourceCompatibility=1.8 | ||
targetCompatibility=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,94 @@ | ||
// 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' | ||
apply plugin: 'de.marcphilipp.nexus-publish' | ||
|
||
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-pdf/issues' | ||
} | ||
scm { | ||
url 'https://github.com/asciidoctor/asciidoctorj-pdf' | ||
} | ||
developers { | ||
developer { | ||
id 'asotobu' | ||
name 'Alex Soto Bueno' | ||
email '[email protected]' | ||
timezone '1' | ||
roles { | ||
role 'Project Lead' | ||
} | ||
} | ||
developer { | ||
id 'mojavelinux' | ||
name 'Dan Allen' | ||
email '[email protected]' | ||
timezone '-7' | ||
roles { | ||
role 'Contributor' | ||
publishing { | ||
publications.create(project.ext.publicationName, MavenPublication) { | ||
|
||
from components.java | ||
|
||
pom { | ||
name = project.name | ||
description = project.description | ||
url = 'https://github.com/asciidoctor/asciidoctorj-pdf' | ||
inceptionYear = '2013' | ||
licenses { | ||
license { | ||
name = 'The Apache Software License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
distribution = 'repo' | ||
} | ||
} | ||
} | ||
developer { | ||
id 'abelsromero' | ||
name 'Abel Salgado Romero' | ||
email '[email protected]' | ||
timezone '1' | ||
roles { | ||
role 'Contributor' | ||
issueManagement { | ||
system = 'github' | ||
url = 'https://github.com/asciidoctor/asciidoctorj-pdf/issues' | ||
} | ||
} | ||
developer { | ||
id 'robertpanzer' | ||
name 'Robert Panzer' | ||
email '[email protected]' | ||
timezone '1' | ||
roles { | ||
role 'Contributor' | ||
scm { | ||
url = 'https://github.com/asciidoctor/asciidoctorj-pdf' | ||
} | ||
} | ||
} | ||
} | ||
|
||
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 | ||
developers { | ||
developer { | ||
id = 'asotobu' | ||
name = 'Alex Soto Bueno' | ||
email = '[email protected]' | ||
timezone = '1' | ||
roles = ['Project Lead'] | ||
} | ||
if (project.tasks.withType(Jar).findByName('javadocJar')) { | ||
artifact javadocJar | ||
developer { | ||
id = 'mojavelinux' | ||
name = 'Dan Allen' | ||
email = '[email protected]' | ||
timezone = '-7' | ||
roles = ['Contributor'] | ||
} | ||
developer { | ||
id = 'abelsromero' | ||
name = 'Abel Salgado Romero' | ||
email = '[email protected]' | ||
timezone = '1' | ||
roles = ['Contributor'] | ||
} | ||
developer { | ||
id = 'robertpanzer' | ||
name = 'Robert Panzer' | ||
email = '[email protected]' | ||
timezone = '1' | ||
roles = ['Contributor'] | ||
} | ||
} | ||
|
||
pom.withXml { | ||
asNode().children().last() + projectMeta | ||
} | ||
|
||
from components.java | ||
} | ||
} | ||
} | ||
|
||
if ( !project.hasProperty('skip.signing') ) { | ||
task addSignaturesToPublication(dependsOn: signArchives) { | ||
group "publishing" | ||
description "add all signatures to the publication" | ||
// QUESTION should we move manifest creation to general Java plugin config? | ||
jar { | ||
manifest { | ||
attributes \ | ||
'Built-By': System.properties['user.name'], | ||
'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(), | ||
'Build-Date': buildDateOnly, | ||
//'Build-Time': buildTimeOnly, | ||
//'Specification-Title': project.name, | ||
//'Specification-Version': project.version, | ||
//'Specification-Vendor': 'asciidoctor.org', | ||
'Implementation-Title': project.name, | ||
'Implementation-Version': project.version, | ||
'Implementation-Vendor': 'asciidoctor.org' | ||
} | ||
} | ||
|
||
doLast { | ||
publishing.publications { | ||
jars(MavenPublication) { | ||
configurations.signatures.getArtifacts().each { sig -> | ||
logger.debug "adding signature to jars publication: $sig" | ||
artifact(sig) { | ||
extension "jar.asc" | ||
} | ||
} | ||
} | ||
} | ||
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 | ||
} | ||
} | ||
|
||
tasks["signPom"].finalizedBy addSignaturesToPublication | ||
} | ||
|
||
// QUESTION should we move manifest creation to general Java plugin config? | ||
jar { | ||
manifest { | ||
attributes \ | ||
'Built-By': System.properties['user.name'], | ||
'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(), | ||
'Build-Date': buildDateOnly, | ||
//'Build-Time': buildTimeOnly, | ||
//'Specification-Title': project.name, | ||
//'Specification-Version': project.version, | ||
//'Specification-Vendor': 'asciidoctor.org', | ||
'Implementation-Title': project.name, | ||
'Implementation-Version': project.version, | ||
'Implementation-Vendor': 'asciidoctor.org' | ||
} | ||
nexusPublishing { | ||
repositories { | ||
sonatype() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,19 @@ | ||
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] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.