bld Extension to Generate Project Version Data https://github.com/rife2/bld-generated-version
Find a file
2023-04-28 10:28:37 -07:00
.github/workflows Added GitHub workflows 2023-04-28 10:28:37 -07:00
.idea Initial commit 2023-04-27 22:36:49 -07:00
.vscode Initial commit 2023-04-27 22:36:49 -07:00
config Initial commit 2023-04-27 22:36:49 -07:00
example Added example 2023-04-28 10:27:42 -07:00
lib/bld Initial commit 2023-04-27 22:36:49 -07:00
src Improved buildTemplate and writeTemplate 2023-04-28 10:27:18 -07:00
.gitignore Initial commit 2023-04-27 22:36:49 -07:00
bld Initial commit 2023-04-27 22:36:49 -07:00
bld.bat Initial commit 2023-04-27 22:36:49 -07:00
LICENSE.txt Initial commit 2023-04-27 22:36:49 -07:00
README.md Added README 2023-04-28 10:28:17 -07:00

Bld Extension to Generate Project Version Data

License (3-Clause BSD) Java Release Snapshot GitHub CI

To automatically create a generated version class using the default template in your project on compile:

@Override
public void compile() throws Exception {
    genver();
    super.compile();
}

@BuildCommand(summary = "Generates version class")
public void genver() throws Exception {
    new GeneratedVersionOperation()
        .fromProject(this)
        .execute();
}
./bld compile

Version Class Template

This is the default template:

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/}}() {
        throw new UnsupportedOperationException("Illegal constructor call.");
    }
}

Custom Template

You can specified your own template using some or all of the template value tags, as follows:

@BuildCommand(summary = "Generates version class")
public void genver() throws Exception {
    new GeneratedVersionOperation()
        .fromProject(this)
        .classTemplate(new File(".", "myversion.txt"))
        .execute();
}

Please check the GeneratedVersionOperation documentation for all available configuration options.