diff --git a/NCPBuildBase/src/main/java/fr/neatmonster/nocheatplus/utilities/build/BuildParameters.java b/NCPBuildBase/src/main/java/fr/neatmonster/nocheatplus/utilities/build/BuildParameters.java index 3d5f5a1d..9fe58276 100644 --- a/NCPBuildBase/src/main/java/fr/neatmonster/nocheatplus/utilities/build/BuildParameters.java +++ b/NCPBuildBase/src/main/java/fr/neatmonster/nocheatplus/utilities/build/BuildParameters.java @@ -23,96 +23,96 @@ import java.util.Map; * */ public class BuildParameters { - - private static final Map fileContents = new HashMap(); - - static{ - // Fetch file content from resources. - String content = null; - try{ - content = ResourceUtil.fetchResource(BuildParameters.class, "BuildParameters.properties"); - } - catch(Throwable t){ - t.printStackTrace(); - } - // Parse properties. - if (content != null){ - ResourceUtil.parseToMap(content, fileContents); - } - } - - ////////////////////// - // Auxiliary methods. - ///////////////////// - - /** - * This gets the raw mapping value, might be something like "${...}" in case the parameter has not been present during building. - * @param path - * @param preset - * @return - */ - public static String getMappingValue(String path, String preset){ - String input = fileContents.get(path); - if (input == null) return preset; - else return input; - } - - /** - * Get a string mapping value, excluding missing maven build parameters like '${...}'. - * @param path - * @param preset - * @return - */ - public static String getString(String path, String preset){ - String input = fileContents.get(path); - if (input == null) return preset; - else if (input.startsWith("${") && input.endsWith("}")) return preset; - else return input; - } - - public static Boolean getBoolean(String path, Boolean preset){ - String input = fileContents.get(path); - if (input == null) return preset; - else return ResourceUtil.getBoolean(input, preset); - } - - public static Integer getInteger(String path, Integer preset){ - String input = fileContents.get(path); - if (input == null) return preset; - else return ResourceUtil.getInteger(input, preset); - } - - ////////////////////// - // Public members. - ////////////////////// - - /** Timestamp from build (maven). "?" if not present. */ - public static final String buildTimeString = getString("BUILD_TIMESTAMP", "?"); - - /** Indicate something about where this was built. */ - public static final String buildSeries = getString("BUILD_SERIES", "?"); - - /** The build number as given by Jenkins. Integer.MIN_VALUE if not present. */ - public static final int buildNumber = getInteger("BUILD_NUMBER", Integer.MIN_VALUE); - - /** - * Test level: more testing for higher levels. Defaults to 0. - *
- * Currently only 0 and 1 are used, later there might be more levels and some general policy for level setup (concerning rough time needed on some reference hardware, console output etc.).
- * Compare to debugLevel. - * - */ - public static final int testLevel = getInteger("TEST_LEVEL", 0); - - /** - * Debug level: more debug output for higher levels. Defaults to 0. - *
- * Currently only 0 and 1 are used, however at some point this will follow some guidelines (to be documented here):
- *
  • 0 is meant for few output, just enough for user debug reports or simple testing.
  • - *
  • There are major levels every 100 units (100, 200, ....)
  • - *
  • Consequently minor levels are between major levels to distinguish minor differences like flags
  • - * - */ - public static final int debugLevel = getInteger("DEBUG_LEVEL", 10000); - + + private static final Map fileContents = new HashMap(); + + static{ + // Fetch file content from resources. + String content = null; + try{ + content = ResourceUtil.fetchResource(BuildParameters.class, "BuildParameters.properties"); + } + catch(Throwable t){ + t.printStackTrace(); + } + // Parse properties. + if (content != null){ + ResourceUtil.parseToMap(content, fileContents); + } + } + + ////////////////////// + // Auxiliary methods. + ///////////////////// + + /** + * This gets the raw mapping value, might be something like "${...}" in case the parameter has not been present during building. + * @param path + * @param preset + * @return + */ + public static String getMappingValue(String path, String preset){ + String input = fileContents.get(path); + if (input == null) return preset; + else return input; + } + + /** + * Get a string mapping value, excluding missing maven build parameters like '${...}'. + * @param path + * @param preset + * @return + */ + public static String getString(String path, String preset){ + String input = fileContents.get(path); + if (input == null) return preset; + else if (input.startsWith("${") && input.endsWith("}")) return preset; + else return input; + } + + public static Boolean getBoolean(String path, Boolean preset){ + String input = fileContents.get(path); + if (input == null) return preset; + else return ResourceUtil.getBoolean(input, preset); + } + + public static Integer getInteger(String path, Integer preset){ + String input = fileContents.get(path); + if (input == null) return preset; + else return ResourceUtil.getInteger(input, preset); + } + + ////////////////////// + // Public members. + ////////////////////// + + /** Timestamp from build (maven). "?" if not present. */ + public static final String buildTimeString = getString("BUILD_TIMESTAMP", "?"); + + /** Indicate something about where this was built. */ + public static final String buildSeries = getString("BUILD_SERIES", "?"); + + /** The build number as given by Jenkins. Integer.MIN_VALUE if not present. */ + public static final int buildNumber = getInteger("BUILD_NUMBER", Integer.MIN_VALUE); + + /** + * Test level: more testing for higher levels. Defaults to 0. + *
    + * Currently only 0 and 1 are used, later there might be more levels and some general policy for level setup (concerning rough time needed on some reference hardware, console output etc.).
    + * Compare to debugLevel. + * + */ + public static final int testLevel = getInteger("TEST_LEVEL", 0); + + /** + * Debug level: more debug output for higher levels. Defaults to 0. + *
    + * Currently only 0 and 1 are used, however at some point this will follow some guidelines (to be documented here):
    + *
  • 0 is meant for few output, just enough for user debug reports or simple testing.
  • + *
  • There are major levels every 100 units (100, 200, ....)
  • + *
  • Consequently minor levels are between major levels to distinguish minor differences like flags
  • + * + */ + public static final int debugLevel = getInteger("DEBUG_LEVEL", 10000); + }