Added EntryBase, EntryDate and EntryInt

This commit is contained in:
Erik C. Thauvin 2023-04-06 03:43:09 -07:00
parent 99c3774227
commit 473a70329e
13 changed files with 794 additions and 497 deletions

View file

@ -15,6 +15,7 @@ To run the examples, issue one of the following command or combination there off
./bld updateMajor run
./bld updateMinor run
./bld updatePatch run
./bld updateRelease run
```
Upon execution, the `version.properties` file will be created and displayed:

View file

@ -1,5 +1,5 @@
#Sun Apr 02 10:32:44 PDT 2023
bld.extension=com.uwyn.rife2:bld-property-file:0.9.0
bld.extension=com.uwyn.rife2:bld-property-file:0.9.1-SNAPSHOT
bld.repositories=MAVEN_LOCAL,RIFE2
bld.downloadExtensionSources=true
rife2.downloadLocation=

View file

@ -3,18 +3,18 @@ package com.example;
import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.extension.propertyfile.Entry;
import rife.bld.extension.propertyfile.Entry.Types;
import rife.bld.extension.propertyfile.EntryDate;
import rife.bld.extension.propertyfile.EntryInt;
import rife.bld.extension.propertyfile.PropertyFileOperation;
import java.util.List;
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Repository.SONATYPE_SNAPSHOTS;
import static rife.bld.dependencies.Scope.test;
import static rife.bld.extension.propertyfile.Calc.ADD;
public class PropertyFileExampleBuild extends Project {
final Entry buildDateEntry = new Entry("build.date").set("now").pattern("yyyy-MM-dd").type(Types.DATE);
final EntryDate buildDateEntry = new EntryDate("build.date").now().pattern("yyyy-MM-dd");
public PropertyFileExampleBuild() {
pkg = "com.example";
@ -23,7 +23,7 @@ public class PropertyFileExampleBuild extends Project {
version = version(0, 1, 0);
downloadSources = true;
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
repositories = List.of(MAVEN_CENTRAL);
scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 2)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 2)));
@ -38,11 +38,11 @@ public class PropertyFileExampleBuild extends Project {
new PropertyFileOperation(this)
.file("version.properties")
// set the major version to 1 if it doesn't exist, increase by 1
.entry(new Entry("version.major").defaultValue(0).type(Types.INT).calc(ADD))
.entry(new EntryInt("version.major").defaultValue(0).calc(ADD))
// set the minor version to 0
.entry(new Entry("version.minor").set(0))
.entry(new EntryInt("version.minor").set(0))
// set the patch version to 0
.entry(new Entry("version.patch").set(0))
.entry(new EntryInt("version.patch").set(0))
// set the build date to the current date
.entry(buildDateEntry)
.execute();
@ -53,11 +53,11 @@ public class PropertyFileExampleBuild extends Project {
new PropertyFileOperation(this)
.file("version.properties")
// set the major version to 1 if it doesn't exist
.entry(new Entry("version.major").defaultValue(1))
.entry(new EntryInt("version.major").defaultValue(1))
// set the minor version to 0 if it doesn't exist, increase by 1
.entry(new Entry("version.minor").defaultValue(-1).type(Types.INT).calc(ADD))
.entry(new EntryInt("version.minor").defaultValue(-1).calc(ADD))
// set the patch version to 0
.entry(new Entry("version.patch").set(0))
.entry(new EntryInt("version.patch").set(0))
// set the build date to the current date
.entry(buildDateEntry)
.execute();
@ -68,16 +68,27 @@ public class PropertyFileExampleBuild extends Project {
new PropertyFileOperation(this)
.file("version.properties")
// set the major version to 1 if it doesn't exist
.entry(new Entry("version.major").defaultValue(1))
.entry(new EntryInt("version.major").defaultValue(1))
// set the minor version to 0 if it doesn't exist
.entry(new Entry("version.minor").defaultValue(0))
.entry(new EntryInt("version.minor").defaultValue(0))
// set the patch version to 10 if it doesn't exist, increase by 10
.entry(new Entry("version.patch").defaultValue(0).type(Types.INT).calc(v -> v + 10))
.entry(new EntryInt("version.patch").defaultValue(0).calc(v -> v + 10))
// set the build date to the current date
.entry(buildDateEntry)
.execute();
}
@BuildCommand(summary = "Updates the release")
public void updateRelease() throws Exception {
new PropertyFileOperation(this)
.file("version.properties")
// set the release to current date/time
.entry(new EntryDate("release").now().pattern("yyyyMMddHHmmss"))
// prepend 'beta.' to the release
.entry(new Entry("release").modify("beta.", (v, s) -> s + v))
.execute();
}
@BuildCommand(summary = "Delete version properties")
public void deleteVersion() throws Exception {
new PropertyFileOperation(this)
@ -85,6 +96,7 @@ public class PropertyFileExampleBuild extends Project {
.entry(new Entry("version.major").delete())
.entry(new Entry("version.minor").delete())
.entry(new Entry("version.patch").delete())
.entry(new Entry("release").delete())
.entry(buildDateEntry.delete())
.execute();
}