/** * Replaces <code>${xxx}</code> style constructions in the given value with * the string value of the corresponding properties. * * @param project The project containing the properties to replace. * Must not be <code>null</code>. * * @param value The string to be scanned for property references. * May be <code>null</code>. * * @exception BuildException if the string contains an opening * <code>${</code> without a closing * <code>}</code> * @return the original string with the properties replaced, or * <code>null</code> if the original string is <code>null</code>. * * @deprecated since 1.6.x. * Use project.replaceProperties(). * @since 1.5 */ @Deprecated public static String replaceProperties(Project project, String value) throws BuildException { // needed since project properties are not accessible return project.replaceProperties(value); }
/** * Read in lines and execute them. * * @param reader the reader from which to get the groovy source to exec * @param out the outputstream to use * @throws java.io.IOException if something goes wrong */ protected void runStatements(Reader reader, PrintStream out) throws IOException { log.debug("runStatements()"); StringBuilder txt = new StringBuilder(); String line = ""; BufferedReader in = new BufferedReader(reader); while ((line = in.readLine()) != null) { line = getProject().replaceProperties(line); if (line.contains("--")) { txt.append("\n"); } } // Catch any statements not followed by ; if (!txt.toString().equals("")) { execGroovy(txt.toString(), out); } }
/** * Set a multiline message. * @param msg The message to be displayed. */ public void addText(final String msg) { if (messageAttribute && msg.trim().isEmpty()) { return; } message += getProject().replaceProperties(msg); }
/** * Set the error text; all properties are expanded in the message. * * @param message the text to use in a failure message */ public void addText(String message) { text = getProject().replaceProperties(message); }
/** * @return the text */ public String getText() { String s = buf.toString(); return expandProperties ? getProject().replaceProperties(s) : s; } }
/** * Convenience method to expand properties. * @param content the string to expand * @return the converted string */ protected String expand(final String content) { return getProject().replaceProperties(content); }
/** * set the text using inline * @param value the text to place inline */ public void addText(String value) { this.value += getProject().replaceProperties(value); }
/** * Set a multiline message. * @param msg the message to display */ public void addText(String msg) { if (message == null) { message = ""; } message += getProject().replaceProperties(msg); }
/** * Set a multiline message. * @param msg the CDATA text to append to the output text */ public void addText(String msg) { message += getProject().replaceProperties(msg); }
/** * Set the script text. * * @param text a component of the script text to be added. * @since ant1.7 */ public void addText(String text) { this.text = getProject().replaceProperties(text); }
/** * Add text to a node. * @param n node * @param s value */ private void addText(Node n, String s) { s = getProject().replaceProperties(s); //only text nodes that are non null after property expansion are added if (s != null && !s.trim().isEmpty()) { Text t = doc.createTextNode(s.trim()); n.appendChild(t); } }
/** * Get all the attributes in the ant-attribute:param * namespace and place them in a map. * @param el the element this attribute is in. * @return a map of attributes. */ protected Map<String, String> getParams(UnknownElement el) { // this makes a copy! return el.getWrapper().getAttributeMap().entrySet().stream() .filter(e -> e.getKey().startsWith("ant-attribute:param")) .collect(Collectors.toMap(e -> e.getKey().substring(e.getKey().lastIndexOf(':') + 1), e -> el.getProject().replaceProperties((String) e.getValue()), (a, b) -> b)); } }
/** * Construct a StringResource with the supplied project and value, * doing property replacement against the project if non-null. * @param project the owning Project. * @param value the value of this StringResource. */ public StringResource(Project project, String value) { setProject(project); setValue(project == null ? value : project.replaceProperties(value)); }
private static void concatDescriptions(Project project, Target t, StringBuilder description) { if (t == null) { return; } for (Task task : findElementInTarget(t, "description")) { if (task instanceof UnknownElement) { UnknownElement ue = (UnknownElement) task; String descComp = ue.getWrapper().getText().toString(); if (descComp != null) { description.append(project.replaceProperties(descComp)); } } } }
String line; while ((line = in.readLine()) != null) { out.write(getProject().replaceProperties(line)); out.newLine(); out.write(getProject().replaceProperties(buffer.substring(0))); out.newLine();
/** * 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"); } }
/** * Return the value for the given attribute. * If we are not using semantic attributes, its just the * literal string value of the attribute. * * <p>If we <em>are</em> using semantic attributes, then first * dependent properties are resolved (i.e., ${foo} is resolved * based on the foo property value), and then an appropriate data * type is used. In particular, location-based properties are * resolved to absolute file names. Also for refid values, look * up the referenced object from the project.</p> */ private String getAttributeValue(Node attributeNode) { String nodeValue = attributeNode.getNodeValue().trim(); if (semanticAttributes) { String attributeName = attributeNode.getNodeName(); nodeValue = getProject().replaceProperties(nodeValue); if (LOCATION.equals(attributeName)) { File f = resolveFile(nodeValue); return f.getPath(); } if (REF_ID.equals(attributeName)) { Object ref = getProject().getReference(nodeValue); if (ref != null) { return ref.toString(); } } } return nodeValue; }
private void setValueFromOutputStream(String output) { String value; if (getProject() != null) { value = getProject().replaceProperties(output); } else { value = output; } setValue(value); }
/** * Add nested text to this resource. * Properties will be expanded during this process. * @since Ant 1.7.1 * @param text text to use as the string resource */ public void addText(String text) { checkChildrenAllowed(); setValue(getProject().replaceProperties(text)); }
continue; value = owner.getProject().replaceProperties(value); // FixMe: need to make config if (!enable.isEnabled(owner, value)) { return false;