001/* 002 * Copyright 2025 devteam@scivicslab.com 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, 011 * software distributed under the License is distributed on an 012 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 013 * either express or implied. See the License for the 014 * specific language governing permissions and limitations 015 * under the License. 016 */ 017 018package com.scivicslab.actoriac; 019 020import java.io.IOException; 021import java.io.InputStream; 022import java.util.Properties; 023 024/** 025 * Provides version information for actor-IaC. 026 * 027 * <p>The version is read from version.properties which is populated 028 * by Maven resource filtering at build time.</p> 029 * 030 * @author devteam@scivicslab.com 031 * @since 2.14.0 032 */ 033public final class Version { 034 035 private static final String VERSION; 036 037 static { 038 String version = "unknown"; 039 try (InputStream is = Version.class.getResourceAsStream("/version.properties")) { 040 if (is != null) { 041 Properties props = new Properties(); 042 props.load(is); 043 version = props.getProperty("version", "unknown"); 044 } 045 } catch (IOException e) { 046 // Ignore, use default 047 } 048 VERSION = version; 049 } 050 051 private Version() { 052 // Utility class 053 } 054 055 /** 056 * Returns the actor-IaC version. 057 * 058 * @return the version string (e.g., "2.14.0-SNAPSHOT") 059 */ 060 public static String get() { 061 return VERSION; 062 } 063 064 /** 065 * Returns the full version string for CLI display. 066 * 067 * @return formatted version string (e.g., "actor-IaC 2.14.0-SNAPSHOT") 068 */ 069 public static String full() { 070 return "actor-IaC " + VERSION; 071 } 072 073 /** 074 * Returns the version string for a specific command. 075 * 076 * @param command the command name (e.g., "run", "list") 077 * @return formatted version string (e.g., "actor-IaC run 2.14.0-SNAPSHOT") 078 */ 079 public static String forCommand(String command) { 080 return "actor-IaC " + command + " " + VERSION; 081 } 082}