Cleaned up API to match bld operations aand options APIs
This commit is contained in:
parent
46b9a52215
commit
eabca28d38
6 changed files with 56 additions and 6 deletions
6
.idea/bld.xml
generated
Normal file
6
.idea/bld.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="BldConfiguration">
|
||||||
|
<events />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -1,6 +1,6 @@
|
||||||
bld.downloadExtensionJavadoc=false
|
bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.downloadLocation=
|
bld.downloadLocation=
|
||||||
bld.extension-gv=com.uwyn.rife2:bld-generated-version:0.9.8
|
bld.extension-gv=com.uwyn.rife2:bld-generated-version:0.9.9-SNAPSHOT
|
||||||
bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
bld.version=2.0.1
|
bld.version=2.0.1
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
public final class GeneratedVersion {
|
public final class GeneratedVersion {
|
||||||
public static final String PROJECT = "Sample";
|
public static final String PROJECT = "Sample";
|
||||||
public static final Date BUILD_DATE = new Date(1722235624114L);
|
public static final Date BUILD_DATE = new Date(1724831563821L);
|
||||||
public static final int MAJOR = 1;
|
public static final int MAJOR = 1;
|
||||||
public static final int MINOR = 0;
|
public static final int MINOR = 0;
|
||||||
public static final int REVISION = 1;
|
public static final int REVISION = 1;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class GeneratedVersionOperationBuild extends Project {
|
||||||
public GeneratedVersionOperationBuild() {
|
public GeneratedVersionOperationBuild() {
|
||||||
pkg = "rife.bld.extension";
|
pkg = "rife.bld.extension";
|
||||||
name = "GeneratedVersionOperation";
|
name = "GeneratedVersionOperation";
|
||||||
version = version(0, 9, 8);
|
version = version(0, 9, 9, "SNAPSHOT");
|
||||||
|
|
||||||
javaRelease = 17;
|
javaRelease = 17;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import rife.bld.operations.AbstractOperation;
|
||||||
import rife.bld.operations.exceptions.ExitStatusException;
|
import rife.bld.operations.exceptions.ExitStatusException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -67,6 +68,16 @@ public class GeneratedVersionOperation extends AbstractOperation<GeneratedVersio
|
||||||
return classTemplate(new File(template));
|
return classTemplate(new File(template));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the class template path.
|
||||||
|
*
|
||||||
|
* @param template the template path
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public GeneratedVersionOperation classTemplate(Path template) {
|
||||||
|
return classTemplate(template.toFile());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the destination directory.
|
* Sets the destination directory.
|
||||||
*
|
*
|
||||||
|
@ -88,6 +99,16 @@ public class GeneratedVersionOperation extends AbstractOperation<GeneratedVersio
|
||||||
return directory(new File(directory));
|
return directory(new File(directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the destination directory.
|
||||||
|
*
|
||||||
|
* @param directory the destination directory
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public GeneratedVersionOperation directory(Path directory) {
|
||||||
|
return directory(directory.toFile());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a version data class for this project.
|
* Generates a version data class for this project.
|
||||||
*/
|
*/
|
||||||
|
@ -140,6 +161,15 @@ public class GeneratedVersionOperation extends AbstractOperation<GeneratedVersio
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the generated version instance.
|
||||||
|
*
|
||||||
|
* @return the generated version
|
||||||
|
*/
|
||||||
|
public GeneratedVersion generatedVersion() {
|
||||||
|
return generatedVersion_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the package name.
|
* Sets the package name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -91,17 +91,16 @@ class GeneratedVersionTest {
|
||||||
gv.setClassName("MyVersion");
|
gv.setClassName("MyVersion");
|
||||||
|
|
||||||
var t = gv.buildTemplate();
|
var t = gv.buildTemplate();
|
||||||
//noinspection TrailingWhitespacesInTextBlock
|
|
||||||
assertThat(t.getContent()).isEqualTo("""
|
assertThat(t.getContent()).isEqualTo("""
|
||||||
package com.example.my;
|
package com.example.my;
|
||||||
|
|
||||||
public final class MyVersion {
|
public final class MyVersion {
|
||||||
public static final int PROJECT = "My App";
|
public static final int PROJECT = "My App";
|
||||||
public static final int MAJOR = 2;
|
public static final int MAJOR = 2;
|
||||||
public static final int MINOR = 1;
|
public static final int MINOR = 1;
|
||||||
public static final int REVISION = 3;
|
public static final int REVISION = 3;
|
||||||
public static final String QUALIFIER = "";
|
public static final String QUALIFIER = "";
|
||||||
|
|
||||||
private MyVersion() {
|
private MyVersion() {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
|
@ -127,6 +126,21 @@ class GeneratedVersionTest {
|
||||||
.contains("private GeneratedVersion");
|
.contains("private GeneratedVersion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testDirectories() {
|
||||||
|
var foo = new File("foo");
|
||||||
|
var bar = new File("bar");
|
||||||
|
|
||||||
|
var op = new GeneratedVersionOperation().directory(foo);
|
||||||
|
assertThat(op.generatedVersion().getDirectory()).as("as file").isEqualTo(foo);
|
||||||
|
|
||||||
|
op = op.directory(bar.toPath());
|
||||||
|
assertThat(op.generatedVersion().getDirectory()).as("as path").isEqualTo(bar);
|
||||||
|
|
||||||
|
op = op.directory("foo");
|
||||||
|
assertThat(op.generatedVersion().getDirectory()).as("as string").isEqualTo(foo);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testExample() throws Exception {
|
void testExample() throws Exception {
|
||||||
var tmpDir = Files.createTempDirectory("bld-generated-version-example-").toFile();
|
var tmpDir = Files.createTempDirectory("bld-generated-version-example-").toFile();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue