Use Version.properties to store version information, instead of Bundle.properties that is a tracked file.

This commit is contained in:
adam-m 2012-07-25 09:57:24 -04:00
parent e1857a7647
commit fe8ce51961
3 changed files with 58 additions and 15 deletions

2
.gitignore vendored
View File

@ -22,7 +22,7 @@ Bundle_*.properties
genfiles.properties genfiles.properties
/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties /branding/core/core.jar/org/netbeans/core/startup/Bundle.properties
/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties /branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties
/CoreUtils/src/org/sleuthkit/autopsy/coreutils/Bundle.properties /CoreUtils/src/org/sleuthkit/autopsy/coreutils/Version.properties
/Testing/script/input/ /Testing/script/input/
/Testing/script/output/ /Testing/script/output/
/Testing/script/gold/ /Testing/script/gold/

View File

@ -18,29 +18,72 @@
*/ */
package org.sleuthkit.autopsy.coreutils; package org.sleuthkit.autopsy.coreutils;
import org.openide.util.NbBundle; import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/** /**
* * Utility to get version and build settings set at build time
* @author dfickling
*/ */
public class Version { public class Version {
private Version() { } private static Properties versionProperties;
public enum Type{ private Version() {
}
public enum Type {
RELEASE, DEVELOPMENT; RELEASE, DEVELOPMENT;
} }
private static void loadVersionProperty() {
if (versionProperties != null) {
return;
}
versionProperties = new Properties();
try {
InputStream inputStream = Version.class.getResourceAsStream("Version.properties");
versionProperties.load(inputStream);
} catch (IOException e) {
versionProperties = null;
}
}
private static String getVersionProperty(String property) {
loadVersionProperty();
if (versionProperties == null) {
return "";
} else {
return versionProperties.getProperty(property);
}
}
/**
* Get the application version as set at build time
* @return application version string
*/
public static String getVersion() { public static String getVersion() {
return NbBundle.getMessage(Version.class, "app.version"); return getVersionProperty("app.version");
} }
/**
* Get the application name as set at build time
* @return the application name string
*/
public static String getName() { public static String getName() {
return NbBundle.getMessage(Version.class, "app.name"); return getVersionProperty("app.name");
} }
/**
* Get the application build type as set at build time
* @return the application build type
*/
public static Version.Type getBuildType() { public static Version.Type getBuildType() {
return Type.valueOf(NbBundle.getMessage(Version.class, "build.type")); String valueProp = getVersionProperty("build.type");
return Type.valueOf(valueProp);
} }
} }

View File

@ -178,7 +178,7 @@
</propertyfile> </propertyfile>
<propertyfile <propertyfile
file="${basedir}/CoreUtils/src/org/sleuthkit/autopsy/coreutils/Bundle.properties" file="${basedir}/CoreUtils/src/org/sleuthkit/autopsy/coreutils/Version.properties"
comment="Updated by build script"> comment="Updated by build script">
<entry key="app.name" value="${app.title}" /> <entry key="app.name" value="${app.title}" />
<entry key="app.version" value="${app.version}" /> <entry key="app.version" value="${app.version}" />