use of org.apache.tools.ant.types.PropertySet in project ant by apache.
the class EchoProperties method setPrefix.
/**
* If the prefix is set, then only properties which start with this
* prefix string will be recorded. If regex is not set and if this
* is never set, or it is set to an empty string or <tt>null</tt>,
* then all properties will be recorded.
*
* <p>For example, if the attribute is set as:</p>
* <pre><echoproperties prefix="ant." /></pre>
* then the property "ant.home" will be recorded, but "ant-example"
* will not.
*
* @param prefix The new prefix value
*/
public void setPrefix(String prefix) {
if (prefix != null && prefix.length() != 0) {
this.prefix = prefix;
PropertySet ps = new PropertySet();
ps.setProject(getProject());
ps.appendPrefix(prefix);
addPropertyset(ps);
}
}
use of org.apache.tools.ant.types.PropertySet in project ant by apache.
the class EchoProperties method setRegex.
/**
* If the regex is set, then only properties whose names match it
* will be recorded. If prefix is not set and if this is never set,
* or it is set to an empty string or <tt>null</tt>, then all
* properties will be recorded.
*
* <p>For example, if the attribute is set as:</p>
* <pre><echoproperties prefix=".*ant.*" /></pre>
* then the properties "ant.home" and "user.variant" will be recorded,
* but "ant-example" will not.
*
* @param regex The new regex value
*
* @since Ant 1.7
*/
public void setRegex(String regex) {
if (regex != null && !regex.isEmpty()) {
this.regex = regex;
PropertySet ps = new PropertySet();
ps.setProject(getProject());
ps.appendRegex(regex);
addPropertyset(ps);
}
}
use of org.apache.tools.ant.types.PropertySet in project ant by apache.
the class Ant method initializeProject.
/**
* Attaches the build listeners of the current project to the new
* project, configures a possible logfile, transfers task and
* data-type definitions, transfers properties (either all or just
* the ones specified as user properties to the current project,
* depending on inheritall), transfers the input handler.
*/
private void initializeProject() {
newProject.setInputHandler(getProject().getInputHandler());
Iterator<BuildListener> iter = getBuildListeners();
while (iter.hasNext()) {
newProject.addBuildListener(iter.next());
}
if (output != null) {
File outfile;
if (dir != null) {
outfile = FILE_UTILS.resolveFile(dir, output);
} else {
outfile = getProject().resolveFile(output);
}
try {
out = new PrintStream(Files.newOutputStream(outfile.toPath()));
DefaultLogger logger = new DefaultLogger();
logger.setMessageOutputLevel(Project.MSG_INFO);
logger.setOutputPrintStream(out);
logger.setErrorPrintStream(out);
newProject.addBuildListener(logger);
} catch (IOException ex) {
log("Ant: Can't set output to " + output);
}
}
// set user-defined properties
if (useNativeBasedir) {
addAlmostAll(getProject().getUserProperties(), PropertyType.USER);
} else {
getProject().copyUserProperties(newProject);
}
if (!inheritAll) {
// set Ant's built-in properties separately,
// because they are not being inherited.
newProject.initProperties();
} else {
// set all properties from calling project
addAlmostAll(getProject().getProperties(), PropertyType.PLAIN);
}
for (PropertySet ps : propertySets) {
addAlmostAll(ps.getProperties(), PropertyType.PLAIN);
}
}
Aggregations