From 2fa5864c2104b5f6bfc18c3d74225165cca0966b Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sat, 29 Apr 2023 14:00:59 -0700 Subject: [PATCH] Added custom template example --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4385ae5..dbf92e0 100755 --- a/README.md +++ b/README.md @@ -56,13 +56,37 @@ public final class {{v className/}} { You can specified your own template using some or all of the template value tags, as follows: ```java -@BuildCommand(summary = "Generates version class") +@BuildCommand(summary = "Generates MyAppVersion class") public void genver() throws Exception { new GeneratedVersionOperation() .fromProject(this) + .projectName("My App") + .packageName("com.example.myapp") + .className("MyAppVersion") .classTemplate(new File(workDirectory, "myversion.txt")) .execute(); } ``` +```java +// myversion.txt + +package {{v packageName/}}; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; + +public final class {{v className/}} { + public static final String PROJECT = "{{v project/}}"; + public static final LocalDateTime BUILD_DATE = Instant.ofEpochMilli({{v epoch/}}L) + .atZone(ZoneId.systemDefault()).toLocalDateTime(); + public static final String VERSION = "{{v version/}}"; + + private {{v className/}}() { + // no-op + } +} +``` + Please check the [GeneratedVersionOperation documentation](https://rife2.github.io/bld-generated-version/rife/bld/extension/GeneratedVersionOperation.html#method-summary) for all available configuration options.