Skip to content

Commit

Permalink
changed Version to VersionInfo, added javadocs and cleanedup
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudenw committed May 19, 2024
1 parent e47043a commit 83700ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
3 changes: 1 addition & 2 deletions apache-rat-core/src/main/java/org/apache/rat/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FalseFileFilter;
import org.apache.commons.io.filefilter.NameFileFilter;
import org.apache.commons.io.filefilter.NotFileFilter;
import org.apache.commons.io.filefilter.OrFileFilter;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
Expand Down Expand Up @@ -587,7 +586,7 @@ static void printUsage(final PrintWriter writer, final Options opts) {
HelpFormatter helpFormatter = new HelpFormatter.Builder().get();
helpFormatter.setWidth(HELP_WIDTH);
helpFormatter.setOptionComparator(new OptionComparator());
String syntax = format("java -jar apache-rat/target/apache-rat-%s.jar [options] [DIR|ARCHIVE]", Version.VERSION);
String syntax = format("java -jar apache-rat/target/apache-rat-%s.jar [options] [DIR|ARCHIVE]", VersionInfo.version());
helpFormatter.printHelp(writer, helpFormatter.getWidth(), syntax, header("Available options"), opts,
helpFormatter.getLeftPadding(), helpFormatter.getDescPadding(),
header("Argument Types"), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
import java.io.InputStream;
import java.util.Properties;

public class Version {
public static final String VERSION;
/**
* A container for information provided by the build.
*/
public final class VersionInfo {
/**
* The version info string.
*/
private static final String VERSION;

static {
Properties p = new Properties();
try (InputStream input = Version.class.getResourceAsStream("/org/apache/rat/Version.properties")) {
try (InputStream input = VersionInfo.class.getResourceAsStream("/org/apache/rat/Version.properties")) {
if (input != null) {
p.load(input);
}
Expand All @@ -37,10 +43,14 @@ public class Version {
VERSION = p.getProperty("version", "CURRENT-VERSION");
}

private Version() {
private VersionInfo() {
}

String version() {
/**
* Gets the version string.
* @return the version string.
*/
public static String version() {
return VERSION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import static org.junit.jupiter.api.Assertions.assertNotEquals;

public class VersionTest {
public class VersionInfoTest {
@Test
public void testVersion() {
assertNotEquals( "CURRENT-VERSION", Version.VERSION);
assertNotEquals( "CURRENT-VERSION", VersionInfo.version());
}
}

0 comments on commit 83700ce

Please sign in to comment.