From e01f9041e7cb466dede5fa79bc2683c3296b5d0c Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 04 Mar 2016 16:29:56 +0000
Subject: [PATCH] OPENDJ-2582 Fix dsconfig --version
---
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java | 27 ++-------------------------
opendj-config/pom.xml | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/opendj-config/pom.xml b/opendj-config/pom.xml
index 929f67d..382382e 100644
--- a/opendj-config/pom.xml
+++ b/opendj-config/pom.xml
@@ -94,6 +94,19 @@
</resources>
<plugins>
+ <!-- Retrieve the SCM revision number and store it into the ${buildRevision} property -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <executions>
+ <!-- We do not need build timestamp for this module -->
+ <execution>
+ <id>generate-timestamp</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@@ -150,6 +163,11 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <SCM-Revision>${buildRevision}</SCM-Revision>
+ </instructions>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
index 0a17248..dfaa33c 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
@@ -19,6 +19,7 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.CliMessages.*;
import static com.forgerock.opendj.cli.DocGenerationHelper.*;
+import static com.forgerock.opendj.cli.ToolVersionHandler.newToolVersionHandler;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.dsconfig.DsconfigMessages.*;
import static com.forgerock.opendj.util.StaticUtils.*;
@@ -37,19 +38,16 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
@@ -115,7 +113,6 @@
import com.forgerock.opendj.cli.SubCommand;
import com.forgerock.opendj.cli.SubCommandArgumentParser;
import com.forgerock.opendj.cli.SubCommandUsageHandler;
-import com.forgerock.opendj.cli.VersionHandler;
/**
* This class provides a command-line tool which enables administrators to configure the Directory Server.
@@ -862,27 +859,7 @@
this.parser.setShortToolDescription(REF_SHORT_DESC_DSCONFIG.get());
this.parser.setDocToolDescriptionSupplement(REF_DSCFG_DOC_TOOL_DESCRIPTION.get());
this.parser.setDocSubcommandsDescriptionSupplement(REF_DSCFG_DOC_SUBCOMMANDS_DESCRIPTION.get());
- this.parser.setVersionHandler(new VersionHandler() {
- @Override
- public void printVersion() {
- System.out.println(getVersionString());
- }
-
- private String getVersionString() {
- try {
- final Enumeration<URL> resources = getClass().getClassLoader().getResources(
- "META-INF/maven/org.forgerock.opendj/opendj-config/pom.properties");
- while (resources.hasMoreElements()) {
- final Properties props = new Properties();
- props.load(resources.nextElement().openStream());
- return (String) props.get("version");
- }
- } catch (IOException e) {
- errPrintln(LocalizableMessage.raw(e.getMessage()));
- }
- return "";
- }
- });
+ this.parser.setVersionHandler(newToolVersionHandler("opendj-config"));
if (System.getProperty("org.forgerock.opendj.gendoc") != null) {
this.parser.setUsageHandler(new DSConfigSubCommandUsageHandler());
}
--
Gitblit v1.10.0