Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
204 lines (175 sloc) 5.33 KB
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'eclipse'
apply plugin: 'idea'
repositories {
mavenLocal()
mavenCentral()
}
buildDir = 'target'
version = '1.1'
sourceCompatibility = 1.8
targetCompatibility = 1.8
eclipse {
classpath {
// enable here source download if needed
downloadJavadoc = false
downloadSources = false
}
}
idea {
module {}
}
configurations {
all {
transitive = false
}
// for demo build
pzdcdoc {
transitive = true
}
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.2'
compile group: 'org.jsoup', name: 'jsoup', version: '1.11.3'
compile group: 'org.asciidoctor', name: 'asciidoctorj', version: '1.5.6'
compile group: 'com.beust', name: 'jcommander', version: '1.35'
compile group: 'org.jruby', name: 'jruby-complete', version: '1.7.26'
// for demo build
pzdcdoc group: 'org.pzdcdoc', name: 'pzdcdoc', version: "${project.version}"
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}
// demo build
task buildDemoDoc(type:JavaExec) {
classpath = configurations.pzdcdoc
main = 'org.pzdcdoc.DocGenerator'
args 'demo/cfg', 'demo/src', 'target/doc'
}
task sourceJar(type: Jar) {
classifier "sources"
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc.destinationDir
}
artifacts {
archives sourceJar
archives javadocJar
}
signing {
sign configurations.archives
}
// https://medium.com/@nmauti/publishing-a-project-on-maven-central-8106393db2c3
// https://medium.com/@nmauti/sign-and-publish-on-maven-central-a-project-with-the-new-maven-publish-gradle-plugin-22a72a4bfd4b
publishing {
publications {
mavenJava(MavenPublication) {
customizePom(pom)
groupId 'org.pzdcdoc'
artifactId 'pzdcdoc'
version "${project.version}"
from components.java
// create the sign pom artifact
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
}
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
// create the signed artifacts
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
if (matcher.find()) {
classifier = matcher.group(1)
} else {
classifier = null
}
extension = 'jar.asc'
}
}
}
}
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username findProperty('sonatypeUsername')
password findProperty('sonatypePassword')
}
}
}
}
def customizePom(pom) {
pom.withXml {
def root = asNode()
// change packaging from pom
root.packaging[0].value = 'jar'
// eliminate test-scoped dependencies (no need in maven central POMs)
root.dependencies.removeAll { dep ->
dep.scope == "test"
}
// add all items necessary for maven central publication
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
description 'AsciiDoctor based documentation generation tool'
name 'PzdcDoc'
url 'https://github.com/pzdcdoc/pzdcdoc'
organization {
name 'org.pzdcdoc'
url 'https://github.com/pzdcdoc'
}
issueManagement {
system 'GitHub'
url 'https://github.com/pzdcdoc/pzdcdoc/issues'
}
licenses {
license {
name 'MIT License'
url 'https://github.com/pzdcdoc/pzdcdoc/blob/master/LICENSE'
distribution 'repo'
}
}
scm {
url 'https://github.com/pzdcdoc/pzdcdoc'
connection 'scm:git:git://github.com/pzdcdoc/pzdcdoc.git'
developerConnection 'scm:git:ssh://git@github.com:pzdcdoc/pzdcdoc.git'
}
developers {
developer {
name 'Shamil Vakhitov'
}
}
}
}
}
model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
}
tasks.publishMavenJavaPublicationToMavenLocal {
dependsOn project.tasks.signArchives
}
tasks.publishMavenJavaPublicationToMavenRepository {
dependsOn project.tasks.signArchives
}
}
You can’t perform that action at this time.