-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from openpreserve/fix/version-output
FIX: CLI version output
- Loading branch information
Showing
11 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# ODF Validator | ||
|
||
Latest version is 0.13.1. | ||
Latest version is 0.14.0-SNAPSHOT. | ||
|
||
## About | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
odf-apps/src/main/java/org/openpreservation/odf/apps/BuildVersionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.openpreservation.odf.apps; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Properties; | ||
import java.util.logging.Level; | ||
|
||
import picocli.CommandLine.IVersionProvider; | ||
|
||
public class BuildVersionProvider implements IVersionProvider { | ||
private static final String RAW_DATE_FORMAT = "${maven.build.timestamp.format}"; | ||
|
||
@Override | ||
public String[] getVersion() throws Exception { | ||
Properties props = fromResource("org/openpreservation/odf/apps/build.properties"); | ||
String name = props.getProperty("project.name"); //$NON-NLS-1$ | ||
String version = props.getProperty("release.version"); //$NON-NLS-1$ | ||
String dateFormat = props.getProperty("date.format"); //$NON-NLS-1$ | ||
Date date = new Date(); | ||
if (!dateFormat.equals(RAW_DATE_FORMAT)) { | ||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat); | ||
try { | ||
date = formatter.parse(props.getProperty("release.date")); //$NON-NLS-1$ | ||
} catch (ParseException e) { | ||
/** | ||
* Safe to ignore this exception as release simply set to new | ||
* date. | ||
*/ | ||
} | ||
} | ||
return new String[] { name + " v" + version, //$NON-NLS-1$ | ||
"Built: " + new SimpleDateFormat("yyyy-MM-dd").format(date) }; //$NON-NLS-1$ | ||
} | ||
|
||
private static Properties fromResource(final String resourceName) { | ||
try (InputStream is = BuildVersionProvider.class.getClassLoader().getResourceAsStream(resourceName)) { | ||
Properties props = new Properties(); | ||
if (is != null) { | ||
props.load(is); | ||
} | ||
return props; | ||
} catch (IOException excep) { | ||
throw new IllegalStateException("Couldn't load resource:" + resourceName, excep); //$NON-NLS-1$ | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
odf-apps/src/main/resources/org/openpreservation/odf/apps/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
project.name=${project.name} | ||
release.version=${project.version} | ||
release.date=${odfapps.timestamp} | ||
date.format=${maven.build.timestamp.format} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters