Code format, tabs to spaces, etc.

This commit is contained in:
Erik C. Thauvin 2016-07-18 17:45:07 -07:00
parent 3973b144bc
commit 240c928e77
16 changed files with 826 additions and 667 deletions

View file

@ -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
}

Binary file not shown.

View file

@ -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

46
example/gradlew vendored
View file

@ -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

8
example/gradlew.bat vendored
View file

@ -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

View file

@ -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);
}
}

View file

@ -38,28 +38,26 @@ import java.text.SimpleDateFormat;
/**
* 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
* @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("-----------------------------------------------------");
}
}

View file

@ -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