Added custom template example
This commit is contained in:
parent
7b7ce43626
commit
2fa5864c21
1 changed files with 25 additions and 1 deletions
26
README.md
26
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue