Added version.projects property.
Added README.md.
This commit is contained in:
parent
aeee81544c
commit
57116e691f
15 changed files with 218 additions and 67 deletions
|
@ -13,15 +13,15 @@ def deployDir = 'deploy'
|
|||
def getVersion(isIncrement = false)
|
||||
{
|
||||
def propsFile = 'version.properties'
|
||||
def majorProp = 'version.major'
|
||||
def minorProp = 'version.minor'
|
||||
def patchProp = 'version.patch'
|
||||
def metaProp = 'version.buildmeta'
|
||||
def preProp = 'version.prerelease'
|
||||
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: patchProp,
|
||||
entry(key: patchKey,
|
||||
type: 'int',
|
||||
default: '-1',
|
||||
operation: '+')
|
||||
|
@ -29,9 +29,9 @@ def getVersion(isIncrement = false)
|
|||
}
|
||||
def p = new Properties()
|
||||
file(propsFile).withInputStream { stream -> p.load(stream) }
|
||||
def metadata = p.getProperty(metaProp, '')
|
||||
def prerelease = p.getProperty(preProp, '')
|
||||
return (p.getProperty(majorProp, '1') + '.' + p.getProperty(minorProp, '0') + '.' + p.getProperty(patchProp, '0') +
|
||||
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 : ''))
|
||||
}
|
||||
|
||||
|
@ -46,17 +46,17 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile "net.thauvin.erik:semver:+"
|
||||
compile 'net.thauvin.erik:semver:+'
|
||||
}
|
||||
|
||||
annotationProcessor {
|
||||
project.version = getVersion(isRelease)
|
||||
library "net.thauvin.erik:semver:+"
|
||||
processor "net.thauvin.erik.semver.VersionProcessor"
|
||||
library 'net.thauvin.erik:semver:+'
|
||||
processor 'net.thauvin.erik.semver.VersionProcessor'
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.compilerArgs << "-proc:none"
|
||||
options.compilerArgs << '-proc:none'
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -74,17 +74,17 @@ task copyToDeploy(type: Copy) {
|
|||
}
|
||||
|
||||
task deploy(dependsOn: ['build', 'copyToDeploy']) {
|
||||
description = "Copies all needed files to the ${deployDir} directory."
|
||||
group = "Publishing"
|
||||
description = 'Copies all needed files to the ${deployDir} directory.'
|
||||
group = 'Publishing'
|
||||
outputs.dir deployDir
|
||||
inputs.files copyToDeploy
|
||||
mustRunAfter clean
|
||||
}
|
||||
|
||||
|
||||
task release(dependsOn: ['deploy', 'wrapper']) {
|
||||
group = "Publishing"
|
||||
description = "Releases new version."
|
||||
task release(dependsOn: ['deploy', 'wrapper']) << {
|
||||
group = 'Publishing'
|
||||
description = 'Releases new version.'
|
||||
isRelease = true
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Gradle: net.thauvin.erik:semver:1.0" 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" name="Gradle: net.thauvin.erik:semver:1.0.1-beta" level="project" />
|
||||
</component>
|
||||
<component name="org.twodividedbyzero.idea.findbugs">
|
||||
<option name="_basePreferences">
|
||||
|
|
|
@ -13,11 +13,12 @@ import java.util.Date;
|
|||
*/
|
||||
public final class GeneratedVersion {
|
||||
private final static String buildmeta = "";
|
||||
private final static Date date = new Date(1453146881481L);
|
||||
private final static Date date = new Date(1453591949581L);
|
||||
private final static int major = 3;
|
||||
private final static int minor = 1;
|
||||
private final static int patch = 35;
|
||||
private final static String prerelease = "beta";
|
||||
private final static String project = "Example";
|
||||
|
||||
/**
|
||||
* Returns the build date.
|
||||
|
@ -77,6 +78,15 @@ public final class GeneratedVersion {
|
|||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the project name.
|
||||
*
|
||||
* @return The project name, if any.
|
||||
*/
|
||||
public static String getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build metadata.
|
||||
*
|
||||
|
|
|
@ -51,7 +51,7 @@ public class Example
|
|||
{
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("'Built on' EEE, d MMM yyyy 'at' HH:mm:ss z");
|
||||
|
||||
System.out.println(Example.class.getSimpleName() + ' ' + GeneratedVersion.getVersion());
|
||||
System.out.println(GeneratedVersion.getProject() + ' ' + GeneratedVersion.getVersion());
|
||||
System.out.println(sdf.format(GeneratedVersion.getBuildDate()));
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#Mon, 18 Jan 2016 00:09:19 -0800
|
||||
version.project=Example
|
||||
version.major=3
|
||||
version.minor=1
|
||||
version.patch=35
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue