From 240c928e77661f366b53e26834bbdeba2960d9c2 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 18 Jul 2016 17:45:07 -0700 Subject: [PATCH] Code format, tabs to spaces, etc. --- .idea/modules/example.iml | 24 ++ .idea/modules/semver.iml | 12 +- build.gradle | 271 +++++++------- example/build.gradle | 94 +++-- example/gradle/wrapper/gradle-wrapper.jar | Bin 53636 -> 53324 bytes .../gradle/wrapper/gradle-wrapper.properties | 4 +- example/gradlew | 46 +-- example/gradlew.bat | 8 +- .../erik/semver/example/GeneratedVersion.java | 157 +++++++++ .../thauvin/erik/semver/example/Example.java | 30 +- example/version.properties | 5 +- semver.ipr | 43 ++- .../net/thauvin/erik/semver/Constants.java | 128 ++++--- .../java/net/thauvin/erik/semver/Version.java | 35 +- .../net/thauvin/erik/semver/VersionInfo.java | 331 +++++++++--------- .../thauvin/erik/semver/VersionProcessor.java | 305 ++++++++-------- 16 files changed, 826 insertions(+), 667 deletions(-) create mode 100644 .idea/modules/example.iml create mode 100644 example/src/generated/java/net/thauvin/erik/semver/example/GeneratedVersion.java diff --git a/.idea/modules/example.iml b/.idea/modules/example.iml new file mode 100644 index 0000000..3004a6f --- /dev/null +++ b/.idea/modules/example.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/semver.iml b/.idea/modules/semver.iml index 1615fa6..24fcd77 100644 --- a/.idea/modules/semver.iml +++ b/.idea/modules/semver.iml @@ -15,12 +15,12 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7895e9a..b807226 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.jfrog.bintray" version "1.5" + id "com.jfrog.bintray" version "1.5" } apply plugin: 'java' apply plugin: 'idea' @@ -10,29 +10,27 @@ import org.apache.tools.ant.taskdefs.condition.Os defaultTasks 'deploy' -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 : '')) +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() @@ -56,167 +54,162 @@ def pkgLabels = ['java', 'annotation', 'processor', 'semantic', 'version'] [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' repositories { - mavenLocal() - jcenter() + mavenLocal() + jcenter() } dependencies { - compile 'org.apache.velocity:velocity:1.7' - testCompile 'org.testng:testng:6.9.12' + compile 'org.apache.velocity:velocity:1.7' + testCompile 'org.testng:testng:6.9.12' } bintray { - user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') - key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') - publications = ['MyPublication'] - dryRun = true - pkg { - repo = 'maven' - name = mavenName - licenses = pkgLicenses - desc = mavenDescription - websiteUrl = mavenUrl - issueTrackerUrl = pkgIssueTrackerUrl - vcsUrl = mavenScmCon - labels = pkgLabels - publicDownloadNumbers = true - version { - name = project.version - desc = 'Version ' + project.version - vcsTag = project.version - gpg { - sign = true - } - } - } + user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') + key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') + publications = ['MyPublication'] + dryRun = true + pkg { + repo = 'maven' + name = mavenName + licenses = pkgLicenses + desc = mavenDescription + websiteUrl = mavenUrl + issueTrackerUrl = pkgIssueTrackerUrl + vcsUrl = mavenScmCon + labels = pkgLabels + publicDownloadNumbers = true + version { + name = project.version + desc = 'Version ' + project.version + vcsTag = project.version + gpg { + sign = true + } + } + } } - 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 - } + 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 + } } publishing { - publications { - MyPublication(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - groupId mavenGroupId - artifactId rootProject.name - version project.version + publications { + MyPublication(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + groupId mavenGroupId + 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.withXml { + def root = asNode() + root.appendNode('name', mavenName) + root.appendNode('description', mavenDescription) + root.appendNode('url', mavenUrl) + root.children().last() + pomConfig + } + } + } } task javadocJar(type: Jar, dependsOn: javadoc) { - group = 'Build' - description = 'Builds an archive of the javadoc docs.' - classifier = 'javadoc' - from javadoc.destinationDir + group = 'Build' + description = 'Builds an archive of the javadoc docs.' + classifier = 'javadoc' + from javadoc.destinationDir } task sourcesJar(type: Jar) { - group = 'Build' - description = 'Builds an archive of the source code.' - classifier = 'sources' - from sourceSets.main.allSource + group = 'Build' + description = 'Builds an archive of the source code.' + classifier = 'sources' + from sourceSets.main.allSource } artifacts { - archives javadocJar - archives sourcesJar + archives javadocJar + archives sourcesJar } javadoc { - title = mavenDescription + ' ' + version - options.tags = ['created'] - options.author = true - options.addStringOption('link', 'http://docs.oracle.com/javase/8/docs/api/') - options.addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc : "$System.env.JAVA_HOME/src.zip") - if (JavaVersion.current().isJava8Compatible()) - { - options.addStringOption('Xdoclint:none', '-quiet') - } + title = mavenDescription + ' ' + version + options.tags = ['created'] + options.author = true + options.addStringOption('link', 'http://docs.oracle.com/javase/8/docs/api/') + options.addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc : "$System.env.JAVA_HOME/src.zip") + if (JavaVersion.current().isJava8Compatible()) { + options.addStringOption('Xdoclint:none', '-quiet') + } } test { - useTestNG() + useTestNG() } compileJava { - doFirst { - project.version = getVersion(isRelease) - } + doFirst { + project.version = getVersion(isRelease) + } } clean { - delete deployDir + delete deployDir } task copyToDeploy(type: Copy) { - from jar - into deployDir + from jar + into deployDir } task deploy(dependsOn: ['build', 'copyToDeploy']) { - description = 'Copies all needed files to the ${deployDir} directory.' - group = 'Publishing' - outputs.dir deployDir - inputs.files copyToDeploy - mustRunAfter clean + description = 'Copies all needed files to the ${deployDir} directory.' + group = 'Publishing' + outputs.dir deployDir + inputs.files copyToDeploy + mustRunAfter clean } task wrapper(type: Wrapper) { - gradleVersion = gradle.gradleVersion + gradleVersion = gradle.gradleVersion } task release(dependsOn: ['wrapper', 'clean', 'deploy']) << { - group = 'Publishing' - description = 'Releases new version.' - isRelease = true + group = 'Publishing' + description = 'Releases new version.' + isRelease = true } task pandoc(type: Exec) { - group = 'Documentation' - def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-c', 'github-pandoc.css', '-o', 'README.html', 'README.md'] - if (Os.isFamily(Os.FAMILY_WINDOWS)) - { - commandLine(['cmd', '/c', 'pandoc'] + pandoc_args) - } - else - { - executable 'pandoc' - args pandoc_args - } - standardOutput = new ByteArrayOutputStream() - ext.output = { - return standardOutput.toString() - } -} + group = 'Documentation' + def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-c', 'github-pandoc.css', '-o', 'README.html', 'README.md'] + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine(['cmd', '/c', 'pandoc'] + pandoc_args) + } else { + executable 'pandoc' + args pandoc_args + } + standardOutput = new ByteArrayOutputStream() + ext.output = { + return standardOutput.toString() + } +} \ No newline at end of file diff --git a/example/build.gradle b/example/build.gradle index 66b8272..c6937a3 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -1,5 +1,5 @@ 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: 'idea' @@ -11,29 +11,27 @@ def isRelease = 'release' in gradle.startParameter.taskNames def deployDir = 'deploy' // Get version from properties file. Increment patch if specified. -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 : '')) +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() @@ -42,55 +40,53 @@ mainClassName = 'net.thauvin.erik.semver.example.Example' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' repositories { - mavenLocal() - mavenCentral() + mavenLocal() + mavenCentral() } dependencies { - compileOnly 'net.thauvin.erik:semver:0.9.6-beta' + compileOnly 'net.thauvin.erik:semver:0.9.6-beta' } annotationProcessor { - // Update version, increment on release. - project.version = getVersion(isRelease) - library 'net.thauvin.erik:semver:0.9.6-beta' - processor 'net.thauvin.erik.semver.VersionProcessor' - // sourcesDir 'src/generated/java' + // Update version, increment on release. + project.version = getVersion(isRelease) + library 'net.thauvin.erik:semver:0.9.6-beta' + processor 'net.thauvin.erik.semver.VersionProcessor' + // sourcesDir 'src/generated/java' } compileJava { - options.compilerArgs << '-proc:none' + options.compilerArgs << '-proc:none' } jar { - manifest.attributes('Main-Class': mainClassName) + manifest.attributes('Main-Class': mainClassName) } clean { - delete deployDir + delete deployDir } - task copyToDeploy(type: Copy) { - from jar - into deployDir + from jar + into deployDir } task deploy(dependsOn: ['build', 'copyToDeploy']) { - description = 'Copies all needed files to the ${deployDir} directory.' - group = 'Publishing' - outputs.dir deployDir - inputs.files copyToDeploy - mustRunAfter clean + description = 'Copies all needed files to the ${deployDir} directory.' + group = 'Publishing' + outputs.dir deployDir + inputs.files copyToDeploy + mustRunAfter clean } task release(dependsOn: ['wrapper', 'clean', 'deploy']) << { - group = 'Publishing' - description = 'Releases new version.' - isRelease = true + group = 'Publishing' + description = 'Releases new version.' + isRelease = true } task wrapper(type: Wrapper) { - gradleVersion = gradle.gradleVersion -} - + gradleVersion = gradle.gradleVersion +} \ No newline at end of file diff --git a/example/gradle/wrapper/gradle-wrapper.jar b/example/gradle/wrapper/gradle-wrapper.jar index 13372aef5e24af05341d49695ee84e5f9b594659..3baa851b28c65f87dd36a6748e1a85cf360c1301 100644 GIT binary patch delta 5483 zcmaJ_2{=@3`yazZ*_W|38vDM7tSS2*QuZxlDND8xF`-n}>Le1PNJ_RD^oqoo!Prt+ zlAY{{O4j%vGv4~<`>yMMuIpUqKKJ~7_x3!`eV%8oJ)!Q%qh_)+rKULqfzZ)GX!O4u z-C+`8+AAgalOSS7` zhJ0&s^qOJusDT6X)Rlmi~=2n_ERo%^t(X;r1I0@vu{2cC*nN;RV zqfpAljXbxr7J}BV^T+(ru#iL3(LPNDTvlqbMit_CbEJ*5aYPAgdqfedlwJD7{h_I+ zT)xML2(PW{#PC~enahGDN2ORt^NA7e@yl)c3|1_K8ObK~77%g+}eTSa- z^gzM`I(j8@doMzdnYX^F=cU-qgE*yZUufyuw~1Gyh=X}mm%HRw(LQ0m&NUfTtM_E% z?So{h9)C*6=1K_=JCCACn32|CH5nK*Fk$xp?4bVgbN)a8p{It^KZ(8N-BC=IaZM-3 zAbaiUIk+lPyujBkpGTJr*KW(V(IZD2U8@WH-lOwdfeqDu&k za*q@%E#ku|&V>wr2uJf6Vc0*(42Kfc9PCCvPBK|tBIw7a-u*3<8sM8M0%)fnC)x*? z>s}s&rsy}zV(y!rJ%Y=SRa>27TT?jfJ|{jIb?i5C=E)Z-vFAxn{{IlJGAanUU$E%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k7qH4O_)_)+Ug zASI+1gn$>8XU;4@|4;Z7pepa!Q@egpm7NF}u;fC=*SWPwP=))~Ytkzxp`{$Vj59lj zvRst4Dqc4xQfbH@9aN@vD*H^LFI6VWqgm+IgtoAn&!euj_cKXbAsjViO7uK1$>Y5?hpwM`;I=u&)5$6 zNQT3@9u4BL^q9AJWv#e82Hfag<`y1XeLaou_2pI)<3=M3pm>kiqD}lLy3_)%H(hoa z&pY?e03O?`Ho)_=YZ6aUpG4|36%0`WkN66(Ue9m*|4SUC?%%{gbPs51iwRaO2nqEG zclBylVv~pn%5>^)nGeV|NDg(VZbq!W-ESh3_xRz`rl7e|(#s``9}5dv8kgh03n$gJF0axWLP$p3~+aBC4v z@|40(;*){{9Ig005N(A+AIM|zTdilYA%?@V3(CL^RAGfcga`zlqp-w`CQ<;?%7HtD z2~YsIj>W0k@FyeO28VhZVX;hBYQU+D7spKi@n91yu1iD?bhj~Z5nP0z**OBke}Nxu zNbZxI|9h=LAYfd7o{A8AD?q!Q|K!x^3%fCvM~F zM3A{Blb>{ce|iy|Z2%slk$_BRhb3RNWe2*uaOB!TZDayS4g>8K3CIkNSn`H98BpI# z3UGF^WA73`sS^(Us_4{Lh$E)~GpjmO2h;n4L5cpWl8_yPSN zWAgyFXGvgP+CdN2r3A(+p+HHuG diff --git a/example/gradle/wrapper/gradle-wrapper.properties b/example/gradle/wrapper/gradle-wrapper.properties index 7968b98..7d773c3 100644 --- a/example/gradle/wrapper/gradle-wrapper.properties +++ b/example/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Jan 23 18:16:10 PST 2016 +#Mon Jul 18 17:32:58 PDT 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME 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 diff --git a/example/gradlew b/example/gradlew index 9d82f78..27309d9 100644 --- a/example/gradlew +++ b/example/gradlew @@ -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. -DEFAULT_JVM_OPTS="" +# 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 APP_NAME="Gradle" 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. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; 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 # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # 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` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then diff --git a/example/gradlew.bat b/example/gradlew.bat index 8a0b282..832fdb6 100644 --- a/example/gradlew.bat +++ b/example/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell 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 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 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 if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,7 +46,7 @@ echo location of your Java installation. goto fail :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 "%@eval[2+2]" == "4" goto 4NT_args diff --git a/example/src/generated/java/net/thauvin/erik/semver/example/GeneratedVersion.java b/example/src/generated/java/net/thauvin/erik/semver/example/GeneratedVersion.java new file mode 100644 index 0000000..13070df --- /dev/null +++ b/example/src/generated/java/net/thauvin/erik/semver/example/GeneratedVersion.java @@ -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 Semantic Version + * Annotation Processor + */ +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. + *

