Search in sources :

Example 1 with ResolvePropertyMap

use of org.apache.tools.ant.property.ResolvePropertyMap in project ant by apache.

the class Property method resolveAllProperties.

/**
 * resolve properties inside a properties hashtable
 * @param props properties object to resolve
 */
private void resolveAllProperties(Map<String, Object> props) throws BuildException {
    PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(getProject());
    new ResolvePropertyMap(getProject(), propertyHelper, propertyHelper.getExpanders()).resolveAllProperties(props, getPrefix(), getPrefixValues());
}
Also used : ResolvePropertyMap(org.apache.tools.ant.property.ResolvePropertyMap) PropertyHelper(org.apache.tools.ant.PropertyHelper)

Example 2 with ResolvePropertyMap

use of org.apache.tools.ant.property.ResolvePropertyMap in project ant by apache.

the class Main method setProperties.

private void setProperties(final Project project) {
    project.init();
    // resolve properties
    final PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project);
    @SuppressWarnings({ "rawtypes", "unchecked" }) final Map raw = new HashMap(definedProps);
    @SuppressWarnings("unchecked") final Map<String, Object> props = raw;
    final ResolvePropertyMap resolver = new ResolvePropertyMap(project, NOPROPERTIES, propertyHelper.getExpanders());
    resolver.resolveAllProperties(props, null, false);
    // set user-define properties
    for (final Entry<String, Object> ent : props.entrySet()) {
        final String arg = ent.getKey();
        final Object value = ent.getValue();
        project.setUserProperty(arg, String.valueOf(value));
    }
    project.setUserProperty(MagicNames.ANT_FILE, buildFile.getAbsolutePath());
    project.setUserProperty(MagicNames.ANT_FILE_TYPE, MagicNames.ANT_FILE_TYPE_FILE);
    // this list doesn't contain the build files default target,
    // which may be added later unless targets have been specified
    // on the command line. Therefore the property gets set again
    // in Project#executeTargets when we can be sure the list is
    // complete.
    // Setting it here allows top-level tasks to access the
    // property.
    project.setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS, CollectionUtils.flattenToString(targets));
}
Also used : ResolvePropertyMap(org.apache.tools.ant.property.ResolvePropertyMap) HashMap(java.util.HashMap) ResolvePropertyMap(org.apache.tools.ant.property.ResolvePropertyMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ResolvePropertyMap (org.apache.tools.ant.property.ResolvePropertyMap)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PropertyHelper (org.apache.tools.ant.PropertyHelper)1