Reworked default velocity template.
Improved example kobalt build.
This commit is contained in:
parent
b763de695c
commit
62fe418522
18 changed files with 389 additions and 268 deletions
24
example/.idea/modules/example.iml
generated
24
example/.idea/modules/example.iml
generated
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="example" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." 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$/../../build/classes/main" />
|
||||
<output-test url="file://$MODULE_DIR$/../../build/classes/test" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../..">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/generated/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/annotationProcessor/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/test/resources" type="java-test-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: net.thauvin.erik:semver:0.9.5-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>
|
|
@ -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,27 +11,29 @@ 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()
|
||||
|
@ -40,55 +42,55 @@ 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.5-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.5-beta'
|
||||
processor 'net.thauvin.erik.semver.VersionProcessor'
|
||||
// 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: ['deploy', 'wrapper']) << {
|
||||
group = 'Publishing'
|
||||
description = 'Releases new version.'
|
||||
isRelease = true
|
||||
task release(dependsOn: ['clean', 'wrapper', 'deploy']) << {
|
||||
group = 'Publishing'
|
||||
description = 'Releases new version.'
|
||||
isRelease = true
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = gradle.gradleVersion
|
||||
gradleVersion = gradle.gradleVersion
|
||||
}
|
||||
|
||||
|
|
56
example/example.iml
Normal file
56
example/example.iml
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="example" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="KOBALT" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/kobaltBuild/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/kobaltBuild/test-classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/generated/java" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/kobaltBuild" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="Kobalt: net.thauvin.erik:semver:jar:0.9.6-beta">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.kobalt/repository/net/thauvin/erik/semver/0.9.6-beta/semver-0.9.6-beta.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="Kobalt: org.apache.velocity:velocity:jar:1.7">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.kobalt/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="Kobalt: commons-lang:commons-lang:jar:2.4">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.kobalt/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="Kobalt: commons-collections:commons-collections:jar:3.2.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.kobalt/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
|
@ -166,7 +166,7 @@
|
|||
<KobaltProjectSettings>
|
||||
<option name="autoDownloadKobalt" value="true" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="kobaltHome" value="$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.841" />
|
||||
<option name="kobaltHome" value="$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.842" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
@ -182,6 +182,12 @@
|
|||
</MavenGeneralSettings>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value />
|
||||
</option>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Erik's Code Style" />
|
||||
</component>
|
||||
<component name="ProjectInspectionProfilesVisibleTreeState">
|
||||
<entry key="Project Default">
|
||||
<profile-state>
|
||||
|
@ -215,7 +221,7 @@
|
|||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/kobalt/Build.kt.iml" filepath="$PROJECT_DIR$/kobalt/Build.kt.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/example.iml" filepath="$PROJECT_DIR$/.idea/modules/example.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/example.iml" filepath="$PROJECT_DIR$/example.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8.x" project-jdk-type="JavaSDK">
|
||||
|
@ -363,7 +369,7 @@
|
|||
</library>
|
||||
<library name="kobalt.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.841/kobalt/wrapper/kobalt-0.841.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.842/kobalt/wrapper/kobalt-0.842.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
|
@ -374,6 +380,12 @@
|
|||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.840/kobalt/wrapper/kobalt-0.840.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.841/kobalt/wrapper/kobalt-0.841.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.841/kobalt/wrapper/kobalt-0.841.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.841/kobalt/wrapper/kobalt-0.841.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.842/kobalt/wrapper/kobalt-0.842.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.842/kobalt/wrapper/kobalt-0.842.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.842/kobalt/wrapper/kobalt-0.842.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.842/kobalt/wrapper/kobalt-0.842.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.842/kobalt/wrapper/kobalt-0.842.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
|
|
|
@ -34,7 +34,7 @@ val p = project {
|
|||
version = versionFor()
|
||||
|
||||
val mainClassName = "net.thauvin.erik.semver.example.Example"
|
||||
val processorJar = "net.thauvin.erik:semver:0.9.5-beta"
|
||||
val processorJar = "net.thauvin.erik:semver:0.9.6-beta"
|
||||
|
||||
sourceDirectories {
|
||||
path("src/main/java")
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=0.841
|
||||
kobalt.version=0.842
|
|
@ -13,15 +13,15 @@ import java.util.Date;
|
|||
* Annotation Processor</a>
|
||||
*/
|
||||
public final class GeneratedVersion {
|
||||
private final static String buildmeta = "";
|
||||
private final static Date date = new Date(1467521680486L);
|
||||
private final static int major = 3;
|
||||
private final static int minor = 1;
|
||||
private final static int patch = 39;
|
||||
private final static String prerelease = "beta";
|
||||
private final static String project = "Example";
|
||||
private final static String buildmeta = "";
|
||||
private final static Date date = new Date(1467959174599L);
|
||||
private final static int major = 3;
|
||||
private final static int minor = 1;
|
||||
private final static int patch = 45;
|
||||
private final static String prerelease = "beta";
|
||||
private final static String project = "Example";
|
||||
|
||||
/**
|
||||
/**
|
||||
* Disables the default constructor.
|
||||
*
|
||||
* @throws UnsupportedOperationException If the constructor is called.
|
||||
|
@ -71,7 +71,7 @@ public final class GeneratedVersion {
|
|||
return Integer.toString(getMajor()) + '.'
|
||||
+ Integer.toString(getMinor()) + '.'
|
||||
+ Integer.toString(getPatch())
|
||||
+ getPreRelease() + getBuildMetadata();
|
||||
+ getPreRelease(true) + getBuildMetadata(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,14 +101,46 @@ public final class GeneratedVersion {
|
|||
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() {
|
||||
if (prerelease.length() > 0) {
|
||||
return '-' + prerelease;
|
||||
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 "";
|
||||
|
@ -120,10 +152,6 @@ public final class GeneratedVersion {
|
|||
* @return The build metadata, if any.
|
||||
*/
|
||||
public static String getBuildMetadata() {
|
||||
if (buildmeta.length() > 0) {
|
||||
return '+' + buildmeta;
|
||||
}
|
||||
|
||||
return "";
|
||||
return getBuildMetadata(false);
|
||||
}
|
||||
}
|
|
@ -47,9 +47,19 @@ public class Example
|
|||
{
|
||||
public static void main(final String... args)
|
||||
{
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("'Built on' 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(GeneratedVersion.getProject() + ' ' + GeneratedVersion.getVersion());
|
||||
System.out.println(sdf.format(GeneratedVersion.getBuildDate()));
|
||||
System.out.println("-----------------------------------------------------");
|
||||
|
||||
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("-----------------------------------------------------");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue