[java-metadata-aggregator] branch master updated: MDA-179 - fix Version class
Ian Young
ian at iay.org.uk
Wed May 10 12:51:10 EDT 2017
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=87bd011f3ad295e0cf68c8e25f5684c331a32160
The following commit(s) were added to refs/heads/master by this push:
new 87bd011 MDA-179 - fix Version class
87bd011 is described below
commit 87bd011f3ad295e0cf68c8e25f5684c331a32160
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed May 10 17:50:22 2017 +0100
MDA-179 - fix Version class
Make the Version class functional.
Add a --version option to the CLI.
---
.../shibboleth/metadata/cli/SimpleCommandLine.java | 6 +++++
.../metadata/cli/SimpleCommandLineArguments.java | 26 ++++++++++++++++----
aggregator-pipeline/pom.xml | 2 +-
.../main/java/net/shibboleth/metadata/Version.java | 28 ++++++++++++----------
4 files changed, 45 insertions(+), 17 deletions(-)
diff --git a/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLine.java b/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLine.java
index ba7d6e6..d99ced5 100644
--- a/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLine.java
+++ b/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLine.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Date;
import net.shibboleth.metadata.Item;
+import net.shibboleth.metadata.Version;
import net.shibboleth.metadata.pipeline.Pipeline;
import net.shibboleth.metadata.pipeline.TerminationException;
@@ -80,6 +81,11 @@ public final class SimpleCommandLine {
cli.printHelp(System.out);
System.exit(RC_OK);
}
+
+ if (cli.doVersion()) {
+ System.out.println(Version.getVersion());
+ System.exit(RC_OK);
+ }
initLogging(cli);
diff --git a/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLineArguments.java b/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLineArguments.java
index 94abd5a..5f4c7ce 100644
--- a/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLineArguments.java
+++ b/aggregator-cli/src/main/java/net/shibboleth/metadata/cli/SimpleCommandLineArguments.java
@@ -76,6 +76,14 @@ public class SimpleCommandLineArguments {
@Parameter(names = "--help", help=true)
private boolean help;
+ // Version
+
+ /**
+ * Version has been requested.
+ */
+ @Parameter(names = "--version")
+ private boolean version;
+
/**
* Parse an array of command-line arguments as passed to the main program.
*
@@ -85,6 +93,10 @@ public class SimpleCommandLineArguments {
try {
new JCommander(this, args);
+ if (doHelp() || doVersion()) {
+ return;
+ }
+
if (otherArgs.size() != 2) {
printHelp(System.out);
System.out.flush();
@@ -155,14 +167,19 @@ public class SimpleCommandLineArguments {
}
/**
+ * Indicates the presence of the <code>--version</code> option.
+ *
+ * @return <code>true</code> if the user requested the version be printed.
+ */
+ public boolean doVersion() {
+ return version;
+ }
+
+ /**
* Validate the provided command line arguments, for example issuing
* an error if they are inconsistent.
*/
private void validateCommandLineArguments() {
- if (doHelp()) {
- return;
- }
-
if (doVerboseOutput() && doQuietOutput()) {
errorAndExit("Verbose and quiet output are mutually exclusive");
}
@@ -185,6 +202,7 @@ public class SimpleCommandLineArguments {
out.println("==== Command Line Options ====");
out.println();
out.println(String.format(" --%-20s %s", "help", "Prints this help information"));
+ out.println(String.format(" --%-20s %s", "version", "Prints aggregator framework version"));
out.println();
out.println("Logging Options - these options are mutually exclusive");
diff --git a/aggregator-pipeline/pom.xml b/aggregator-pipeline/pom.xml
index 9d1b262..fc90331 100644
--- a/aggregator-pipeline/pom.xml
+++ b/aggregator-pipeline/pom.xml
@@ -99,7 +99,7 @@
</manifestEntries>
<manifestSections>
<manifestSection>
- <name>net/shibboleth/metadata</name>
+ <name>net/shibboleth/metadata/</name>
<manifestEntries>
<Implementation-Title>${project.artifactId}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/Version.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/Version.java
index 8dd8241..9ee299e 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/Version.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/Version.java
@@ -22,17 +22,17 @@ import javax.annotation.Nonnull;
/** Class for getting and printing the version of the metadata pipeline. */
public final class Version {
- /** metadata pipeline version. */
+ /** Metadata pipeline version. */
private static final String VERSION;
- /** metadata pipeline major version number. */
+ /** Metadata pipeline major version number. */
private static final int MAJOR_VERSION;
- /** metadata pipeline minor version number. */
+ /** Metadata pipeline minor version number. */
private static final int MINOR_VERSION;
- /** metadata pipeline micro version number. */
- private static final int MICRO_VERSION;
+ /** Metadata pipeline patch version number. */
+ private static final int PATCH_VERSION;
/** Constructor. */
private Version() {
@@ -76,19 +76,23 @@ public final class Version {
}
/**
- * Gets the micro version number of the metadata pipeline.
+ * Gets the patch version number of the metadata pipeline.
*
- * @return micro version number of the metadata pipeline
+ * @return patch version number of the metadata pipeline
*/
- public static int getMicroVersion() {
- return MICRO_VERSION;
+ public static int getPatchVersion() {
+ return PATCH_VERSION;
}
static {
VERSION = Version.class.getPackage().getImplementationVersion();
- final String[] versionParts = VERSION.split(".");
+
+ // Semantic versioning: three dot-separated numbers, followed by extensions
+ // separated by '-' and '+'.
+ final String[] versionParts = VERSION.split("[\\.\\+\\-]");
+
MAJOR_VERSION = Integer.parseInt(versionParts[0]);
MINOR_VERSION = Integer.parseInt(versionParts[1]);
- MICRO_VERSION = Integer.parseInt(versionParts[2]);
+ PATCH_VERSION = Integer.parseInt(versionParts[2]);
}
-}
\ No newline at end of file
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list