--- java-1.5-fixer 2006-07-18 12:43:03.000000000 +0200 +++ java-1.5-fixer 2006-07-28 13:55:15.000000000 +0200 @@ -60,29 +60,68 @@ fi } +# $1 - package.env file +# $2 - name of VAR=foo variable +get_value_from_package_env() { + # get the VAR line from package.env + local line="$(grep ${2} ${1})" + + # strip VAR= + local value="${line#${2}=}" + + # strip quotes + value="${value//\"/}" + + echo ${value} +} + get_jars_from_package_env() { local package_env=${1} # keep track of the original classpath local save_classpath=${CLASSPATH} - local classpath_line=$(grep CLASSPATH ${package_env}) - # strip CLASSPATH= - local package_classpath=${classpath_line#CLASSPATH=} - # strip quotes - package_classpath=${package_classpath//\"/} - #local package_classpath=$(source ${package_env} >/dev/null 2>&1; echo ${CLASSPATH}) + # get classpath from package.env + package_classpath=$(get_value_from_package_env ${package_env} CLASSPATH) echo ${package_classpath//:/ } } +check_package_env_valid_gen2_target_15() { + local generation=$(get_value_from_package_env ${1} GENERATION) + + debug_print "${1} generation: ${generation}" + + # packages with generation 1 or without generation won't have TARGET and shouldn't be 1.5 + if [[ "${generation}" != "2" ]]; then + return 1 + fi + + local target=$(get_value_from_package_env ${1} TARGET) + + debug_print "${1} target: $target" + + # packages with target 1.5 or 1.6 are valid to have 1.5+ bytecode, skip them + if [[ "${target}" = "1.5" || "${target}" = "1.6" ]]; then + return 0 + fi + + # bytecode should be under 1.5, check it + return 1 +} + get_jars() { local package_envs=$@ local package_env local all_jars # for each package.env file for package_env in ${package_envs}; do - if [[ -f ${package_env} ]]; then + if [[ -f ${package_env} ]]; then + #check if package is valid gen2 with 1.5+ target + if $(check_package_env_valid_gen2_target_15 ${package_env}); then + debug_print "skipping ${package_env}" + continue + fi debug_print "parsing ${package_env}" # figure out what jars are in it local jars=$(get_jars_from_package_env ${package_env})