Code format, tabs to spaces, etc.
This commit is contained in:
parent
3973b144bc
commit
240c928e77
16 changed files with 826 additions and 667 deletions
24
.idea/modules/example.iml
generated
Normal file
24
.idea/modules/example.iml
generated
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id="example" external.linked.project.path="$MODULE_DIR$/../../example" external.root.project.path="$MODULE_DIR$/../../example" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="3.1.45-beta" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
|
<output url="file://$MODULE_DIR$/../../example/build/classes/main" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/../../example/build/classes/test" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$/../../example">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../example/src/generated/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../example/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../example/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../example/src/annotationProcessor/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../example/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/../../example/src/test/resources" type="java-test-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../example/.gradle" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../example/build" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Gradle: net.thauvin.erik:semver:0.9.6-beta" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Gradle: commons-lang:commons-lang:2.4" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Gradle: commons-collections:commons-collections:3.2.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.apache.velocity:velocity:1.7" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
12
.idea/modules/semver.iml
generated
12
.idea/modules/semver.iml
generated
|
@ -15,12 +15,12 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="Gradle: org.apache.velocity:velocity:1.7" level="project" />
|
<orderEntry type="library" name="Gradle: org.apache.velocity:velocity:1.7" level="project" />
|
||||||
<orderEntry type="library" name="Gradle: commons-collections:commons-collections:3.2.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Gradle: commons-lang:commons-lang:2.4" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: org.testng:testng:6.9.12" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: org.beanshell:bsh:2.0b4" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: com.beust:jcommander:1.48" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: org.apache.ant:ant:1.7.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="TEST" name="Gradle: org.apache.ant:ant-launcher:1.7.0" level="project" />
|
<orderEntry type="library" scope="TEST" name="Gradle: org.apache.ant:ant-launcher:1.7.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Gradle: org.apache.ant:ant:1.7.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Gradle: com.beust:jcommander:1.48" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Gradle: org.beanshell:bsh:2.0b4" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Gradle: org.testng:testng:6.9.12" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: commons-lang:commons-lang:2.4" level="project" />
|
||||||
|
<orderEntry type="library" name="Gradle: commons-collections:commons-collections:3.2.1" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
269
build.gradle
269
build.gradle
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "com.jfrog.bintray" version "1.5"
|
id "com.jfrog.bintray" version "1.5"
|
||||||
}
|
}
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
|
@ -10,29 +10,27 @@ import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
|
|
||||||
defaultTasks 'deploy'
|
defaultTasks 'deploy'
|
||||||
|
|
||||||
def getVersion(isIncrement = false)
|
def getVersion(isIncrement = false) {
|
||||||
{
|
def propsFile = 'version.properties'
|
||||||
def propsFile = 'version.properties'
|
def majorKey = 'version.major'
|
||||||
def majorKey = 'version.major'
|
def minorKey = 'version.minor'
|
||||||
def minorKey = 'version.minor'
|
def patchKey = 'version.patch'
|
||||||
def patchKey = 'version.patch'
|
def metaKey = 'version.buildmeta'
|
||||||
def metaKey = 'version.buildmeta'
|
def preKey = 'version.prerelease'
|
||||||
def preKey = 'version.prerelease'
|
if (isIncrement) {
|
||||||
if (isIncrement)
|
ant.propertyfile(file: propsFile) {
|
||||||
{
|
entry(key: patchKey,
|
||||||
ant.propertyfile(file: propsFile) {
|
type: 'int',
|
||||||
entry(key: patchKey,
|
default: '-1',
|
||||||
type: 'int',
|
operation: '+')
|
||||||
default: '-1',
|
}
|
||||||
operation: '+')
|
}
|
||||||
}
|
def p = new Properties()
|
||||||
}
|
file(propsFile).withInputStream { stream -> p.load(stream) }
|
||||||
def p = new Properties()
|
def metadata = p.getProperty(metaKey, '')
|
||||||
file(propsFile).withInputStream { stream -> p.load(stream) }
|
def prerelease = p.getProperty(preKey, '')
|
||||||
def metadata = p.getProperty(metaKey, '')
|
return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') +
|
||||||
def prerelease = p.getProperty(preKey, '')
|
(prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : ''))
|
||||||
return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') +
|
|
||||||
(prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : ''))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = getVersion()
|
version = getVersion()
|
||||||
|
@ -56,167 +54,162 @@ def pkgLabels = ['java', 'annotation', 'processor', 'semantic', 'version']
|
||||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'org.apache.velocity:velocity:1.7'
|
compile 'org.apache.velocity:velocity:1.7'
|
||||||
testCompile 'org.testng:testng:6.9.12'
|
testCompile 'org.testng:testng:6.9.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
bintray {
|
bintray {
|
||||||
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
||||||
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
||||||
publications = ['MyPublication']
|
publications = ['MyPublication']
|
||||||
dryRun = true
|
dryRun = true
|
||||||
pkg {
|
pkg {
|
||||||
repo = 'maven'
|
repo = 'maven'
|
||||||
name = mavenName
|
name = mavenName
|
||||||
licenses = pkgLicenses
|
licenses = pkgLicenses
|
||||||
desc = mavenDescription
|
desc = mavenDescription
|
||||||
websiteUrl = mavenUrl
|
websiteUrl = mavenUrl
|
||||||
issueTrackerUrl = pkgIssueTrackerUrl
|
issueTrackerUrl = pkgIssueTrackerUrl
|
||||||
vcsUrl = mavenScmCon
|
vcsUrl = mavenScmCon
|
||||||
labels = pkgLabels
|
labels = pkgLabels
|
||||||
publicDownloadNumbers = true
|
publicDownloadNumbers = true
|
||||||
version {
|
version {
|
||||||
name = project.version
|
name = project.version
|
||||||
desc = 'Version ' + project.version
|
desc = 'Version ' + project.version
|
||||||
vcsTag = project.version
|
vcsTag = project.version
|
||||||
gpg {
|
gpg {
|
||||||
sign = true
|
sign = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def pomConfig = {
|
def pomConfig = {
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name mavenLicense
|
name mavenLicense
|
||||||
url mavenLicenseUrl
|
url mavenLicenseUrl
|
||||||
distribution 'repo'
|
distribution 'repo'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
developers {
|
developers {
|
||||||
developer {
|
developer {
|
||||||
id 'ethauvin'
|
id 'ethauvin'
|
||||||
name 'Erik C. Thauvin'
|
name 'Erik C. Thauvin'
|
||||||
email 'erik@thauvin.net'
|
email 'erik@thauvin.net'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scm {
|
scm {
|
||||||
connection 'scm:git:' + mavenScmCon
|
connection 'scm:git:' + mavenScmCon
|
||||||
developerConnection 'scm:git:' + mavenScmDevCon
|
developerConnection 'scm:git:' + mavenScmDevCon
|
||||||
url mavenScmCon
|
url mavenScmCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
MyPublication(MavenPublication) {
|
MyPublication(MavenPublication) {
|
||||||
from components.java
|
from components.java
|
||||||
artifact sourcesJar
|
artifact sourcesJar
|
||||||
artifact javadocJar
|
artifact javadocJar
|
||||||
groupId mavenGroupId
|
groupId mavenGroupId
|
||||||
artifactId rootProject.name
|
artifactId rootProject.name
|
||||||
version project.version
|
version project.version
|
||||||
|
|
||||||
pom.withXml {
|
pom.withXml {
|
||||||
def root = asNode()
|
def root = asNode()
|
||||||
root.appendNode('name', mavenName)
|
root.appendNode('name', mavenName)
|
||||||
root.appendNode('description', mavenDescription)
|
root.appendNode('description', mavenDescription)
|
||||||
root.appendNode('url', mavenUrl)
|
root.appendNode('url', mavenUrl)
|
||||||
root.children().last() + pomConfig
|
root.children().last() + pomConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||||
group = 'Build'
|
group = 'Build'
|
||||||
description = 'Builds an archive of the javadoc docs.'
|
description = 'Builds an archive of the javadoc docs.'
|
||||||
classifier = 'javadoc'
|
classifier = 'javadoc'
|
||||||
from javadoc.destinationDir
|
from javadoc.destinationDir
|
||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
group = 'Build'
|
group = 'Build'
|
||||||
description = 'Builds an archive of the source code.'
|
description = 'Builds an archive of the source code.'
|
||||||
classifier = 'sources'
|
classifier = 'sources'
|
||||||
from sourceSets.main.allSource
|
from sourceSets.main.allSource
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
archives javadocJar
|
archives javadocJar
|
||||||
archives sourcesJar
|
archives sourcesJar
|
||||||
}
|
}
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
title = mavenDescription + ' ' + version
|
title = mavenDescription + ' ' + version
|
||||||
options.tags = ['created']
|
options.tags = ['created']
|
||||||
options.author = true
|
options.author = true
|
||||||
options.addStringOption('link', 'http://docs.oracle.com/javase/8/docs/api/')
|
options.addStringOption('link', 'http://docs.oracle.com/javase/8/docs/api/')
|
||||||
options.addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc : "$System.env.JAVA_HOME/src.zip")
|
options.addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc : "$System.env.JAVA_HOME/src.zip")
|
||||||
if (JavaVersion.current().isJava8Compatible())
|
if (JavaVersion.current().isJava8Compatible()) {
|
||||||
{
|
options.addStringOption('Xdoclint:none', '-quiet')
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useTestNG()
|
useTestNG()
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
doFirst {
|
doFirst {
|
||||||
project.version = getVersion(isRelease)
|
project.version = getVersion(isRelease)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clean {
|
clean {
|
||||||
delete deployDir
|
delete deployDir
|
||||||
}
|
}
|
||||||
|
|
||||||
task copyToDeploy(type: Copy) {
|
task copyToDeploy(type: Copy) {
|
||||||
from jar
|
from jar
|
||||||
into deployDir
|
into deployDir
|
||||||
}
|
}
|
||||||
|
|
||||||
task deploy(dependsOn: ['build', 'copyToDeploy']) {
|
task deploy(dependsOn: ['build', 'copyToDeploy']) {
|
||||||
description = 'Copies all needed files to the ${deployDir} directory.'
|
description = 'Copies all needed files to the ${deployDir} directory.'
|
||||||
group = 'Publishing'
|
group = 'Publishing'
|
||||||
outputs.dir deployDir
|
outputs.dir deployDir
|
||||||
inputs.files copyToDeploy
|
inputs.files copyToDeploy
|
||||||
mustRunAfter clean
|
mustRunAfter clean
|
||||||
}
|
}
|
||||||
|
|
||||||
task wrapper(type: Wrapper) {
|
task wrapper(type: Wrapper) {
|
||||||
gradleVersion = gradle.gradleVersion
|
gradleVersion = gradle.gradleVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
task release(dependsOn: ['wrapper', 'clean', 'deploy']) << {
|
task release(dependsOn: ['wrapper', 'clean', 'deploy']) << {
|
||||||
group = 'Publishing'
|
group = 'Publishing'
|
||||||
description = 'Releases new version.'
|
description = 'Releases new version.'
|
||||||
isRelease = true
|
isRelease = true
|
||||||
}
|
}
|
||||||
|
|
||||||
task pandoc(type: Exec) {
|
task pandoc(type: Exec) {
|
||||||
group = 'Documentation'
|
group = 'Documentation'
|
||||||
def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-c', 'github-pandoc.css', '-o', 'README.html', 'README.md']
|
def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-c', 'github-pandoc.css', '-o', 'README.html', 'README.md']
|
||||||
if (Os.isFamily(Os.FAMILY_WINDOWS))
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||||
{
|
commandLine(['cmd', '/c', 'pandoc'] + pandoc_args)
|
||||||
commandLine(['cmd', '/c', 'pandoc'] + pandoc_args)
|
} else {
|
||||||
}
|
executable 'pandoc'
|
||||||
else
|
args pandoc_args
|
||||||
{
|
}
|
||||||
executable 'pandoc'
|
standardOutput = new ByteArrayOutputStream()
|
||||||
args pandoc_args
|
ext.output = {
|
||||||
}
|
return standardOutput.toString()
|
||||||
standardOutput = new ByteArrayOutputStream()
|
}
|
||||||
ext.output = {
|
|
||||||
return standardOutput.toString()
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "com.ewerk.gradle.plugins.annotation-processor" version "1.0.2"
|
id "com.ewerk.gradle.plugins.annotation-processor" version "1.0.2"
|
||||||
}
|
}
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
|
@ -11,29 +11,27 @@ def isRelease = 'release' in gradle.startParameter.taskNames
|
||||||
def deployDir = 'deploy'
|
def deployDir = 'deploy'
|
||||||
|
|
||||||
// Get version from properties file. Increment patch if specified.
|
// Get version from properties file. Increment patch if specified.
|
||||||
def getVersion(isIncrement = false)
|
def getVersion(isIncrement = false) {
|
||||||
{
|
def propsFile = 'version.properties'
|
||||||
def propsFile = 'version.properties'
|
def majorKey = 'version.major'
|
||||||
def majorKey = 'version.major'
|
def minorKey = 'version.minor'
|
||||||
def minorKey = 'version.minor'
|
def patchKey = 'version.patch'
|
||||||
def patchKey = 'version.patch'
|
def metaKey = 'version.buildmeta'
|
||||||
def metaKey = 'version.buildmeta'
|
def preKey = 'version.prerelease'
|
||||||
def preKey = 'version.prerelease'
|
if (isIncrement) {
|
||||||
if (isIncrement)
|
ant.propertyfile(file: propsFile) {
|
||||||
{
|
entry(key: patchKey,
|
||||||
ant.propertyfile(file: propsFile) {
|
type: 'int',
|
||||||
entry(key: patchKey,
|
default: '-1',
|
||||||
type: 'int',
|
operation: '+')
|
||||||
default: '-1',
|
}
|
||||||
operation: '+')
|
}
|
||||||
}
|
def p = new Properties()
|
||||||
}
|
file(propsFile).withInputStream { stream -> p.load(stream) }
|
||||||
def p = new Properties()
|
def metadata = p.getProperty(metaKey, '')
|
||||||
file(propsFile).withInputStream { stream -> p.load(stream) }
|
def prerelease = p.getProperty(preKey, '')
|
||||||
def metadata = p.getProperty(metaKey, '')
|
return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') +
|
||||||
def prerelease = p.getProperty(preKey, '')
|
(prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : ''))
|
||||||
return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') +
|
|
||||||
(prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : ''))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = getVersion()
|
version = getVersion()
|
||||||
|
@ -42,55 +40,53 @@ mainClassName = 'net.thauvin.erik.semver.example.Example'
|
||||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'net.thauvin.erik:semver:0.9.6-beta'
|
compileOnly 'net.thauvin.erik:semver:0.9.6-beta'
|
||||||
}
|
}
|
||||||
|
|
||||||
annotationProcessor {
|
annotationProcessor {
|
||||||
// Update version, increment on release.
|
// Update version, increment on release.
|
||||||
project.version = getVersion(isRelease)
|
project.version = getVersion(isRelease)
|
||||||
library 'net.thauvin.erik:semver:0.9.6-beta'
|
library 'net.thauvin.erik:semver:0.9.6-beta'
|
||||||
processor 'net.thauvin.erik.semver.VersionProcessor'
|
processor 'net.thauvin.erik.semver.VersionProcessor'
|
||||||
// sourcesDir 'src/generated/java'
|
// sourcesDir 'src/generated/java'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
options.compilerArgs << '-proc:none'
|
options.compilerArgs << '-proc:none'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest.attributes('Main-Class': mainClassName)
|
manifest.attributes('Main-Class': mainClassName)
|
||||||
}
|
}
|
||||||
|
|
||||||
clean {
|
clean {
|
||||||
delete deployDir
|
delete deployDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
task copyToDeploy(type: Copy) {
|
task copyToDeploy(type: Copy) {
|
||||||
from jar
|
from jar
|
||||||
into deployDir
|
into deployDir
|
||||||
}
|
}
|
||||||
|
|
||||||
task deploy(dependsOn: ['build', 'copyToDeploy']) {
|
task deploy(dependsOn: ['build', 'copyToDeploy']) {
|
||||||
description = 'Copies all needed files to the ${deployDir} directory.'
|
description = 'Copies all needed files to the ${deployDir} directory.'
|
||||||
group = 'Publishing'
|
group = 'Publishing'
|
||||||
outputs.dir deployDir
|
outputs.dir deployDir
|
||||||
inputs.files copyToDeploy
|
inputs.files copyToDeploy
|
||||||
mustRunAfter clean
|
mustRunAfter clean
|
||||||
}
|
}
|
||||||
|
|
||||||
task release(dependsOn: ['wrapper', 'clean', 'deploy']) << {
|
task release(dependsOn: ['wrapper', 'clean', 'deploy']) << {
|
||||||
group = 'Publishing'
|
group = 'Publishing'
|
||||||
description = 'Releases new version.'
|
description = 'Releases new version.'
|
||||||
isRelease = true
|
isRelease = true
|
||||||
}
|
}
|
||||||
|
|
||||||
task wrapper(type: Wrapper) {
|
task wrapper(type: Wrapper) {
|
||||||
gradleVersion = gradle.gradleVersion
|
gradleVersion = gradle.gradleVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
example/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
example/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
#Sat Jan 23 18:16:10 PST 2016
|
#Mon Jul 18 17:32:58 PDT 2016
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
|
||||||
|
|
46
example/gradlew
vendored
46
example/gradlew
vendored
|
@ -6,12 +6,30 @@
|
||||||
##
|
##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Attempt to set APP_HOME
|
||||||
DEFAULT_JVM_OPTS=""
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
@ -30,6 +48,7 @@ die ( ) {
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
case "`uname`" in
|
case "`uname`" in
|
||||||
CYGWIN* )
|
CYGWIN* )
|
||||||
cygwin=true
|
cygwin=true
|
||||||
|
@ -40,26 +59,11 @@ case "`uname`" in
|
||||||
MINGW* )
|
MINGW* )
|
||||||
msys=true
|
msys=true
|
||||||
;;
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
|
@ -85,7 +89,7 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
|
8
example/gradlew.bat
vendored
8
example/gradlew.bat
vendored
|
@ -8,14 +8,14 @@
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS=
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ echo location of your Java installation.
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
:init
|
||||||
@rem Get command-line arguments, handling Windowz variants
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
/*
|
||||||
|
* This file is automatically generated.
|
||||||
|
* Do not modify! -- ALL CHANGES WILL BE ERASED!
|
||||||
|
*/
|
||||||
|
package net.thauvin.erik.semver.example;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides semantic version information.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/ethauvin/semver">Semantic Version
|
||||||
|
* Annotation Processor</a>
|
||||||
|
*/
|
||||||
|
public final class GeneratedVersion {
|
||||||
|
private final static String buildmeta = "";
|
||||||
|
private final static Date date = new Date(1468888435317L);
|
||||||
|
private final static int major = 3;
|
||||||
|
private final static int minor = 1;
|
||||||
|
private final static int patch = 49;
|
||||||
|
private final static String prerelease = "beta";
|
||||||
|
private final static String project = "Example";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables the default constructor.
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException If the constructor is called.
|
||||||
|
*/
|
||||||
|
private GeneratedVersion()
|
||||||
|
throws UnsupportedOperationException {
|
||||||
|
throw new UnsupportedOperationException("Illegal constructor call.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the build date.
|
||||||
|
*
|
||||||
|
* @return The build date.
|
||||||
|
*/
|
||||||
|
public static Date getBuildDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the project name.
|
||||||
|
*
|
||||||
|
* @return The project name, if any.
|
||||||
|
*/
|
||||||
|
public static String getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full version string.
|
||||||
|
* <p>
|
||||||
|
* Formatted as:
|
||||||
|
* <blockquote>
|
||||||
|
* <code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code>
|
||||||
|
* </blockquote>
|
||||||
|
* <p>
|
||||||
|
* For example:
|
||||||
|
* <ul>
|
||||||
|
* <li><code>1.0.0</code></li>
|
||||||
|
* <li><code>1.0.0-beta</code></li>
|
||||||
|
* <li><code>1.0.0+20160124144700</code></li>
|
||||||
|
* <li><code>1.0.0-alpha+001</code></li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @return The version string.
|
||||||
|
*/
|
||||||
|
public static String getVersion() {
|
||||||
|
return Integer.toString(getMajor()) + '.'
|
||||||
|
+ Integer.toString(getMinor()) + '.'
|
||||||
|
+ Integer.toString(getPatch())
|
||||||
|
+ getPreRelease(true) + getBuildMetadata(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the major version.
|
||||||
|
*
|
||||||
|
* @return The major version.
|
||||||
|
*/
|
||||||
|
public static int getMajor() {
|
||||||
|
return major;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the minor version.
|
||||||
|
*
|
||||||
|
* @return The minor version.
|
||||||
|
*/
|
||||||
|
public static int getMinor() {
|
||||||
|
return minor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the patch version.
|
||||||
|
*
|
||||||
|
* @return The patch version.
|
||||||
|
*/
|
||||||
|
public static int getPatch() {
|
||||||
|
return patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pre-release version.
|
||||||
|
*
|
||||||
|
* @param isHyphen Prepend a hyphen, if <code>true</code>.
|
||||||
|
* @return The pre-release version, if any.
|
||||||
|
*/
|
||||||
|
public static String getPreRelease(final boolean isHyphen) {
|
||||||
|
if (prerelease.length() > 0) {
|
||||||
|
if (isHyphen) {
|
||||||
|
return '-' + prerelease;
|
||||||
|
} else {
|
||||||
|
return prerelease;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pre-release version.
|
||||||
|
*
|
||||||
|
* @return The pre-release version, if any.
|
||||||
|
*/
|
||||||
|
public static String getPreRelease() {
|
||||||
|
return getPreRelease(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the build metadata.
|
||||||
|
*
|
||||||
|
* @param isPlus Prepend a plus sign, if <code>true</code>.
|
||||||
|
* @return The build metadata, if any.
|
||||||
|
*/
|
||||||
|
public static String getBuildMetadata(final boolean isPlus) {
|
||||||
|
if (buildmeta.length() > 0) {
|
||||||
|
if (isPlus) {
|
||||||
|
return '+' + buildmeta;
|
||||||
|
} else {
|
||||||
|
return buildmeta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the build metadata.
|
||||||
|
*
|
||||||
|
* @return The build metadata, if any.
|
||||||
|
*/
|
||||||
|
public static String getBuildMetadata() {
|
||||||
|
return getBuildMetadata(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,28 +38,26 @@ import java.text.SimpleDateFormat;
|
||||||
/**
|
/**
|
||||||
* The <code>Example</code> class.
|
* The <code>Example</code> class.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net" target="_blank">Erik C. Thauvin</a>
|
||||||
* @created 2016-01-13
|
* @created 2016-01-13
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
@Version(properties = "version.properties")
|
@Version(properties = "version.properties")
|
||||||
public class Example
|
public class Example {
|
||||||
{
|
public static void main(final String... args) {
|
||||||
public static void main(final String... args)
|
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z");
|
||||||
{
|
|
||||||
final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z");
|
|
||||||
|
|
||||||
System.out.println("-----------------------------------------------------");
|
System.out.println("-----------------------------------------------------");
|
||||||
|
|
||||||
System.out.println(" " + GeneratedVersion.getProject() + ' ' + GeneratedVersion.getVersion());
|
System.out.println(" " + GeneratedVersion.getProject() + ' ' + GeneratedVersion.getVersion());
|
||||||
|
|
||||||
System.out.println(" Built on: " + sdf.format(GeneratedVersion.getBuildDate()));
|
System.out.println(" Built on: " + sdf.format(GeneratedVersion.getBuildDate()));
|
||||||
System.out.println(" Major: " + GeneratedVersion.getMajor());
|
System.out.println(" Major: " + GeneratedVersion.getMajor());
|
||||||
System.out.println(" Minor: " + GeneratedVersion.getMinor());
|
System.out.println(" Minor: " + GeneratedVersion.getMinor());
|
||||||
System.out.println(" Patch: " + GeneratedVersion.getPatch());
|
System.out.println(" Patch: " + GeneratedVersion.getPatch());
|
||||||
System.out.println(" PreRelease: " + GeneratedVersion.getPreRelease());
|
System.out.println(" PreRelease: " + GeneratedVersion.getPreRelease());
|
||||||
System.out.println(" BuildMetaData: " + GeneratedVersion.getBuildMetadata());
|
System.out.println(" BuildMetaData: " + GeneratedVersion.getBuildMetadata());
|
||||||
|
|
||||||
System.out.println("-----------------------------------------------------");
|
System.out.println("-----------------------------------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
#
|
#Mon, 18 Jul 2016 17:33:54 -0700
|
||||||
#Wed Jul 06 19:28:58 PDT 2016
|
|
||||||
version.prerelease=beta
|
version.prerelease=beta
|
||||||
version.project=Example
|
version.project=Example
|
||||||
version.minor=1
|
version.minor=1
|
||||||
version.buildmeta=
|
version.buildmeta=
|
||||||
version.patch=45
|
version.patch=49
|
||||||
version.major=3
|
version.major=3
|
||||||
|
|
43
semver.ipr
43
semver.ipr
|
@ -58,10 +58,27 @@
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
</component>
|
</component>
|
||||||
<component name="CopyrightManager" default="" />
|
<component name="CopyrightManager" default="">
|
||||||
|
<copyright>
|
||||||
|
<option name="myName" value="Erik's Copyright Notice" />
|
||||||
|
<option name="notice" value="&#36;file.fileName Copyright (c) &#36;today.year, Erik C. Thauvin (erik@thauvin.net) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of this project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." />
|
||||||
|
</copyright>
|
||||||
|
<module2copyright>
|
||||||
|
<element module="Source" copyright="Erik's Copyright Notice" />
|
||||||
|
</module2copyright>
|
||||||
|
<LanguageOptions name="__TEMPLATE__">
|
||||||
|
<option name="addBlankAfter" value="false" />
|
||||||
|
</LanguageOptions>
|
||||||
|
</component>
|
||||||
|
<component name="DependencyValidationManager">
|
||||||
|
<scope name="Source" pattern="file[example]:src/main/java//*.java||file[semver]:src/main/java//*.java" />
|
||||||
|
</component>
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
<file url="PROJECT" charset="UTF-8" />
|
<file url="PROJECT" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<entry_points version="2.0" />
|
||||||
|
</component>
|
||||||
<component name="GradleLocalSettings">
|
<component name="GradleLocalSettings">
|
||||||
<option name="modificationStamps">
|
<option name="modificationStamps">
|
||||||
<map>
|
<map>
|
||||||
|
@ -80,7 +97,7 @@
|
||||||
<entry key="$PROJECT_DIR$/../HttpStatus" value="2906561643260" />
|
<entry key="$PROJECT_DIR$/../HttpStatus" value="2906561643260" />
|
||||||
<entry key="$PROJECT_DIR$/../SemanticVersion" value="2905451385982" />
|
<entry key="$PROJECT_DIR$/../SemanticVersion" value="2905451385982" />
|
||||||
<entry key="$PROJECT_DIR$/../mobibot" value="2865248599040" />
|
<entry key="$PROJECT_DIR$/../mobibot" value="2865248599040" />
|
||||||
<entry key="$PROJECT_DIR$" value="2921455760636" />
|
<entry key="$PROJECT_DIR$" value="2921872379706" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
<option name="externalProjectsViewState">
|
<option name="externalProjectsViewState">
|
||||||
|
@ -102,6 +119,18 @@
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
<option name="useAutoImport" value="true" />
|
<option name="useAutoImport" value="true" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="distributionType" value="LOCAL" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$/example" />
|
||||||
|
<option name="gradleHome" value="C:/gradle" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$/example" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
<option name="useAutoImport" value="true" />
|
||||||
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
|
@ -199,6 +228,7 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/example.iml" filepath="$PROJECT_DIR$/.idea/modules/example.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/semver.iml" filepath="$PROJECT_DIR$/.idea/modules/semver.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/semver.iml" filepath="$PROJECT_DIR$/.idea/modules/semver.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
@ -334,6 +364,15 @@
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/commons-lang/commons-lang/2.4/2b8c4b3035e45520ef42033e823c7d33e4b4402c/commons-lang-2.4-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/commons-lang/commons-lang/2.4/2b8c4b3035e45520ef42033e823c7d33e4b4402c/commons-lang-2.4-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
|
<library name="Gradle: net.thauvin.erik:semver:0.9.6-beta">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/semver/0.9.6-beta/semver-0.9.6-beta.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/semver/0.9.6-beta/semver-0.9.6-beta-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
<library name="Gradle: org.apache.ant:ant-launcher:1.7.0">
|
<library name="Gradle: org.apache.ant:ant-launcher:1.7.0">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.7.0/e7e30789211e074aa70ef3eaea59bd5b22a7fa7a/ant-launcher-1.7.0.jar!/" />
|
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.7.0/e7e30789211e074aa70ef3eaea59bd5b22a7fa7a/ant-launcher-1.7.0.jar!/" />
|
||||||
|
|
|
@ -34,85 +34,83 @@ package net.thauvin.erik.semver;
|
||||||
/**
|
/**
|
||||||
* The <code>Constants</code> class holds the constant variables used throughout this project.
|
* The <code>Constants</code> class holds the constant variables used throughout this project.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net" target="_blank">Erik C. Thauvin</a>
|
||||||
* @created 2016-01-13
|
* @created 2016-01-13
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public final class Constants
|
public final class Constants {
|
||||||
{
|
/**
|
||||||
/**
|
* The default class name.
|
||||||
* The default class name.
|
*/
|
||||||
*/
|
public static final String DEFAULT_CLASS_NAME = "GeneratedVersion";
|
||||||
public static final String DEFAULT_CLASS_NAME = "GeneratedVersion";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default major version.
|
* The default major version.
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_MAJOR = 1;
|
public static final int DEFAULT_MAJOR = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default minor version.
|
* The default minor version.
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_MINOR = 0;
|
public static final int DEFAULT_MINOR = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default patch version.
|
* The default patch version.
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_PATCH = 0;
|
public static final int DEFAULT_PATCH = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default Velocity template.
|
* The default Velocity template.
|
||||||
*/
|
*/
|
||||||
public static final String DEFAULT_TEMPLATE = "version.vm";
|
public static final String DEFAULT_TEMPLATE = "version.vm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The empty string.
|
* The empty string.
|
||||||
*/
|
*/
|
||||||
public static final String EMPTY = "";
|
public static final String EMPTY = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The build metadata property key.
|
* The build metadata property key.
|
||||||
*/
|
*/
|
||||||
public static final String KEY_VERSION_BUILDMETA = "version.buildmeta";
|
public static final String KEY_VERSION_BUILDMETA = "version.buildmeta";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The major version property key.
|
* The major version property key.
|
||||||
*/
|
*/
|
||||||
public static final String KEY_VERSION_MAJOR = "version.major";
|
public static final String KEY_VERSION_MAJOR = "version.major";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minor version property key.
|
* The minor version property key.
|
||||||
*/
|
*/
|
||||||
public static final String KEY_VERSION_MINOR = "version.minor";
|
public static final String KEY_VERSION_MINOR = "version.minor";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The patch version property key.
|
* The patch version property key.
|
||||||
*/
|
*/
|
||||||
public static final String KEY_VERSION_PATCH = "version.patch";
|
public static final String KEY_VERSION_PATCH = "version.patch";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pre-release version property key.
|
* The pre-release version property key.
|
||||||
*/
|
*/
|
||||||
public static final String KEY_VERSION_PRERELEASE = "version.prerelease";
|
public static final String KEY_VERSION_PRERELEASE = "version.prerelease";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The project property key.
|
* The project property key.
|
||||||
*/
|
*/
|
||||||
public static final String KEY_VERSION_PROJECT = "version.project";
|
public static final String KEY_VERSION_PROJECT = "version.project";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The velocity properties name.
|
* The velocity properties name.
|
||||||
*/
|
*/
|
||||||
public static final String VELOCITY_PROPERTIES = "velocity.properties";
|
public static final String VELOCITY_PROPERTIES = "velocity.properties";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables the default constructor.
|
* Disables the default constructor.
|
||||||
*
|
*
|
||||||
* @throws UnsupportedOperationException if the constructor is called.
|
* @throws UnsupportedOperationException if the constructor is called.
|
||||||
*/
|
*/
|
||||||
private Constants()
|
private Constants()
|
||||||
throws UnsupportedOperationException
|
throws UnsupportedOperationException {
|
||||||
{
|
throw new UnsupportedOperationException("Illegal constructor call.");
|
||||||
throw new UnsupportedOperationException("Illegal constructor call.");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -39,41 +39,40 @@ import java.lang.annotation.Target;
|
||||||
/**
|
/**
|
||||||
* The <code>Version</code> class implements the annotation interface.
|
* The <code>Version</code> class implements the annotation interface.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net" target="_blank">Erik C. Thauvin</a>
|
||||||
* @created 2016-01-13
|
* @created 2016-01-13
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface Version
|
public @interface Version {
|
||||||
{
|
String buildmeta() default Constants.EMPTY;
|
||||||
String buildmeta() default Constants.EMPTY;
|
|
||||||
|
|
||||||
String buildmetaKey() default Constants.KEY_VERSION_BUILDMETA;
|
String buildmetaKey() default Constants.KEY_VERSION_BUILDMETA;
|
||||||
|
|
||||||
String className() default Constants.DEFAULT_CLASS_NAME;
|
String className() default Constants.DEFAULT_CLASS_NAME;
|
||||||
|
|
||||||
int major() default Constants.DEFAULT_MAJOR;
|
int major() default Constants.DEFAULT_MAJOR;
|
||||||
|
|
||||||
String majorKey() default Constants.KEY_VERSION_MAJOR;
|
String majorKey() default Constants.KEY_VERSION_MAJOR;
|
||||||
|
|
||||||
int minor() default Constants.DEFAULT_MINOR;
|
int minor() default Constants.DEFAULT_MINOR;
|
||||||
|
|
||||||
String minorKey() default Constants.KEY_VERSION_MINOR;
|
String minorKey() default Constants.KEY_VERSION_MINOR;
|
||||||
|
|
||||||
int patch() default Constants.DEFAULT_PATCH;
|
int patch() default Constants.DEFAULT_PATCH;
|
||||||
|
|
||||||
String patchKey() default Constants.KEY_VERSION_PATCH;
|
String patchKey() default Constants.KEY_VERSION_PATCH;
|
||||||
|
|
||||||
String prerelease() default Constants.EMPTY;
|
String prerelease() default Constants.EMPTY;
|
||||||
|
|
||||||
String prereleaseKey() default Constants.KEY_VERSION_PRERELEASE;
|
String prereleaseKey() default Constants.KEY_VERSION_PRERELEASE;
|
||||||
|
|
||||||
String project() default Constants.EMPTY;
|
String project() default Constants.EMPTY;
|
||||||
|
|
||||||
String projectKey() default Constants.KEY_VERSION_PROJECT;
|
String projectKey() default Constants.KEY_VERSION_PROJECT;
|
||||||
|
|
||||||
String properties() default Constants.EMPTY;
|
String properties() default Constants.EMPTY;
|
||||||
|
|
||||||
String template() default Constants.DEFAULT_TEMPLATE;
|
String template() default Constants.DEFAULT_TEMPLATE;
|
||||||
}
|
}
|
|
@ -34,203 +34,186 @@ package net.thauvin.erik.semver;
|
||||||
/**
|
/**
|
||||||
* The <code>VersionInfo</code> class is used to hold and retrieve the semantic version values.
|
* The <code>VersionInfo</code> class is used to hold and retrieve the semantic version values.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net" target="_blank">Erik C. Thauvin</a>
|
||||||
* @created 2016-01-16
|
* @created 2016-01-16
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class VersionInfo
|
public class VersionInfo {
|
||||||
{
|
private final long epoch = System.currentTimeMillis();
|
||||||
private final long epoch = System.currentTimeMillis();
|
|
||||||
|
|
||||||
private String buildmeta;
|
private String buildmeta;
|
||||||
|
|
||||||
private int major;
|
private int major;
|
||||||
|
|
||||||
private int minor;
|
private int minor;
|
||||||
|
|
||||||
private int patch;
|
private int patch;
|
||||||
|
|
||||||
private String prerelease;
|
private String prerelease;
|
||||||
|
|
||||||
private String project;
|
private String project;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new object with default values
|
* Creates a new object with default values
|
||||||
*/
|
*/
|
||||||
public VersionInfo()
|
public VersionInfo() {
|
||||||
{
|
major = Constants.DEFAULT_MAJOR;
|
||||||
major = Constants.DEFAULT_MAJOR;
|
minor = Constants.DEFAULT_MINOR;
|
||||||
minor = Constants.DEFAULT_MINOR;
|
patch = Constants.DEFAULT_PATCH;
|
||||||
patch = Constants.DEFAULT_PATCH;
|
buildmeta = Constants.EMPTY;
|
||||||
buildmeta = Constants.EMPTY;
|
prerelease = Constants.EMPTY;
|
||||||
prerelease = Constants.EMPTY;
|
project = Constants.EMPTY;
|
||||||
project = Constants.EMPTY;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new object with values from a {@link net.thauvin.erik.semver.Version Version} object.
|
* Creates a new object with values from a {@link net.thauvin.erik.semver.Version Version} object.
|
||||||
*
|
*
|
||||||
* @param version The version object.
|
* @param version The version object.
|
||||||
*/
|
*/
|
||||||
public VersionInfo(final Version version)
|
public VersionInfo(final Version version) {
|
||||||
{
|
major = version.major();
|
||||||
major = version.major();
|
minor = version.minor();
|
||||||
minor = version.minor();
|
patch = version.patch();
|
||||||
patch = version.patch();
|
buildmeta = version.buildmeta();
|
||||||
buildmeta = version.buildmeta();
|
prerelease = version.prerelease();
|
||||||
prerelease = version.prerelease();
|
project = version.project();
|
||||||
project = version.project();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the build metadata.
|
* Returns the build metadata.
|
||||||
*
|
*
|
||||||
* @return The build metadata.
|
* @return The build metadata.
|
||||||
*/
|
*/
|
||||||
public String getBuildMetadata()
|
public String getBuildMetadata() {
|
||||||
{
|
return buildmeta;
|
||||||
return buildmeta;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the build metadata.
|
* Sets the build metadata.
|
||||||
*
|
*
|
||||||
* @param buildmeta The new build metadata.
|
* @param buildmeta The new build metadata.
|
||||||
*/
|
*/
|
||||||
public void setBuildMetadata(final String buildmeta)
|
public void setBuildMetadata(final String buildmeta) {
|
||||||
{
|
this.buildmeta = buildmeta;
|
||||||
this.buildmeta = buildmeta;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the build epoch/Unix timestamp.
|
* Returns the build epoch/Unix timestamp.
|
||||||
*
|
*
|
||||||
* @return The build epoch.
|
* @return The build epoch.
|
||||||
*/
|
*/
|
||||||
public long getEpoch()
|
public long getEpoch() {
|
||||||
{
|
return epoch;
|
||||||
return epoch;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the major version.
|
* Returns the major version.
|
||||||
*
|
*
|
||||||
* @return The major version.
|
* @return The major version.
|
||||||
*/
|
*/
|
||||||
public int getMajor()
|
public int getMajor() {
|
||||||
{
|
return major;
|
||||||
return major;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the major version.
|
* Sets the major version.
|
||||||
*
|
*
|
||||||
* @param major The new major version.
|
* @param major The new major version.
|
||||||
*/
|
*/
|
||||||
public void setMajor(final int major)
|
public void setMajor(final int major) {
|
||||||
{
|
this.major = major;
|
||||||
this.major = major;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the major version.
|
* Returns the major version.
|
||||||
*
|
*
|
||||||
* @return The major version.
|
* @return The major version.
|
||||||
*/
|
*/
|
||||||
public int getMinor()
|
public int getMinor() {
|
||||||
{
|
return minor;
|
||||||
return minor;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the minor version.
|
* Sets the minor version.
|
||||||
*
|
*
|
||||||
* @param minor The new minor version.
|
* @param minor The new minor version.
|
||||||
*/
|
*/
|
||||||
public void setMinor(final int minor)
|
public void setMinor(final int minor) {
|
||||||
{
|
this.minor = minor;
|
||||||
this.minor = minor;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the patch version.
|
* Returns the patch version.
|
||||||
*
|
*
|
||||||
* @return The patch version.
|
* @return The patch version.
|
||||||
*/
|
*/
|
||||||
public int getPatch()
|
public int getPatch() {
|
||||||
{
|
return patch;
|
||||||
return patch;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the patch version.
|
* Sets the patch version.
|
||||||
*
|
*
|
||||||
* @param patch The new patch version.
|
* @param patch The new patch version.
|
||||||
*/
|
*/
|
||||||
public void setPatch(final int patch)
|
public void setPatch(final int patch) {
|
||||||
{
|
this.patch = patch;
|
||||||
this.patch = patch;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the pre-release version.
|
* Returns the pre-release version.
|
||||||
*
|
*
|
||||||
* @return The pre-release version.
|
* @return The pre-release version.
|
||||||
*/
|
*/
|
||||||
public String getPreRelease()
|
public String getPreRelease() {
|
||||||
{
|
return prerelease;
|
||||||
return prerelease;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the pre-release version.
|
* Sets the pre-release version.
|
||||||
*
|
*
|
||||||
* @param prerelease The new pre-release version.
|
* @param prerelease The new pre-release version.
|
||||||
*/
|
*/
|
||||||
public void setPreRelease(final String prerelease)
|
public void setPreRelease(final String prerelease) {
|
||||||
{
|
this.prerelease = prerelease;
|
||||||
this.prerelease = prerelease;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the project name.
|
* Returns the project name.
|
||||||
*
|
*
|
||||||
* @return The project name.
|
* @return The project name.
|
||||||
*/
|
*/
|
||||||
public String getProject()
|
public String getProject() {
|
||||||
{
|
return project;
|
||||||
return project;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the project name.
|
* Sets the project name.
|
||||||
*
|
*
|
||||||
* @param project The new project name.
|
* @param project The new project name.
|
||||||
*/
|
*/
|
||||||
public void setProject(final String project)
|
public void setProject(final String project) {
|
||||||
{
|
this.project = project;
|
||||||
this.project = project;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the full version string.
|
* Returns the full version string.
|
||||||
* <p>
|
* <p>
|
||||||
* Formatted as:
|
* Formatted as:
|
||||||
* <blockquote><code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code></blockquote>
|
* <blockquote><code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code></blockquote>
|
||||||
* <p>
|
* <p>
|
||||||
* For example:
|
* For example:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li><code>1.0.0</code></li>
|
* <li><code>1.0.0</code></li>
|
||||||
* <li><code>1.0.0-beta</code></li>
|
* <li><code>1.0.0-beta</code></li>
|
||||||
* <li><code>1.0.0+20160124144700</code></li>
|
* <li><code>1.0.0+20160124144700</code></li>
|
||||||
* <li><code>1.0.0-alpha+001</code></li>
|
* <li><code>1.0.0-alpha+001</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return The version string.
|
* @return The version string.
|
||||||
*/
|
*/
|
||||||
public String getVersion()
|
public String getVersion() {
|
||||||
{
|
return Integer.toString(major) + '.' + Integer.toString(minor) + '.' + Integer.toString(patch) + (
|
||||||
return Integer.toString(major) + '.' + Integer.toString(minor) + '.' + Integer.toString(patch) + (
|
prerelease.length() > 0 ? '-' + prerelease : "") + (buildmeta.length() > 0 ? '+' + buildmeta : "");
|
||||||
prerelease.length() > 0 ? '-' + prerelease : "") + (buildmeta.length() > 0 ? '+' + buildmeta : "");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -52,200 +52,169 @@ import java.util.Set;
|
||||||
/**
|
/**
|
||||||
* The <code>VersionProcessor</code> class implements a semantic version annotation processor.
|
* The <code>VersionProcessor</code> class implements a semantic version annotation processor.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net" target="_blank">Erik C. Thauvin</a>
|
||||||
* @created 2016-01-13
|
* @created 2016-01-13
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class VersionProcessor extends AbstractProcessor
|
public class VersionProcessor extends AbstractProcessor {
|
||||||
{
|
private Filer filer;
|
||||||
private Filer filer;
|
|
||||||
|
|
||||||
private Messager messager;
|
private Messager messager;
|
||||||
|
|
||||||
private void error(final String s)
|
private void error(final String s) {
|
||||||
{
|
log(Diagnostic.Kind.ERROR, s);
|
||||||
log(Diagnostic.Kind.ERROR, s);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void error(final String s, final Throwable t)
|
private void error(final String s, final Throwable t) {
|
||||||
{
|
messager.printMessage(Diagnostic.Kind.ERROR, (t != null ? t.toString() : s));
|
||||||
messager.printMessage(Diagnostic.Kind.ERROR, (t != null ? t.toString() : s));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private VersionInfo findValues(final Version version)
|
private VersionInfo findValues(final Version version)
|
||||||
throws IOException
|
throws IOException {
|
||||||
{
|
final VersionInfo versionInfo;
|
||||||
final VersionInfo versionInfo;
|
|
||||||
|
|
||||||
if (version.properties().length() > 0)
|
if (version.properties().length() > 0) {
|
||||||
{
|
versionInfo = new VersionInfo();
|
||||||
versionInfo = new VersionInfo();
|
|
||||||
|
|
||||||
final File propsFile = new File(version.properties());
|
final File propsFile = new File(version.properties());
|
||||||
if (propsFile.exists())
|
if (propsFile.exists()) {
|
||||||
{
|
note("Found properties: " + propsFile);
|
||||||
note("Found properties: " + propsFile);
|
final Properties p = new Properties();
|
||||||
final Properties p = new Properties();
|
|
||||||
|
|
||||||
try (FileReader reader = new FileReader(propsFile))
|
try (FileReader reader = new FileReader(propsFile)) {
|
||||||
{
|
p.load(reader);
|
||||||
p.load(reader);
|
|
||||||
|
|
||||||
versionInfo.setProject(p.getProperty(version.projectKey(), Constants.EMPTY));
|
versionInfo.setProject(p.getProperty(version.projectKey(), Constants.EMPTY));
|
||||||
versionInfo.setMajor(parseIntProperty(p, version.majorKey(), Constants.DEFAULT_MAJOR));
|
versionInfo.setMajor(parseIntProperty(p, version.majorKey(), Constants.DEFAULT_MAJOR));
|
||||||
versionInfo.setMinor(parseIntProperty(p, version.minorKey(), Constants.DEFAULT_MINOR));
|
versionInfo.setMinor(parseIntProperty(p, version.minorKey(), Constants.DEFAULT_MINOR));
|
||||||
versionInfo.setPatch(parseIntProperty(p, version.patchKey(), Constants.DEFAULT_PATCH));
|
versionInfo.setPatch(parseIntProperty(p, version.patchKey(), Constants.DEFAULT_PATCH));
|
||||||
versionInfo.setBuildMetadata(p.getProperty(version.buildmetaKey(), Constants.EMPTY));
|
versionInfo.setBuildMetadata(p.getProperty(version.buildmetaKey(), Constants.EMPTY));
|
||||||
versionInfo.setPreRelease(p.getProperty(version.prereleaseKey(), Constants.EMPTY));
|
versionInfo.setPreRelease(p.getProperty(version.prereleaseKey(), Constants.EMPTY));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
error("Could not find: " + propsFile);
|
||||||
{
|
throw new FileNotFoundException(propsFile + " (The system cannot find the file specified)");
|
||||||
error("Could not find: " + propsFile);
|
}
|
||||||
throw new FileNotFoundException(propsFile + " (The system cannot find the file specified)");
|
} else {
|
||||||
}
|
versionInfo = new VersionInfo(version);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
versionInfo = new VersionInfo(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
return versionInfo;
|
return versionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getSupportedAnnotationTypes()
|
public Set<String> getSupportedAnnotationTypes() {
|
||||||
{
|
final Set<String> result = new HashSet<>();
|
||||||
final Set<String> result = new HashSet<>();
|
result.add(Version.class.getCanonicalName());
|
||||||
result.add(Version.class.getCanonicalName());
|
return result;
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SourceVersion getSupportedSourceVersion()
|
public SourceVersion getSupportedSourceVersion() {
|
||||||
{
|
return SourceVersion.RELEASE_8;
|
||||||
return SourceVersion.RELEASE_8;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void init(final ProcessingEnvironment processingEnv)
|
public synchronized void init(final ProcessingEnvironment processingEnv) {
|
||||||
{
|
super.init(processingEnv);
|
||||||
super.init(processingEnv);
|
filer = processingEnv.getFiler();
|
||||||
filer = processingEnv.getFiler();
|
messager = processingEnv.getMessager();
|
||||||
messager = processingEnv.getMessager();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private void log(final Diagnostic.Kind kind, final String s) {
|
||||||
* {@inheritDoc}
|
messager.printMessage(kind, '[' + VersionProcessor.class.getSimpleName() + "] " + s);
|
||||||
*/
|
}
|
||||||
@Override
|
|
||||||
public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv)
|
|
||||||
{
|
|
||||||
for (final Element element : roundEnv.getElementsAnnotatedWith(Version.class))
|
|
||||||
{
|
|
||||||
final Version version = element.getAnnotation(Version.class);
|
|
||||||
if (element.getKind() == ElementKind.CLASS)
|
|
||||||
{
|
|
||||||
final Element enclosingElement = element.getEnclosingElement();
|
|
||||||
if (enclosingElement.getKind() == ElementKind.PACKAGE)
|
|
||||||
{
|
|
||||||
final PackageElement packageElement = (PackageElement) enclosingElement;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final VersionInfo versionInfo = findValues(version);
|
|
||||||
note("Found version: " + versionInfo.getVersion());
|
|
||||||
writeTemplate(packageElement.getQualifiedName().toString(),
|
|
||||||
version.className(),
|
|
||||||
versionInfo,
|
|
||||||
version.template());
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
error("IOException occurred while running the annotation processor", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void log(final Diagnostic.Kind kind, final String s)
|
private void note(final String s) {
|
||||||
{
|
log(Diagnostic.Kind.NOTE, s);
|
||||||
messager.printMessage(kind, '[' + VersionProcessor.class.getSimpleName() + "] " + s);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void note(final String s)
|
private int parseIntProperty(final Properties p, final String property, final int defaultValue) {
|
||||||
{
|
try {
|
||||||
log(Diagnostic.Kind.NOTE, s);
|
return Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue)));
|
||||||
}
|
} catch (NumberFormatException ignore) {
|
||||||
|
warn("Invalid property value: " + property);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int parseIntProperty(final Properties p, final String property, final int defaultValue)
|
/**
|
||||||
{
|
* {@inheritDoc}
|
||||||
try
|
*/
|
||||||
{
|
@Override
|
||||||
return Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue)));
|
public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
|
||||||
}
|
for (final Element element : roundEnv.getElementsAnnotatedWith(Version.class)) {
|
||||||
catch (NumberFormatException ignore)
|
final Version version = element.getAnnotation(Version.class);
|
||||||
{
|
if (element.getKind() == ElementKind.CLASS) {
|
||||||
warn("Invalid property value: " + property);
|
final Element enclosingElement = element.getEnclosingElement();
|
||||||
return defaultValue;
|
if (enclosingElement.getKind() == ElementKind.PACKAGE) {
|
||||||
}
|
final PackageElement packageElement = (PackageElement) enclosingElement;
|
||||||
}
|
try {
|
||||||
|
final VersionInfo versionInfo = findValues(version);
|
||||||
|
note("Found version: " + versionInfo.getVersion());
|
||||||
|
writeTemplate(packageElement.getQualifiedName().toString(),
|
||||||
|
version.className(),
|
||||||
|
versionInfo,
|
||||||
|
version.template());
|
||||||
|
} catch (IOException e) {
|
||||||
|
error("IOException occurred while running the annotation processor", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void warn(final String s)
|
private void warn(final String s) {
|
||||||
{
|
log(Diagnostic.Kind.WARNING, s);
|
||||||
log(Diagnostic.Kind.WARNING, s);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void writeTemplate(final String packageName, final String className, final VersionInfo versionInfo,
|
private void writeTemplate(final String packageName,
|
||||||
final String template)
|
final String className,
|
||||||
throws IOException
|
final VersionInfo versionInfo,
|
||||||
{
|
final String template)
|
||||||
final Properties p = new Properties();
|
throws IOException {
|
||||||
final URL url = this.getClass().getClassLoader().getResource(Constants.VELOCITY_PROPERTIES);
|
final Properties p = new Properties();
|
||||||
|
final URL url = this.getClass().getClassLoader().getResource(Constants.VELOCITY_PROPERTIES);
|
||||||
|
|
||||||
if (url != null)
|
if (url != null) {
|
||||||
{
|
p.load(url.openStream());
|
||||||
p.load(url.openStream());
|
|
||||||
|
|
||||||
final VelocityEngine ve = new VelocityEngine(p);
|
final VelocityEngine ve = new VelocityEngine(p);
|
||||||
ve.init();
|
ve.init();
|
||||||
|
|
||||||
final VelocityContext vc = new VelocityContext();
|
final VelocityContext vc = new VelocityContext();
|
||||||
vc.put("packageName", packageName);
|
vc.put("packageName", packageName);
|
||||||
vc.put("className", className);
|
vc.put("className", className);
|
||||||
vc.put("project", versionInfo.getProject());
|
vc.put("project", versionInfo.getProject());
|
||||||
vc.put("buildmeta", versionInfo.getBuildMetadata());
|
vc.put("buildmeta", versionInfo.getBuildMetadata());
|
||||||
vc.put("epoch", versionInfo.getEpoch());
|
vc.put("epoch", versionInfo.getEpoch());
|
||||||
vc.put("patch", versionInfo.getPatch());
|
vc.put("patch", versionInfo.getPatch());
|
||||||
vc.put("major", versionInfo.getMajor());
|
vc.put("major", versionInfo.getMajor());
|
||||||
vc.put("minor", versionInfo.getMinor());
|
vc.put("minor", versionInfo.getMinor());
|
||||||
vc.put("prerelease", versionInfo.getPreRelease());
|
vc.put("prerelease", versionInfo.getPreRelease());
|
||||||
|
|
||||||
final Template vt = ve.getTemplate(template);
|
final Template vt = ve.getTemplate(template);
|
||||||
|
|
||||||
note("Loaded template: " + vt.getName());
|
note("Loaded template: " + vt.getName());
|
||||||
|
|
||||||
final JavaFileObject jfo = filer.createSourceFile(packageName + '.' + className);
|
final JavaFileObject jfo = filer.createSourceFile(packageName + '.' + className);
|
||||||
try (final Writer writer = jfo.openWriter())
|
try (final Writer writer = jfo.openWriter()) {
|
||||||
{
|
vt.merge(vc, writer);
|
||||||
vt.merge(vc, writer);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
note("Generated source: " + jfo.getName());
|
note("Generated source: " + jfo.getName());
|
||||||
}
|
} else {
|
||||||
else
|
error("Could not load '" + Constants.VELOCITY_PROPERTIES + "' from jar.");
|
||||||
{
|
}
|
||||||
error("Could not load '" + Constants.VELOCITY_PROPERTIES + "' from jar.");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue