Added semver plugin.
Cleanup.
This commit is contained in:
parent
39693cb398
commit
7db6cbc839
1 changed files with 41 additions and 93 deletions
134
build.gradle
134
build.gradle
|
@ -1,45 +1,17 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id "com.jfrog.bintray" version "1.8.3"
|
||||
id "com.github.ben-manes.versions" version "0.20.0"
|
||||
id "net.thauvin.erik.gradle.semver" version "0.9.5-beta"
|
||||
}
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
defaultTasks 'deploy'
|
||||
defaultTasks 'check'
|
||||
|
||||
def getVersion(isIncrement = false) {
|
||||
def propsFile = 'version.properties'
|
||||
def majorKey = 'version.major'
|
||||
def minorKey = 'version.minor'
|
||||
def patchKey = 'version.patch'
|
||||
def metaKey = 'version.buildmeta'
|
||||
def preKey = 'version.prerelease'
|
||||
if (isIncrement) {
|
||||
ant.propertyfile(file: propsFile) {
|
||||
entry(key: patchKey,
|
||||
type: 'int',
|
||||
default: '-1',
|
||||
operation: '+')
|
||||
}
|
||||
}
|
||||
def p = new Properties()
|
||||
file(propsFile).withInputStream { stream -> p.load(stream) }
|
||||
def metadata = p.getProperty(metaKey, '')
|
||||
def prerelease = p.getProperty(preKey, '')
|
||||
return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') +
|
||||
(prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : ''))
|
||||
}
|
||||
|
||||
version = getVersion()
|
||||
group = 'net.thauvin.erik'
|
||||
|
||||
def deployDir = 'deploy'
|
||||
def isRelease = 'release' in gradle.startParameter.taskNames
|
||||
|
||||
def mavenName = 'SemVer'
|
||||
def mavenDescription = 'Semantic Version Annotation Processor'
|
||||
def mavenUrl = 'https://github.com/ethauvin/semver'
|
||||
|
@ -83,7 +55,7 @@ bintray {
|
|||
publicDownloadNumbers = true
|
||||
version {
|
||||
name = project.version
|
||||
desc = 'Version ' + project.version
|
||||
desc = "Version $project.version"
|
||||
vcsTag = project.version
|
||||
gpg {
|
||||
sign = true
|
||||
|
@ -92,28 +64,6 @@ bintray {
|
|||
}
|
||||
}
|
||||
|
||||
def pomConfig = {
|
||||
licenses {
|
||||
license {
|
||||
name mavenLicense
|
||||
url mavenLicenseUrl
|
||||
distribution 'repo'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id 'ethauvin'
|
||||
name 'Erik C. Thauvin'
|
||||
email 'erik@thauvin.net'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection 'scm:git:' + mavenScmCon
|
||||
developerConnection 'scm:git:' + mavenScmDevCon
|
||||
url mavenScmCon
|
||||
}
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
group = 'Build'
|
||||
description = 'Builds an archive of the javadoc docs.'
|
||||
|
@ -141,28 +91,45 @@ publishing {
|
|||
artifact javadocJar
|
||||
groupId project.group
|
||||
artifactId rootProject.name
|
||||
version project.version
|
||||
|
||||
pom.withXml {
|
||||
def root = asNode()
|
||||
root.appendNode('name', mavenName)
|
||||
root.appendNode('description', mavenDescription)
|
||||
root.appendNode('url', mavenUrl)
|
||||
root.children().last() + pomConfig
|
||||
pom {
|
||||
name = mavenName
|
||||
description = mavenDescription
|
||||
url = mavenUrl
|
||||
licenses {
|
||||
license {
|
||||
name = mavenLicense
|
||||
url = mavenLicenseUrl
|
||||
distribution = 'repo'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = 'ethauvin'
|
||||
name = 'Erik C. Thauvin'
|
||||
email = 'erik@thauvin.net'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = "scm:git:" + mavenScmCon
|
||||
developerConnection = "scm:git:" + mavenScmDevCon
|
||||
url = mavenScmCon
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
javadoc {
|
||||
title = mavenDescription + ' ' + version
|
||||
options.tags = ['created']
|
||||
options.author = true
|
||||
options.addStringOption('link', 'http://docs.oracle.com/javase/8/docs/api/')
|
||||
//options.addBooleanOption('html5', true)
|
||||
//options.addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc : "$System.env.JAVA_HOME/src.zip")
|
||||
if (JavaVersion.current().isJava8Compatible()) {
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
doFirst {
|
||||
title = "$mavenDescription $project.version API"
|
||||
}
|
||||
options.with {
|
||||
tags = ['created']
|
||||
author = true
|
||||
addBooleanOption('html4', true)
|
||||
links('https://docs.oracle.com/javase/8/docs/api/')
|
||||
addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,37 +138,18 @@ test {
|
|||
}
|
||||
|
||||
compileJava {
|
||||
doFirst {
|
||||
project.version = getVersion(isRelease)
|
||||
}
|
||||
options.compilerArgs.add('-proc:none')
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
options.compilerArgs.add('-proc:none')
|
||||
}
|
||||
|
||||
clean {
|
||||
delete deployDir
|
||||
}
|
||||
|
||||
task copyToDeploy(type: Copy) {
|
||||
from jar
|
||||
into deployDir
|
||||
}
|
||||
|
||||
task deploy(dependsOn: ['build', 'copyToDeploy']) {
|
||||
description = 'Copies all needed files to the ${deployDir} directory.'
|
||||
task release(dependsOn: ['wrapper', 'clean', 'publishToMavenLocal']) {
|
||||
group = 'Publishing'
|
||||
outputs.dir deployDir
|
||||
inputs.files copyToDeploy
|
||||
mustRunAfter clean
|
||||
}
|
||||
|
||||
task release(dependsOn: ['wrapper', 'clean', 'deploy']) {
|
||||
group = 'Publishing'
|
||||
description = 'Releases new version.'
|
||||
description = 'Releases new version to local maven repository.'
|
||||
doFirst {
|
||||
isRelease = true
|
||||
println("Version: $version")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue