All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.admc.gradle..JavaPropFile.groovy.swp Maven / Gradle / Ivy

There is a newer version: 0.6.0
Show newest version
b0VIM 7.3b??Np??jblainebeyla~blaine/gradle-javaPropFile-plugin/src/main/groovy/com/admc/gradle/JavaPropFile.groovyutf-8
3210#"! UtpYaZQ?
ad?Y?????dF 
??tI?
?
?
?
l
7

?????`????rlkL?
?
V
R
&
?	?	?	q	V	1		??rR2??B
??\??zR@????hC9??z.???=????        if (unsatisfiedRefBehavior == Behavior.NO_SET) return                + unsatisfiedRefBehavior)                + '.\nWill handle according to unsatisifiedRefBehavior: '                + '\ndue to unresolved references to: ' + unresolveds                'Unable to resolve top-level properties: ' + props.keySet()        gp.logger.warn(                + '\ndue to unresolved references to: ' + unresolveds)                'Unable to resolve top-level properties: ' + props.keySet()            throw new GradleException(        if (unsatisfiedRefBehavior == Behavior.THROW)        // If we get here, then we have unsatisfied references        if (prevCount == 0) return        }            prevCount = props.size()            if (prevCount == props.size()) break            }                }                    props.remove(pk)                    assign(pk, newValString, systemPropPattern)                if (haveNewVal) {                }                    return matchGrps[0]                    haveNewVal = false                    unresolveds << matchGrps[1]                        return System.properties[matchGrps[1]]                            && System.properties.containsKey(matchGrps[1]))                    if (expandSystemProps                        return gp.property(matchGrps[1])                            && (gp.property(matchGrps[1]) instanceof String))                    if (gp.hasProperty(matchGrps[1])                    // This block resolves ${references} in property values                newValString = pv.replaceAll(curlyRefGrpPattern) { matchGrps ->                haveNewVal = true            new HashMap(props).each() { pk, pv ->            unresolveds.clear()        while (prevCount > 0) {                : Pattern.compile("^\\Q" + systemPropPrefix + "\\E(.+)"))                ? null        Pattern systemPropPattern = ((systemPropPrefix == null)         def unresolveds = []        int prevCount = props.size()        boolean haveNewVal        String newValString                'Loaded ' + props.size() + ' from ' + propFile.absolutePath)        gp.logger.info(        propFile.withInputStream { props.load(it) }        Properties props = new Properties()"""            """Specified properties file inaccessible:  $propFile.absolutePath        assert propFile.isFile() && propFile.canRead():            '''unsatisfiedRefBehavior may not be set to null'''        assert unsatisfiedRefBehavior != null:    void load(File propFile) {    }        gp = p    JavaPropFile(Project p) {    //enum Behavior { LITERAL, EMPTY, NO_SET, UNSET, THROW }    enum Behavior { LITERAL, EMPTY, NO_SET, THROW }    // property from a Project.  Project.properties.remove('x') does not work.    // Giving up on UNSET because Gradle provides no way to remove a    String systemPropPrefix    boolean typeCasting    boolean overwriteThrow    boolean overwrite = true    boolean expandSystemProps = true    Behavior unsatisfiedRefBehavior = Behavior.THROW    private Project gp            Pattern.compile(/(.+)\(([^)]+)\)/)    private static final Pattern castLastPattern =            Pattern.compile(/\(([^)]+)\)(.+)/)    private static final Pattern castFirstPattern =            Pattern.compile(/\$\{[^}]+\}/)    private static final Pattern curlyRefPattern =            Pattern.compile(/\$\{([^}]+)\}/)    private static final Pattern curlyRefGrpPattern =class JavaPropFile {import org.gradle.api.GradleExceptionimport org.gradle.api.Projectimport java.lang.reflect.Constructorimport java.lang.reflect.Methodimport java.util.regex.Matcherimport java.util.regex.Patternpackage com.admc.gradlead???????}    }        }                gp.setProperty(propName, newVal)adG?a??M7???_<?
?
?
?
t
j
d
c
<

???_ ???w76?
?
?
h
8
2
1
?	?	g		????d?$??sO(????~.???~a:????I)???W7?????eB#????        String propName = nul        String propName = null        String cName = null        Matcher matcher = null        boolean setSysProp = false            String rawName, String valString, Pattern systemPropPattern) {    private void assign(    }        }            throw new GradleException("Failed to construct a $c.name with param '$str': $e")        } catch (Exception e) {            return cons.newInstance(str)        try {        }            throw new GradleException("TypeCasting class $cName has neither a static static .valueOf(String) method nor a (String) constructor")        } catch (Exception e) {            cons = c.getDeclaredConstructor(String.class)        try {        Constructor cons = null        }            throw new GradleException("Failed to generate a $c.name with param '$str': $e")        } catch (Exception e) {            return m.invoke(null, str)        if (m != null) try {        }            // Intentionally empty        } catch (Exception e) {            m = c.getDeclaredMethod("valueOf", String.class)        try {        Method m = null            throw new GradleException("Inaccessible typeCasting class: $cName")        if (c == null)        }            // intentionally empty        } catch (Exception e) {            c = Class.forName(cName)        else try {            }                // intentionally empty            } catch (Exception e) {                break                c = Class.forName(pkg + '.' + cName)            for (pkg in JavaPropFile.defaultGroovyPackages) try {        if (cName.indexOf('.') < 0)        Class c = null;        if (cName == '') return null        assert cName != null        assert str != null    private static Object instantiateFromString(String str, String cName) {        // are only 2 other things in the package.        // includes BigDecimal and BigInteger from that package, but there        // java.math is a slight over-simplification because Groovy only            ['java.lang', 'java.io', 'java.math', 'java.net', 'java.util']    private static final List defaultGroovyPackages =    }        overwriteThrow = originalOverwriteThrow        overwrite = originalOverwrite        unsatisfiedRefBehavior = originalBehavior        if (localPropertiesFile.exists()) load(localPropertiesFile)        unsatisfiedRefBehavior = Behavior.NO_SET        if (appPropertiesFile.exists()) load(appPropertiesFile)        overwriteThrow = false        overwrite = true        unsatisfiedRefBehavior = Behavior.THROW        // Unlike Ant, the LAST loaded properties will override.        File localPropertiesFile = gp.file('local.properties')        File appPropertiesFile = gp.file('app.properties')        boolean originalOverwriteThrow = overwriteThrow        boolean originalOverwrite = overwrite        Behavior originalBehavior = unsatisfiedRefBehavior    void traditionalPropertiesInit() {    }        }            }                assert false: "Unexpected Behavior value:  $unsatisfiedRefBehavior"              default:             */                break                gp.properties.remove(pk)              case Behavior.UNSET:              /* See not above about Behavior.UNSET.                break                        pv.replaceAll(curlyRefPattern, ''), systemPropPattern)                assign(pk,              case Behavior.EMPTY:                break                assign(pk, pv, systemPropPattern)              case Behavior.LITERAL:            switch (unsatisfiedRefBehavior) {        new HashMap(props).each() { pk, pv ->adbQ??siO'??o-?
?
?
[
,
???C???`?
?
?
[
+

?	?	r	A	$	???????i4??h"???h%???d??a/??x@???I4?????sb            else                System.setProperty(propName, newVal)            if (setSysProp)            // New property        } else {            }                    gp.setProperty(propName, newVal)                else                    System.setProperty(propName, newVal)                if (setSysProp)                            + newVal.class.name)                            + oldVal.class.name + ' to '                            + "'$propName'.  From "                            + "for change of property "                    throw new GradleException("Incompatible type "                        && !oldVal.class.equals(newVal.class))                if (oldVal != null && newVal != null                // Property value really changing                            + "'$oldVal' to '$newVal'")                            + "value of property '$propName' from "                            + "changes, but attempted to change "                            "Configured to prohibit property value "                    throw new GradleException(                if (overwriteThrow)                    || !oldVal.equals(newVal)))) {                    && ((oldVal == null || newVal == null)            if ((overwrite || overwriteThrow) && (oldVal != newVal            // or if oldVar == newVar.            // (!overwrite && !overwriteThrow)            // We will do absolutely nothing if either                    : gp.property(propName))            Object oldVal = (setSysProp ? System.properties[propName]                || (!setSysProp && gp.hasProperty(propName))) {        if ((setSysProp && System.properties.containsKey(propName))                : JavaPropFile.instantiateFromString(valString, cName))        Object newVal = ((cName == null) ? valString        assert propName != null        }            propName = rawName        } else {            }                }                    }                        propName = rawName                    } else {                        cName = matcher.group(2)                        propName = matcher.group(1)                    if (matcher.matches()) {                    matcher = castLastPattern.matcher(rawName)                } else {                    propName = matcher.group(2)                    cName = matcher.group(1)                if (matcher.matches()) {                matcher = castFirstPattern.matcher(rawName)            } else {                cName = ''                            + "typeCast for property '$propName'")                            "Non-empty value supplied to a null "                    throw new GradleException(                if (valString.length() > 0)                propName = rawName.substring(0, rawName.length() - 2)            } else if (rawName.length() > 2 && rawName.endsWith("()")) {                cName = ''                            + "typeCast for property '$propName'")                            "Non-empty value supplied to a null "                    throw new GradleException(                if (valString.length() > 0)                propName = rawName.substring(2)            if (rawName.length() > 2 && rawName.startsWith("()")) {                        + "end with ): $rawName")                        "TypeCast name may not begin with ( and "                throw new GradleException(                    && rawName.charAt(rawName.length()-1) == ')')            if (rawName.charAt(0) == '('        } else if (typeCasting) {            propName = matcher.group(1)        if (setSysProp) {        }            setSysProp = matcher.matches()            matcher = systemPropPattern.matcher(rawName)        if (systemPropPattern != null) {




© 2015 - 2024 Weber Informatics LLC | Privacy Policy