Normalized fields and property names.
This commit is contained in:
parent
3f630c1b55
commit
6d76cceeef
5 changed files with 30 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Example.java
|
||||
*
|
||||
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -49,7 +49,7 @@ public class Example {
|
|||
|
||||
System.out.println("-----------------------------------------------------");
|
||||
|
||||
System.out.println(" " + GeneratedVersion.project + ' ' + GeneratedVersion.getVersion());
|
||||
System.out.println(" " + GeneratedVersion.project + ' ' + GeneratedVersion.version);
|
||||
|
||||
System.out.println(" Built on: " + sdf.format(GeneratedVersion.buildDate));
|
||||
System.out.println(" Major: " + GeneratedVersion.major);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Constants.java
|
||||
*
|
||||
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -43,10 +43,6 @@ public final class Constants {
|
|||
* The default class name.
|
||||
*/
|
||||
public static final String DEFAULT_CLASS_NAME = "GeneratedVersion";
|
||||
/**
|
||||
* The default mustache template.
|
||||
*/
|
||||
public static final String DEFAULT_TEMPLATE = "version.mustache";
|
||||
/**
|
||||
* /**
|
||||
* The default Java mustache template.
|
||||
|
@ -72,6 +68,10 @@ public final class Constants {
|
|||
* The default patch version.
|
||||
*/
|
||||
public static final int DEFAULT_PATCH = 0;
|
||||
/**
|
||||
* The default mustache template.
|
||||
*/
|
||||
public static final String DEFAULT_TEMPLATE_NAME = "version.mustache";
|
||||
/**
|
||||
* The empty string.
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Version.java
|
||||
*
|
||||
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -46,9 +46,9 @@ import java.lang.annotation.Target;
|
|||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
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;
|
||||
|
||||
|
@ -64,9 +64,9 @@ public @interface Version {
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* VersionInfo.java
|
||||
*
|
||||
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -74,8 +74,8 @@ public class VersionInfo {
|
|||
major = version.major();
|
||||
minor = version.minor();
|
||||
patch = version.patch();
|
||||
buildMeta = version.buildmeta();
|
||||
preRelease = version.prerelease();
|
||||
buildMeta = version.buildMeta();
|
||||
preRelease = version.preRelease();
|
||||
project = version.project();
|
||||
className = version.className();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* VersionProcessor.java
|
||||
*
|
||||
* Copyright (c) 2016, Erik C. Thauvin (erik@thauvin.net)
|
||||
* Copyright (c) 2016-2017, Erik C. Thauvin (erik@thauvin.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -80,7 +80,7 @@ public class VersionProcessor extends AbstractProcessor {
|
|||
if (propsFile.exists()) {
|
||||
note("Found properties: " + propsFile);
|
||||
final Properties p = new Properties();
|
||||
|
||||
|
||||
try (FileReader reader = new FileReader(propsFile)) {
|
||||
p.load(reader);
|
||||
|
||||
|
@ -88,8 +88,8 @@ public class VersionProcessor extends AbstractProcessor {
|
|||
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.setBuildMeta(p.getProperty(version.buildmetaKey(), Constants.EMPTY));
|
||||
versionInfo.setPreRelease(p.getProperty(version.prereleaseKey(), Constants.EMPTY));
|
||||
versionInfo.setBuildMeta(p.getProperty(version.buildMetaKey(), Constants.EMPTY));
|
||||
versionInfo.setPreRelease(p.getProperty(version.preReleaseKey(), Constants.EMPTY));
|
||||
}
|
||||
} else {
|
||||
error("Could not find: " + propsFile);
|
||||
|
@ -164,8 +164,8 @@ public class VersionProcessor extends AbstractProcessor {
|
|||
note("Found version: " + versionInfo.getVersion());
|
||||
final String template;
|
||||
if (version.template().equals(Constants.DEFAULT_JAVA_TEMPLATE) &&
|
||||
new File(Constants.DEFAULT_TEMPLATE).exists()) {
|
||||
template = Constants.DEFAULT_TEMPLATE;
|
||||
new File(Constants.DEFAULT_TEMPLATE_NAME).exists()) {
|
||||
template = Constants.DEFAULT_TEMPLATE_NAME;
|
||||
} else if (version.template().equals(Constants.DEFAULT_JAVA_TEMPLATE) &&
|
||||
version.type().equals(Constants.KOTLIN_TYPE)) {
|
||||
template = Constants.DEFAULT_KOTLIN_TEMPLATE;
|
||||
|
@ -191,7 +191,15 @@ public class VersionProcessor extends AbstractProcessor {
|
|||
final MustacheFactory mf = new DefaultMustacheFactory();
|
||||
final Mustache mustache = mf.compile(template);
|
||||
|
||||
note("Loaded template: " + mustache.getName());
|
||||
final String templateName;
|
||||
if (mustache.getName().equals(Constants.DEFAULT_JAVA_TEMPLATE)) {
|
||||
templateName = "default (java)";
|
||||
} else if (mustache.getName().equals(Constants.DEFAULT_KOTLIN_TEMPLATE)) {
|
||||
templateName = "default (kotlin)";
|
||||
} else {
|
||||
templateName = mustache.getName();
|
||||
}
|
||||
note("Loaded template: " + templateName);
|
||||
|
||||
final FileObject jfo;
|
||||
if (type.equalsIgnoreCase(Constants.KOTLIN_TYPE)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue