From e8a12857b84872b3b5822063de45e5a0912779ee Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Thu, 11 Jul 2024 09:25:35 -0700 Subject: [PATCH] Cleaned up alternate example class template --- examples/my_app_version.txt | 30 +++++++++++++++++++ examples/myversion.txt | 17 ----------- .../src/bld/java/com/example/SampleBuild.java | 4 +-- 3 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 examples/my_app_version.txt delete mode 100644 examples/myversion.txt diff --git a/examples/my_app_version.txt b/examples/my_app_version.txt new file mode 100644 index 0000000..3d4c223 --- /dev/null +++ b/examples/my_app_version.txt @@ -0,0 +1,30 @@ +package {{v packageName/}}; + +import java.util.Date; + +public final class {{v className/}} implements Comparable<{{v className/}}> { + public static final String PROJECT = "{{v project/}}"; + public static final Date BUILD_DATE = new Date({{v epoch/}}L); + public static final int MAJOR = {{v major/}}; + public static final int MINOR = {{v minor/}}; + public static final int REVISION = {{v revision/}}; + public static final String QUALIFIER = "{{v qualifier/}}"; + public static final String VERSION = "{{v version/}}"; + + private {{v className/}}() { + // no-op + } + + @Override + public int compareTo({{v className/}} other) { + if (MAJOR != other.MAJOR) { + return Integer.compare(MAJOR, other.MAJOR); + } else if (MINOR != other.MINOR) { + return Integer.compare(MINOR, other.MINOR); + } else if (REVISION != other.REVISION) { + return Integer.compare(REVISION, other.REVISION); + } else { + return QUALIFIER.compareTo(other.QUALIFIER); + } + } +} \ No newline at end of file diff --git a/examples/myversion.txt b/examples/myversion.txt deleted file mode 100644 index 8d27e1f..0000000 --- a/examples/myversion.txt +++ /dev/null @@ -1,17 +0,0 @@ -package {{v packageName/}}; - -import java.util.Date; - -public final class {{v className/}} { - public static final String PROJECT = "{{v project/}}"; - public static final Date BUILD_DATE = new Date({{v epoch/}}L); - public static final int MAJOR = {{v major/}}; - public static final int MINOR = {{v minor/}}; - public static final int REVISION = {{v revision/}}; - public static final String QUALIFIER = "{{v qualifier/}}"; - public static final String VERSION = "{{v version/}}"; - - private {{v className/}}() { - // no-op - } -} \ No newline at end of file diff --git a/examples/src/bld/java/com/example/SampleBuild.java b/examples/src/bld/java/com/example/SampleBuild.java index 0069f8d..d2e3c19 100644 --- a/examples/src/bld/java/com/example/SampleBuild.java +++ b/examples/src/bld/java/com/example/SampleBuild.java @@ -45,8 +45,8 @@ public class SampleBuild extends Project { public void genver() throws Exception { new GeneratedVersionOperation() .fromProject(this) -// .projectName("My App") -// .classTemplate("myversion.txt") + .projectName("My App") + .classTemplate("my_app_version.txt") .execute(); } }