本文整理汇总了Java中org.apache.tools.ant.taskdefs.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于org.apache.tools.ant.taskdefs包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readProperties
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
private Properties readProperties(Vector <? extends Property> antProperties) throws IOException {
Properties props = new Properties();
for(Property prop : antProperties) {
if(prop.getName()!=null) {
if(prop.getValue()!=null) {
props.setProperty(prop.getName(), prop.getValue());
} else if(prop.getLocation()!=null) {
props.setProperty(prop.getName(),
new File(prop.getLocation().getFileName()).getAbsolutePath());
}
} else if(prop.getFile()!=null || prop.getUrl()!=null) {
InputStream is = null;
try {
is = (prop.getFile()!=null) ?
new FileInputStream(prop.getFile()) :
prop.getUrl().openStream();
Properties loadedProps = new Properties();
loadedProps.load(is);
is.close();
if ( prop.getPrefix() != null ) {
for(Object p : loadedProps.keySet()) {
props.setProperty(prop.getPrefix() + p,
loadedProps.getProperty(p.toString()));
}
} else {
props.putAll(loadedProps);
}
} finally {
if (is != null) {
is.close();
}
}
}
}
return props;
}
示例2: execute
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/** Execute this task. */
public void execute () throws BuildException {
if ( values.isEmpty() ) {
throw new BuildException("You must set at least one value!", getLocation());
}
if ( target == null ) {
throw new BuildException("Target must be set!", getLocation());
}
for (String val : values) {
log ("Process '" + val + "' location with '" + target + "' target ...", Project.MSG_VERBOSE);
CallTarget antCall = (CallTarget) getProject().createTask("antcall");
antCall.init();
antCall.setLocation(getLocation());
// ant.setDir (dir);
antCall.setTarget (target);
Property prop = antCall.createParam();
prop.setName(name);
prop.setValue(val);
antCall.execute();
}
}
示例3: doScanSuite
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
private static void doScanSuite(Map<String,Entry> entries, File suite, Map<String,Object> properties, Project project) throws IOException {
Project fakeproj = new Project();
fakeproj.setBaseDir(suite); // in case ${basedir} is used somewhere
Property faketask = new Property();
faketask.setProject(fakeproj);
faketask.setFile(new File(suite, "nbproject/private/private.properties".replace('/', File.separatorChar)));
faketask.execute();
faketask.setFile(new File(suite, "nbproject/project.properties".replace('/', File.separatorChar)));
faketask.execute();
String modulesS = fakeproj.getProperty("modules");
if (modulesS == null) {
throw new IOException("No definition of modules in " + suite);
}
String[] modules = Path.translatePath(fakeproj, modulesS);
for (int i = 0; i < modules.length; i++) {
File module = new File(modules[i]);
if (!module.isDirectory()) {
throw new IOException("No such module " + module + " referred to from " + suite);
}
if (!scanPossibleProject(module, entries, properties, null, ModuleType.SUITE, project, null)) {
throw new IOException("No valid module found in " + module + " referred to from " + suite);
}
}
}
示例4: updateProject
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Updates the Ant Project used in this container with variables set in Ivy.
*
* All variables defined in Ivy will be set in the Ant project under two names:
* <ul>
* <li>the name of the variable</li>
* <li>the name of the variable suffixed with a dot + the given id, if the given id is not null
* </li>
* </ul>
*
* @param id
* The identifier of the settings in which the variables have been set, which should
* be used as property names suffix
*/
public void updateProject(String id) {
Map<String, String> r = new HashMap<>(super.getVariables());
r.putAll(overwrittenProperties);
for (Map.Entry<String, String> entry : r.entrySet()) {
setPropertyIfNotSet(entry.getKey(), entry.getValue());
if (id != null) {
setPropertyIfNotSet(entry.getKey() + "." + id, entry.getValue());
}
}
if (getEnvironmentPrefix() != null) {
Property propTask = new Property();
propTask.setProject(project);
propTask.setEnvironment(getEnvironmentPrefix());
propTask.init();
propTask.execute();
}
}
示例5: handlePropertyParameter
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
private void handlePropertyParameter() {
if (isRequired() && getProject().getProperty(property) == null) {
throw new BuildException("expected property '" + property + "': " + description);
}
if (!possibleValues.isEmpty()) {
String currentValue = getProject().getProperty(property);
if (!possibleValues.contains(currentValue)) {
throw new BuildException("current value of property '" + property
+ "' doesn't match with possible values : " + possibleValues.toString());
}
}
if (defaultValue != null && getProject().getProperty(property) == null) {
Property propTask = new Property();
propTask.setProject(getProject());
propTask.setTaskName(getTaskName());
propTask.setName(property);
propTask.setValue(defaultValue);
propTask.execute();
}
}
示例6: buildProject
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
private Project buildProject() {
Project project = new Project();
project.setNewProperty(EasyAntMagicNames.AUDIT_MODE, "true");
project.setNewProperty(EasyAntMagicNames.SKIP_CORE_REVISION_CHECKER, "true");
project.addReference(EasyAntMagicNames.EASYANT_IVY_INSTANCE, easyantIvySettings);
TaskCollectorFromImplicitTargetListener listener = new TaskCollectorFromImplicitTargetListener();
listener.addClassToCollect(ParameterTask.class);
listener.addClassToCollect(Property.class);
listener.addClassToCollect(Import.class);
listener.addClassToCollect(ImportDeferred.class);
listener.addClassToCollect(Path.class);
listener.addClassToCollect(PathTask.class);
listener.addClassToCollect(FileSet.class);
project.addBuildListener(listener);
// add a property helper to ignore basedir property on reports
PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project);
propertyHelper.add(new BypassDefaultPropertyExpander());
project.init();
ProjectUtils.configureProjectHelper(project);
return project;
}
示例7: reinit
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Called in execute or createProperty if newProject is null. <p>
*
* This can happen if the same instance of this task is run twice as
* newProject is set to null at the end of execute (to save memory and help
* the GC).</p> <p>
*
* Sets all properties that have been defined as nested property elements.
* </p>
*/
private void reinit() {
init();
final int count = properties.size();
for ( int i = 0; i < count; i++ ) {
Property p = (Property)properties.elementAt( i );
Property newP = (Property)newProject.createTask( "property" );
newP.setName( p.getName() );
if ( p.getValue() != null ) {
newP.setValue( p.getValue() );
}
if ( p.getFile() != null ) {
newP.setFile( p.getFile() );
}
if ( p.getResource() != null ) {
newP.setResource( p.getResource() );
}
if ( p.getPrefix() != null ) {
newP.setPrefix( p.getPrefix() );
}
if ( p.getRefid() != null ) {
newP.setRefid( p.getRefid() );
}
if ( p.getEnvironment() != null ) {
newP.setEnvironment( p.getEnvironment() );
}
if ( p.getClasspath() != null ) {
newP.setClasspath( p.getClasspath() );
}
properties.setElementAt( newP, i );
}
}
示例8: overrideProperties
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Override the properties in the new project with the one explicitly defined
* as nested elements here.
*
* @exception BuildException Description of the Exception
*/
private void overrideProperties() throws BuildException {
Enumeration e = properties.elements();
while ( e.hasMoreElements() ) {
Property p = (Property)e.nextElement();
p.setProject( newProject );
p.execute();
}
getProject().copyInheritedProperties( newProject );
}
示例9: createProperty
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Property to pass to the new project. The property is passed as a 'user
* property'
*
* @return Description of the Return Value
*/
public Property createProperty() {
if ( newProject == null ) {
reinit();
}
/*
* Property p = new Property( true, getProject() );
*/
Property p = new Property();
p.setProject( newProject );
p.setTaskName( "property" );
properties.addElement( p );
return p;
}
示例10: setIfNotSetAlready
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Set a System.property with this value if it is not already set.
*
* @return
*/
public static boolean setIfNotSetAlready(Property property)
{
if (System.getProperty(property.getName()) == null)
{
System.setProperty(property.getName(), (property.getValue() == null ? "" : property
.getValue()));
TaskLog.log("Setting property '" + property.getName() + "' to value '"
+ property.getValue() + "'");
return true;
}
return false;
}
示例11: setSystemProperties
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Sets the system properties.
*/
private void setSystemProperties()
{
if (systemProperties != null)
{
Iterator propertiesIterator = systemProperties.getSystemProperties().iterator();
while (propertiesIterator.hasNext())
{
Property property = ((Property) propertiesIterator.next());
SystemProperties.setIfNotSetAlready(property);
}
}
}
示例12: setPropertyValue
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
protected final void setPropertyValue(String value) {
if (value != null) {
if (override) {
if (getProject().getUserProperty(property) == null)
getProject().setProperty(property, value);
else
getProject().setUserProperty(property, value);
} else {
Property p = (Property) project.createTask("property");
p.setName(property);
p.setValue(value);
p.execute();
}
}
}
示例13: reinit
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Called in execute or createProperty if newProject is null.
* <p>
*
* This can happen if the same instance of this task is run twice as
* newProject is set to null at the end of execute (to save memory and help
* the GC).
* </p>
* <p>
*
* Sets all properties that have been defined as nested property elements.
* </p>
*/
private void reinit() {
init();
final int count = properties.size();
for (int i = 0; i < count; i++) {
Property p = (Property) properties.elementAt(i);
Property newP = (Property) newProject.createTask("property");
newP.setName(p.getName());
if (p.getValue() != null) {
newP.setValue(p.getValue());
}
if (p.getFile() != null) {
newP.setFile(p.getFile());
}
if (p.getResource() != null) {
newP.setResource(p.getResource());
}
if (p.getPrefix() != null) {
newP.setPrefix(p.getPrefix());
}
if (p.getRefid() != null) {
newP.setRefid(p.getRefid());
}
if (p.getEnvironment() != null) {
newP.setEnvironment(p.getEnvironment());
}
if (p.getClasspath() != null) {
newP.setClasspath(p.getClasspath());
}
properties.setElementAt(newP, i);
}
}
示例14: overrideProperties
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Override the properties in the new project with the one explicitly
* defined as nested elements here.
*
* @exception BuildException
* Description of the Exception
*/
private void overrideProperties() throws BuildException {
Enumeration e = properties.elements();
while (e.hasMoreElements()) {
Property p = (Property) e.nextElement();
p.setProject(newProject);
p.execute();
}
getProject().copyInheritedProperties(newProject);
}
示例15: createProperty
import org.apache.tools.ant.taskdefs.Property; //导入依赖的package包/类
/**
* Property to pass to the new project. The property is passed as a 'user
* property'
*
* @return Description of the Return Value
*/
public Property createProperty() {
if (newProject == null) {
reinit();
}
/*
* Property p = new Property( true, getProject() );
*/
Property p = new Property();
p.setProject(newProject);
p.setTaskName("property");
properties.addElement(p);
return p;
}