Improved template search path, again

This commit is contained in:
Erik C. Thauvin 2024-07-11 16:25:54 -07:00
parent 61d723b589
commit 07c23883c1
Signed by: erik
GPG key ID: 776702A6A2DA330E
5 changed files with 69 additions and 26 deletions

View file

@ -47,6 +47,7 @@ public class SampleBuild extends Project {
.fromProject(this)
// .projectName("My App")
// .classTemplate("my_app_version.txt")
// .classTemplate("version.txt")
.execute();
}
}

View file

@ -1,30 +1,28 @@
/*
* This file is automatically generated.
* Do not modify! -- ALL CHANGES WILL BE ERASED!
*/
package com.example;
import java.util.Date;
public final class GeneratedVersion implements Comparable<GeneratedVersion> {
public static final Date BUILD_DATE = new Date(1720371304587L);
/**
* Provides project version information.
*/
public final class GeneratedVersion {
public static final String PROJECT = "Sample";
public static final Date BUILD_DATE = new Date(1720742175167L);
public static final int MAJOR = 1;
public static final int MINOR = 0;
public static final String PROJECT = "My App";
public static final String QUALIFIER = "rc1";
public static final int REVISION = 1;
public static final String QUALIFIER = "rc1";
public static final String VERSION = "1.0.1-rc1";
/**
* Disables the default constructor.
*/
private GeneratedVersion() {
// no-op
throw new UnsupportedOperationException("Illegal constructor call.");
}
@Override
public int compareTo(GeneratedVersion 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);
}
}
}
}

17
examples/version.txt Normal file
View file

@ -0,0 +1,17 @@
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
}
}