+ * Formatted as: + *

+ * MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA] + *
+ *

+ * For example: + *

    + *
  • 1.0.0
  • + *
  • 1.0.0-beta
  • + *
  • 1.0.0+20160124144700
  • + *
  • 1.0.0-alpha+001
  • + *
+ * + * @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 true. + * @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 true. + * @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); + } +} \ No newline at end of file diff --git a/example/src/main/java/net/thauvin/erik/semver/example/Example.java b/example/src/main/java/net/thauvin/erik/semver/example/Example.java index f854c44..d21035a 100644 --- a/example/src/main/java/net/thauvin/erik/semver/example/Example.java +++ b/example/src/main/java/net/thauvin/erik/semver/example/Example.java @@ -38,28 +38,26 @@ import java.text.SimpleDateFormat; /** * The Example class. * - * @author Erik C. Thauvin + * @author Erik C. Thauvin * @created 2016-01-13 * @since 1.0 */ @Version(properties = "version.properties") -public class Example -{ - public static void main(final String... args) - { - final SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy 'at' HH:mm:ss z"); +public class Example { + public static void main(final String... args) { + 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(" Major: " + GeneratedVersion.getMajor()); - System.out.println(" Minor: " + GeneratedVersion.getMinor()); - System.out.println(" Patch: " + GeneratedVersion.getPatch()); - System.out.println(" PreRelease: " + GeneratedVersion.getPreRelease()); - System.out.println(" BuildMetaData: " + GeneratedVersion.getBuildMetadata()); + System.out.println(" Built on: " + sdf.format(GeneratedVersion.getBuildDate())); + System.out.println(" Major: " + GeneratedVersion.getMajor()); + System.out.println(" Minor: " + GeneratedVersion.getMinor()); + System.out.println(" Patch: " + GeneratedVersion.getPatch()); + System.out.println(" PreRelease: " + GeneratedVersion.getPreRelease()); + System.out.println(" BuildMetaData: " + GeneratedVersion.getBuildMetadata()); - System.out.println("-----------------------------------------------------"); - } + System.out.println("-----------------------------------------------------"); + } } \ No newline at end of file diff --git a/example/version.properties b/example/version.properties index bb3db8e..c99f89d 100644 --- a/example/version.properties +++ b/example/version.properties @@ -1,8 +1,7 @@ -# -#Wed Jul 06 19:28:58 PDT 2016 +#Mon, 18 Jul 2016 17:33:54 -0700 version.prerelease=beta version.project=Example version.minor=1 version.buildmeta= -version.patch=45 +version.patch=49 version.major=3 diff --git a/semver.ipr b/semver.ipr index 47c9c27..26de8dd 100644 --- a/semver.ipr +++ b/semver.ipr @@ -58,10 +58,27 @@ - + + + + + + + + + + + + + + + @@ -199,6 +228,7 @@ + @@ -334,6 +364,15 @@ + + + + + + + + + diff --git a/src/main/java/net/thauvin/erik/semver/Constants.java b/src/main/java/net/thauvin/erik/semver/Constants.java index 9e6f587..25ada5d 100644 --- a/src/main/java/net/thauvin/erik/semver/Constants.java +++ b/src/main/java/net/thauvin/erik/semver/Constants.java @@ -34,85 +34,83 @@ package net.thauvin.erik.semver; /** * The Constants class holds the constant variables used throughout this project. * - * @author Erik C. Thauvin + * @author Erik C. Thauvin * @created 2016-01-13 * @since 1.0 */ -public final class Constants -{ - /** - * The default class name. - */ - public static final String DEFAULT_CLASS_NAME = "GeneratedVersion"; +public final class Constants { + /** + * The default class name. + */ + public static final String DEFAULT_CLASS_NAME = "GeneratedVersion"; - /** - * The default major version. - */ - public static final int DEFAULT_MAJOR = 1; + /** + * The default major version. + */ + public static final int DEFAULT_MAJOR = 1; - /** - * The default minor version. - */ - public static final int DEFAULT_MINOR = 0; + /** + * The default minor version. + */ + public static final int DEFAULT_MINOR = 0; - /** - * The default patch version. - */ - public static final int DEFAULT_PATCH = 0; + /** + * The default patch version. + */ + public static final int DEFAULT_PATCH = 0; - /** - * The default Velocity template. - */ - public static final String DEFAULT_TEMPLATE = "version.vm"; + /** + * The default Velocity template. + */ + public static final String DEFAULT_TEMPLATE = "version.vm"; - /** - * The empty string. - */ - public static final String EMPTY = ""; + /** + * The empty string. + */ + public static final String EMPTY = ""; - /** - * The build metadata property key. - */ - public static final String KEY_VERSION_BUILDMETA = "version.buildmeta"; + /** + * The build metadata property key. + */ + public static final String KEY_VERSION_BUILDMETA = "version.buildmeta"; - /** - * The major version property key. - */ - public static final String KEY_VERSION_MAJOR = "version.major"; + /** + * The major version property key. + */ + public static final String KEY_VERSION_MAJOR = "version.major"; - /** - * The minor version property key. - */ - public static final String KEY_VERSION_MINOR = "version.minor"; + /** + * The minor version property key. + */ + public static final String KEY_VERSION_MINOR = "version.minor"; - /** - * The patch version property key. - */ - public static final String KEY_VERSION_PATCH = "version.patch"; + /** + * The patch version property key. + */ + public static final String KEY_VERSION_PATCH = "version.patch"; - /** - * The pre-release version property key. - */ - public static final String KEY_VERSION_PRERELEASE = "version.prerelease"; + /** + * The pre-release version property key. + */ + public static final String KEY_VERSION_PRERELEASE = "version.prerelease"; - /** - * The project property key. - */ - public static final String KEY_VERSION_PROJECT = "version.project"; + /** + * The project property key. + */ + public static final String KEY_VERSION_PROJECT = "version.project"; - /** - * The velocity properties name. - */ - public static final String VELOCITY_PROPERTIES = "velocity.properties"; + /** + * The velocity properties name. + */ + public static final String VELOCITY_PROPERTIES = "velocity.properties"; - /** - * Disables the default constructor. - * - * @throws UnsupportedOperationException if the constructor is called. - */ - private Constants() - throws UnsupportedOperationException - { - throw new UnsupportedOperationException("Illegal constructor call."); - } + /** + * Disables the default constructor. + * + * @throws UnsupportedOperationException if the constructor is called. + */ + private Constants() + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Illegal constructor call."); + } } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/semver/Version.java b/src/main/java/net/thauvin/erik/semver/Version.java index fd1c986..15c1aa8 100644 --- a/src/main/java/net/thauvin/erik/semver/Version.java +++ b/src/main/java/net/thauvin/erik/semver/Version.java @@ -39,41 +39,40 @@ import java.lang.annotation.Target; /** * The Version class implements the annotation interface. * - * @author Erik C. Thauvin + * @author Erik C. Thauvin * @created 2016-01-13 * @since 1.0 */ @Retention(RetentionPolicy.SOURCE) @Target(ElementType.TYPE) -public @interface Version -{ - String buildmeta() default Constants.EMPTY; +public @interface Version { + 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; } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/semver/VersionInfo.java b/src/main/java/net/thauvin/erik/semver/VersionInfo.java index 6da9672..678573d 100644 --- a/src/main/java/net/thauvin/erik/semver/VersionInfo.java +++ b/src/main/java/net/thauvin/erik/semver/VersionInfo.java @@ -34,203 +34,186 @@ package net.thauvin.erik.semver; /** * The VersionInfo class is used to hold and retrieve the semantic version values. * - * @author Erik C. Thauvin + * @author Erik C. Thauvin * @created 2016-01-16 * @since 1.0 */ -public class VersionInfo -{ - private final long epoch = System.currentTimeMillis(); +public class VersionInfo { + 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 - */ - public VersionInfo() - { - major = Constants.DEFAULT_MAJOR; - minor = Constants.DEFAULT_MINOR; - patch = Constants.DEFAULT_PATCH; - buildmeta = Constants.EMPTY; - prerelease = Constants.EMPTY; - project = Constants.EMPTY; - } + /** + * Creates a new object with default values + */ + public VersionInfo() { + major = Constants.DEFAULT_MAJOR; + minor = Constants.DEFAULT_MINOR; + patch = Constants.DEFAULT_PATCH; + buildmeta = Constants.EMPTY; + prerelease = Constants.EMPTY; + project = Constants.EMPTY; + } - /** - * Creates a new object with values from a {@link net.thauvin.erik.semver.Version Version} object. - * - * @param version The version object. - */ - public VersionInfo(final Version version) - { - major = version.major(); - minor = version.minor(); - patch = version.patch(); - buildmeta = version.buildmeta(); - prerelease = version.prerelease(); - project = version.project(); - } + /** + * Creates a new object with values from a {@link net.thauvin.erik.semver.Version Version} object. + * + * @param version The version object. + */ + public VersionInfo(final Version version) { + major = version.major(); + minor = version.minor(); + patch = version.patch(); + buildmeta = version.buildmeta(); + prerelease = version.prerelease(); + project = version.project(); + } - /** - * Returns the build metadata. - * - * @return The build metadata. - */ - public String getBuildMetadata() - { - return buildmeta; - } + /** + * Returns the build metadata. + * + * @return The build metadata. + */ + public String getBuildMetadata() { + return buildmeta; + } - /** - * Sets the build metadata. - * - * @param buildmeta The new build metadata. - */ - public void setBuildMetadata(final String buildmeta) - { - this.buildmeta = buildmeta; - } + /** + * Sets the build metadata. + * + * @param buildmeta The new build metadata. + */ + public void setBuildMetadata(final String buildmeta) { + this.buildmeta = buildmeta; + } - /** - * Returns the build epoch/Unix timestamp. - * - * @return The build epoch. - */ - public long getEpoch() - { - return epoch; - } + /** + * Returns the build epoch/Unix timestamp. + * + * @return The build epoch. + */ + public long getEpoch() { + return epoch; + } - /** - * Returns the major version. - * - * @return The major version. - */ - public int getMajor() - { - return major; - } + /** + * Returns the major version. + * + * @return The major version. + */ + public int getMajor() { + return major; + } - /** - * Sets the major version. - * - * @param major The new major version. - */ - public void setMajor(final int major) - { - this.major = major; - } + /** + * Sets the major version. + * + * @param major The new major version. + */ + public void setMajor(final int major) { + this.major = major; + } - /** - * Returns the major version. - * - * @return The major version. - */ - public int getMinor() - { - return minor; - } + /** + * Returns the major version. + * + * @return The major version. + */ + public int getMinor() { + return minor; + } - /** - * Sets the minor version. - * - * @param minor The new minor version. - */ - public void setMinor(final int minor) - { - this.minor = minor; - } + /** + * Sets the minor version. + * + * @param minor The new minor version. + */ + public void setMinor(final int minor) { + this.minor = minor; + } - /** - * Returns the patch version. - * - * @return The patch version. - */ - public int getPatch() - { - return patch; - } + /** + * Returns the patch version. + * + * @return The patch version. + */ + public int getPatch() { + return patch; + } - /** - * Sets the patch version. - * - * @param patch The new patch version. - */ - public void setPatch(final int patch) - { - this.patch = patch; - } + /** + * Sets the patch version. + * + * @param patch The new patch version. + */ + public void setPatch(final int patch) { + this.patch = patch; + } - /** - * Returns the pre-release version. - * - * @return The pre-release version. - */ - public String getPreRelease() - { - return prerelease; - } + /** + * Returns the pre-release version. + * + * @return The pre-release version. + */ + public String getPreRelease() { + return prerelease; + } - /** - * Sets the pre-release version. - * - * @param prerelease The new pre-release version. - */ - public void setPreRelease(final String prerelease) - { - this.prerelease = prerelease; - } + /** + * Sets the pre-release version. + * + * @param prerelease The new pre-release version. + */ + public void setPreRelease(final String prerelease) { + this.prerelease = prerelease; + } - /** - * Returns the project name. - * - * @return The project name. - */ - public String getProject() - { - return project; - } + /** + * Returns the project name. + * + * @return The project name. + */ + public String getProject() { + return project; + } - /** - * Sets the project name. - * - * @param project The new project name. - */ - public void setProject(final String project) - { - this.project = project; - } + /** + * Sets the project name. + * + * @param project The new project name. + */ + public void setProject(final String project) { + this.project = project; + } - /** - * Returns the full version string. - *

- * Formatted as: - *

MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]
- *

- * For example: - *

    - *
  • 1.0.0
  • - *
  • 1.0.0-beta
  • - *
  • 1.0.0+20160124144700
  • - *
  • 1.0.0-alpha+001
  • - *
- * - * @return The version string. - */ - public String getVersion() - { - return Integer.toString(major) + '.' + Integer.toString(minor) + '.' + Integer.toString(patch) + ( - prerelease.length() > 0 ? '-' + prerelease : "") + (buildmeta.length() > 0 ? '+' + buildmeta : ""); - } + /** + * Returns the full version string. + *

+ * Formatted as: + *

MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]
+ *

+ * For example: + *

    + *
  • 1.0.0
  • + *
  • 1.0.0-beta
  • + *
  • 1.0.0+20160124144700
  • + *
  • 1.0.0-alpha+001
  • + *
+ * + * @return The version string. + */ + public String getVersion() { + return Integer.toString(major) + '.' + Integer.toString(minor) + '.' + Integer.toString(patch) + ( + prerelease.length() > 0 ? '-' + prerelease : "") + (buildmeta.length() > 0 ? '+' + buildmeta : ""); + } } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java index 4a386f8..e62f6e0 100644 --- a/src/main/java/net/thauvin/erik/semver/VersionProcessor.java +++ b/src/main/java/net/thauvin/erik/semver/VersionProcessor.java @@ -52,200 +52,169 @@ import java.util.Set; /** * The VersionProcessor class implements a semantic version annotation processor. * - * @author Erik C. Thauvin + * @author Erik C. Thauvin * @created 2016-01-13 * @since 1.0 */ -public class VersionProcessor extends AbstractProcessor -{ - private Filer filer; +public class VersionProcessor extends AbstractProcessor { + private Filer filer; - private Messager messager; + private Messager messager; - private void error(final String s) - { - log(Diagnostic.Kind.ERROR, s); - } + private void error(final String s) { + log(Diagnostic.Kind.ERROR, s); + } - private void error(final String s, final Throwable t) - { - messager.printMessage(Diagnostic.Kind.ERROR, (t != null ? t.toString() : s)); - } + private void error(final String s, final Throwable t) { + messager.printMessage(Diagnostic.Kind.ERROR, (t != null ? t.toString() : s)); + } - private VersionInfo findValues(final Version version) - throws IOException - { - final VersionInfo versionInfo; + private VersionInfo findValues(final Version version) + throws IOException { + final VersionInfo versionInfo; - if (version.properties().length() > 0) - { - versionInfo = new VersionInfo(); + if (version.properties().length() > 0) { + versionInfo = new VersionInfo(); - final File propsFile = new File(version.properties()); - if (propsFile.exists()) - { - note("Found properties: " + propsFile); - final Properties p = new Properties(); + final File propsFile = new File(version.properties()); + if (propsFile.exists()) { + note("Found properties: " + propsFile); + final Properties p = new Properties(); - try (FileReader reader = new FileReader(propsFile)) - { - p.load(reader); + try (FileReader reader = new FileReader(propsFile)) { + p.load(reader); - versionInfo.setProject(p.getProperty(version.projectKey(), Constants.EMPTY)); - versionInfo.setMajor(parseIntProperty(p, version.majorKey(), Constants.DEFAULT_MAJOR)); - versionInfo.setMinor(parseIntProperty(p, version.minorKey(), Constants.DEFAULT_MINOR)); - versionInfo.setPatch(parseIntProperty(p, version.patchKey(), Constants.DEFAULT_PATCH)); - versionInfo.setBuildMetadata(p.getProperty(version.buildmetaKey(), Constants.EMPTY)); - versionInfo.setPreRelease(p.getProperty(version.prereleaseKey(), Constants.EMPTY)); - } - } - else - { - error("Could not find: " + propsFile); - throw new FileNotFoundException(propsFile + " (The system cannot find the file specified)"); - } - } - else - { - versionInfo = new VersionInfo(version); - } + versionInfo.setProject(p.getProperty(version.projectKey(), Constants.EMPTY)); + versionInfo.setMajor(parseIntProperty(p, version.majorKey(), Constants.DEFAULT_MAJOR)); + versionInfo.setMinor(parseIntProperty(p, version.minorKey(), Constants.DEFAULT_MINOR)); + versionInfo.setPatch(parseIntProperty(p, version.patchKey(), Constants.DEFAULT_PATCH)); + versionInfo.setBuildMetadata(p.getProperty(version.buildmetaKey(), Constants.EMPTY)); + versionInfo.setPreRelease(p.getProperty(version.prereleaseKey(), Constants.EMPTY)); + } + } else { + error("Could not find: " + propsFile); + throw new FileNotFoundException(propsFile + " (The system cannot find the file specified)"); + } + } else { + versionInfo = new VersionInfo(version); + } - return versionInfo; - } + return versionInfo; + } - /** - * {@inheritDoc} - */ - @Override - public Set getSupportedAnnotationTypes() - { - final Set result = new HashSet<>(); - result.add(Version.class.getCanonicalName()); - return result; - } + /** + * {@inheritDoc} + */ + @Override + public Set getSupportedAnnotationTypes() { + final Set result = new HashSet<>(); + result.add(Version.class.getCanonicalName()); + return result; + } - /** - * {@inheritDoc} - */ - @Override - public SourceVersion getSupportedSourceVersion() - { - return SourceVersion.RELEASE_8; - } + /** + * {@inheritDoc} + */ + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.RELEASE_8; + } - /** - * {@inheritDoc} - */ - @Override - public synchronized void init(final ProcessingEnvironment processingEnv) - { - super.init(processingEnv); - filer = processingEnv.getFiler(); - messager = processingEnv.getMessager(); - } + /** + * {@inheritDoc} + */ + @Override + public synchronized void init(final ProcessingEnvironment processingEnv) { + super.init(processingEnv); + filer = processingEnv.getFiler(); + messager = processingEnv.getMessager(); + } - /** - * {@inheritDoc} - */ - @Override - public boolean process(final Set 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) { + messager.printMessage(kind, '[' + VersionProcessor.class.getSimpleName() + "] " + s); + } - private void log(final Diagnostic.Kind kind, final String s) - { - messager.printMessage(kind, '[' + VersionProcessor.class.getSimpleName() + "] " + s); - } + private void note(final String s) { + log(Diagnostic.Kind.NOTE, s); + } - private void note(final String s) - { - log(Diagnostic.Kind.NOTE, s); - } + private int parseIntProperty(final Properties p, final String property, final int defaultValue) { + try { + 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) - { - try - { - return Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue))); - } - catch (NumberFormatException ignore) - { - warn("Invalid property value: " + property); - return defaultValue; - } - } + /** + * {@inheritDoc} + */ + @Override + public boolean process(final Set 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 warn(final String s) - { - log(Diagnostic.Kind.WARNING, s); - } + private void warn(final String s) { + log(Diagnostic.Kind.WARNING, s); + } - private void writeTemplate(final String packageName, final String className, final VersionInfo versionInfo, - final String template) - throws IOException - { - final Properties p = new Properties(); - final URL url = this.getClass().getClassLoader().getResource(Constants.VELOCITY_PROPERTIES); + private void writeTemplate(final String packageName, + final String className, + final VersionInfo versionInfo, + final String template) + throws IOException { + final Properties p = new Properties(); + final URL url = this.getClass().getClassLoader().getResource(Constants.VELOCITY_PROPERTIES); - if (url != null) - { - p.load(url.openStream()); + if (url != null) { + p.load(url.openStream()); - final VelocityEngine ve = new VelocityEngine(p); - ve.init(); + final VelocityEngine ve = new VelocityEngine(p); + ve.init(); - final VelocityContext vc = new VelocityContext(); - vc.put("packageName", packageName); - vc.put("className", className); - vc.put("project", versionInfo.getProject()); - vc.put("buildmeta", versionInfo.getBuildMetadata()); - vc.put("epoch", versionInfo.getEpoch()); - vc.put("patch", versionInfo.getPatch()); - vc.put("major", versionInfo.getMajor()); - vc.put("minor", versionInfo.getMinor()); - vc.put("prerelease", versionInfo.getPreRelease()); + final VelocityContext vc = new VelocityContext(); + vc.put("packageName", packageName); + vc.put("className", className); + vc.put("project", versionInfo.getProject()); + vc.put("buildmeta", versionInfo.getBuildMetadata()); + vc.put("epoch", versionInfo.getEpoch()); + vc.put("patch", versionInfo.getPatch()); + vc.put("major", versionInfo.getMajor()); + vc.put("minor", versionInfo.getMinor()); + 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); - try (final Writer writer = jfo.openWriter()) - { - vt.merge(vc, writer); - } + final JavaFileObject jfo = filer.createSourceFile(packageName + '.' + className); + try (final Writer writer = jfo.openWriter()) { + vt.merge(vc, writer); + } - note("Generated source: " + jfo.getName()); - } - else - { - error("Could not load '" + Constants.VELOCITY_PROPERTIES + "' from jar."); - } - } + note("Generated source: " + jfo.getName()); + } else { + error("Could not load '" + Constants.VELOCITY_PROPERTIES + "' from jar."); + } + } } \ No newline at end of file