Skip to content

Commit

Permalink
cli: add more information for version
Browse files Browse the repository at this point in the history
  • Loading branch information
fhussonnois committed Sep 5, 2023
1 parent b056da6 commit af0473c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions jikkou-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ limitations under the License.
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.header.file>${project.parent.basedir}/license-header</license.header.file>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ public final class JikkouInfo {

private static String VERSION = "unknown";

private static String BUILD_TIMESTAMP;

static {
try {
Properties props = new Properties();
props.load(JikkouInfo.class.getResourceAsStream("/jikkou-info.properties"));
VERSION = props.getProperty("version", VERSION).trim();
BUILD_TIMESTAMP = props.getProperty("build.timestamp");
} catch (Exception e) {
LOG.warn("Error while loading version: ", e);
}
Expand All @@ -41,4 +44,7 @@ public final class JikkouInfo {
public static String getVersion() {
return VERSION;
}
public static String getBuildTimestamp() {
return BUILD_TIMESTAMP;
}
}
3 changes: 2 additions & 1 deletion jikkou-api/src/main/resources/jikkou-info.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version=${project.version}
version=${project.version}
build.timestamp=${timestamp}
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ static class ResourcePropertiesVersionProvider implements CommandLine.IVersionPr

public String[] getVersion() {
return new String[]{
"Jikkou " + JikkouInfo.getVersion()
"Jikkou version \"" + JikkouInfo.getVersion() + "\" " + JikkouInfo.getBuildTimestamp(),
"JVM: ${java.version} (${java.vendor} ${java.vm.name} ${java.vm.version})"
};
}
}
Expand Down

0 comments on commit af0473c

Please sign in to comment.