/** * Assigns an Ant property to another. * * @param to the destination property whose content is modified. * @param from the source property whose content is copied. */ private static void copyProperty(Property to, Property from) { to.setName(from.getName()); if (from.getValue() != null) { to.setValue(from.getValue()); } if (from.getFile() != null) { to.setFile(from.getFile()); } if (from.getResource() != null) { to.setResource(from.getResource()); } if (from.getPrefix() != null) { to.setPrefix(from.getPrefix()); } if (from.getRefid() != null) { to.setRefid(from.getRefid()); } if (from.getEnvironment() != null) { to.setEnvironment(from.getEnvironment()); } if (from.getClasspath() != null) { to.setClasspath(from.getClasspath()); } }
/** * Property to pass to the new project. * The property is passed as a 'user property'. * @return the created <code>Property</code> object. */ public Property createProperty() { Property p = new Property(true, getProject()); p.setProject(getNewProject()); p.setTaskName("property"); properties.add(p); return p; }
/** * Sets the property to the absolute filename of the * given file. If the value of this attribute is an absolute path, it * is left unchanged (with / and \ characters converted to the * current platforms conventions). Otherwise it is taken as a path * relative to the project's basedir and expanded. * @param location path to set * * @ant.attribute group="name" */ public void setLocation(File location) { if (relative) { internalSetValue(location); } else { setValue(location.getAbsolutePath()); } }
protected void setProperty(final String name, Object value) { assert name != null; assert value != null; String valueAsString = String.valueOf(value); if (log.isDebugEnabled()) { log.debug("Setting property: " + name + "=" + valueAsString); } Property prop = (Property)createTask("property"); prop.setName(name); prop.setValue(valueAsString); prop.execute(); }
if(propertyFile.exists()) { Project project = new Project(); Property property = new Property(); property.setProject(project); property.setFile(propertyFile); property.execute(); return project.getProperty(propertyKey); Property property = new Property(); property.setProject(project); URL propertyFileUrl = new URL(propertyFilePath); property.setUrl(propertyFileUrl); property.execute(); return project.getProperty(propertyKey);
ct.setInheritRefs(true); Property param = ct.createParam(); param.setName("dependency.name"); param.setValue(depMrid.getName()); param = ct.createParam(); param.setName("dependency.published.status"); param.setValue(status); param = ct.createParam(); param.setName("dependency.published.version"); param.setValue(version); param = ct.createParam(); param.setName("dependency.version"); param.setValue(depMrid.getRevision()); param = ct.createParam(); param.setName("dependency.status"); param.setValue(depStatus == null ? "null" : depStatus);
Property propTask = new Property(); propTask.setProject(project); propTask.setEnvironment(getEnvironmentPrefix()); propTask.init(); propTask.execute();
/** * Create and initialize a GraphProducer according to the * task parameters. * * @return an initialized GraphProducer. */ private GraphProducer initAntProject() { Project antProject; if (buildFile == null) { // Working with current project log("Using current project"); antProject = getProject(); } else { // Open a new project. log("Loading project " + buildFile); antProject = loadNewProject(); } for (PropertySet ps : propertySets) { addAlmostAll(antProject, ps.getProperties()); } if (properties.size() > 0) { for (Property prop : properties) { prop.setProject(antProject); prop.setTaskName("property"); prop.execute(); } } return new AntProject(antProject); }
props.load(tis); Property propertyTask = new Property(); propertyTask.bindToOwner(this); propertyTask.setPrefix(prefix); propertyTask.setPrefixValues(prefixValues); propertyTask.addProperties(props);
/** * Execute the task. It sets the value by evaluating variable name. * @throws BuildException if value is not set * @see org.apache.tools.ant.Task#execute() */ public void execute() throws BuildException { if (internalValue == null) { throw new BuildException("The property '" + getName() + "' was not set."); } String valueEvaluated = getProject().getProperty(internalValue); // set default value if (valueEvaluated == null && defaultValue != null) { valueEvaluated = defaultValue; } // No value ? error if (valueEvaluated == null) { throw new BuildException("The property '" + internalValue + "' cannot be evaluated in the current project."); } // Set the value with the value evaluated super.setValue(valueEvaluated); // Now execute the super method super.execute(); }
prop.setProject(project); prop.init(); prop.execute();
/** * Override the properties in the new project with the one * explicitly defined as nested elements here. * @throws BuildException under unknown circumstances. */ private void overrideProperties() throws BuildException { // remove duplicate properties - last property wins // Needed for backward compatibility Set<String> set = new HashSet<>(); for (int i = properties.size() - 1; i >= 0; --i) { Property p = properties.get(i); if (p.getName() != null && !p.getName().isEmpty()) { if (set.contains(p.getName())) { properties.remove(i); } else { set.add(p.getName()); } } } properties.stream().peek(p -> p.setProject(newProject)) .forEach(Property::execute); if (useNativeBasedir) { addAlmostAll(getProject().getInheritedProperties(), PropertyType.INHERITED); } else { getProject().copyInheritedProperties(newProject); } }
/** * Set a (multiline) property as nested text. * @param msg the text to append to the output text * @since Ant 1.8.0 */ public void addText(String msg) { if (!valueAttributeUsed) { msg = getProject().replaceProperties(msg); String currentValue = getValue(); if (currentValue != null) { msg = currentValue + msg; } internalSetValue(msg); } else if (!msg.trim().isEmpty()) { throw new BuildException("can't combine nested text with value attribute"); } }
/** * Set the value of the property as a String. * @param value value to assign * * @ant.attribute group="name" */ public void setValue(String value) { setValue((Object) value); }
@Override public void execute() throws BuildException { super.execute(); }
private void loadDeliveryList() { Property property = (Property) getProject().createTask("property"); property.setOwningTarget(getOwningTarget()); property.init(); property.setFile(deliveryList); property.perform(); }
p.setProject(null);
protected void setProperty(final String name, Object value) { assert name != null; assert value != null; String valueAsString = String.valueOf(value); if (log.isDebugEnabled()) { log.debug("Setting property: " + name + "=" + valueAsString); } Property prop = (Property)createTask("property"); prop.setName(name); prop.setValue(valueAsString); prop.execute(); }