org.apache.tools.ant.Project.getUserProperty()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.apache.tools.ant.Project.getUserProperty()方法的一些代码示例,展示了Project.getUserProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getUserProperty()方法的具体详情如下:
包路径:org.apache.tools.ant.Project
类名称:Project
方法名:getUserProperty

Project.getUserProperty介绍

[英]Return the value of a user property, if it is set.
[中]返回用户属性的值(如果已设置)。

代码示例

代码示例来源:origin: org.apache.ant/ant

/**
 * Copies all user properties that have not been set on the
 * command line or a GUI tool from this instance to the Project
 * instance given as the argument.
 *
 * <p>To copy all "user" properties, you will also have to call
 * {@link #copyUserProperties copyUserProperties}.</p>
 *
 * <p>Does not copy properties held by implementations of
 * delegates (like local properties).</p>
 *
 * @param other the project to copy the properties to.  Must not be null.
 *
 * @since Ant 1.6
 */
public void copyInheritedProperties(Project other) {
  //avoid concurrent modification:
  synchronized (inheritedProperties) {
    for (Map.Entry<String, Object> entry : inheritedProperties.entrySet()) {
      String arg = entry.getKey();
      if (other.getUserProperty(arg) == null) {
        other.setInheritedProperty(arg, entry.getValue().toString());
      }
    }
  }
}

代码示例来源:origin: org.testng/testng

private void delegateCommandSystemProperties() {
 // Iterate over command-line args and pass them through as sysproperty
 // exclude any built-in properties that start with "ant."
 for (Object propKey : getProject().getUserProperties().keySet()) {
  String propName = (String) propKey;
  String propVal = getProject().getUserProperty(propName);
  if (propName.startsWith("ant.")) {
   log("Excluding ant property: " + propName + ": " + propVal, Project.MSG_DEBUG);
  }    else {
   log("Including user property: " + propName + ": " + propVal, Project.MSG_DEBUG);
   Environment.Variable var = new Environment.Variable();
   var.setKey(propName);
   var.setValue(propVal);
   addSysproperty(var);
  }
 }
}

代码示例来源:origin: cbeust/testng

private void delegateCommandSystemProperties() {
 // Iterate over command-line args and pass them through as sysproperty
 // exclude any built-in properties that start with "ant."
 for (Object propKey : getProject().getUserProperties().keySet()) {
  String propName = (String) propKey;
  String propVal = getProject().getUserProperty(propName);
  if (propName.startsWith("ant.")) {
   log("Excluding ant property: " + propName + ": " + propVal, Project.MSG_DEBUG);
  } else {
   log("Including user property: " + propName + ": " + propVal, Project.MSG_DEBUG);
   Environment.Variable var = new Environment.Variable();
   var.setKey(propName);
   var.setValue(propVal);
   addSysproperty(var);
  }
 }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

private void setPropertiesFromFiles(Project project, List<Properties> allProperties) {
  for (Properties props : allProperties) {
    Enumeration<?> propertyNames = props.propertyNames();
    while (propertyNames.hasMoreElements()) {
      String name = (String) propertyNames.nextElement();
      // do not override extra local properties with the global settings
      if (project.getUserProperty(name) == null) {
        project.setUserProperty(name, props.getProperty(name));
      }
    }
  }
}

代码示例来源:origin: randomizedtesting/randomizedtesting

public void setSeed(String randomSeed) {
 if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_RANDOM_SEED()))) {
  String userProperty = getProject().getUserProperty(SYSPROP_RANDOM_SEED());
  if (!userProperty.equals(randomSeed)) {
   log("Ignoring seed attribute because it is overridden by user properties.", Project.MSG_WARN);
  }
 } else if (!Strings.isNullOrEmpty(randomSeed)) {
  this.random = randomSeed;
 }
}

代码示例来源:origin: randomizedtesting/randomizedtesting

/**
 * Initial random seed used for shuffling test suites and other sources
 * of pseudo-randomness. If not set, any random value is set. 
 * 
 * <p>The seed's format is compatible with {@link RandomizedRunner} so that
 * seed can be fixed for suites and methods alike.
 */
public void setSeed(String randomSeed) {
 if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_RANDOM_SEED()))) {
  String userProperty = getProject().getUserProperty(SYSPROP_RANDOM_SEED());
  if (!userProperty.equals(randomSeed)) {
   log("Ignoring seed attribute because it is overridden by user properties.", Project.MSG_WARN);
  }
 } else if (!Strings.isNullOrEmpty(randomSeed)) {
  this.random = randomSeed;
 }
}

代码示例来源:origin: dita-ot/dita-ot

@VisibleForTesting
Job getJob() {
  String tempDir = getProject().getUserProperty(ANT_TEMP_DIR);
  if (tempDir == null) {
    tempDir = getProject().getProperty(ANT_TEMP_DIR);
  }
  if (tempDir == null) {
    throw new IllegalStateException();
  }
  final Job job = ExtensibleAntInvoker.getJob(new File(tempDir), getProject());
  if (job == null) {
    throw new IllegalStateException();
  }
  return job;
}

代码示例来源:origin: com.carrotsearch.randomizedtesting/junit4-ant

public void setSeed(String randomSeed) {
 if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_RANDOM_SEED()))) {
  String userProperty = getProject().getUserProperty(SYSPROP_RANDOM_SEED());
  if (!userProperty.equals(randomSeed)) {
   log("Ignoring seed attribute because it is overridden by user properties.", Project.MSG_WARN);
  }
 } else if (!Strings.isNullOrEmpty(randomSeed)) {
  this.random = randomSeed;
 }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

private void loadExtraPropertyFiles(Project project) {
  if (fPropertyFiles != null) {
    try {
      List<Properties> allProperties = AntCoreUtil.loadPropertyFiles(fPropertyFiles, project.getUserProperty("basedir"), getEditedFile().getAbsolutePath()); //$NON-NLS-1$
      setPropertiesFromFiles(project, allProperties);
    }
    catch (IOException e1) {
      AntUIPlugin.log(e1);
    }
  }
}

代码示例来源:origin: randomizedtesting/randomizedtesting

/**
 * Initializes custom prefix for all junit4 properties. This must be consistent
 * across all junit4 invocations if done from the same classpath. Use only when REALLY needed.
 */
public void setPrefix(String prefix) {
 if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_PREFIX()))) {
  log("Ignoring prefix attribute because it is overridden by user properties.", Project.MSG_WARN);
 } else {
  SysGlobals.initializeWith(prefix);
 }
}

代码示例来源:origin: com.carrotsearch.randomizedtesting/junit4-ant

/**
 * Initial random seed used for shuffling test suites and other sources
 * of pseudo-randomness. If not set, any random value is set. 
 * 
 * <p>The seed's format is compatible with {@link RandomizedRunner} so that
 * seed can be fixed for suites and methods alike.
 */
public void setSeed(String randomSeed) {
 if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_RANDOM_SEED()))) {
  String userProperty = getProject().getUserProperty(SYSPROP_RANDOM_SEED());
  if (!userProperty.equals(randomSeed)) {
   log("Ignoring seed attribute because it is overridden by user properties.", Project.MSG_WARN);
  }
 } else if (!Strings.isNullOrEmpty(randomSeed)) {
  this.random = randomSeed;
 }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

/**
 * Load all properties from the files
 */
private void loadPropertyFiles(Project project) {
  List<String> fileNames = Arrays.asList(AntCorePlugin.getPlugin().getPreferences().getCustomPropertyFiles());
  try {
    List<Properties> allProperties = AntCoreUtil.loadPropertyFiles(fileNames, project.getUserProperty("basedir"), getEditedFile().getAbsolutePath()); //$NON-NLS-1$
    setPropertiesFromFiles(project, allProperties);
  }
  catch (IOException e1) {
    AntUIPlugin.log(e1);
  }
}

代码示例来源:origin: com.carrotsearch.randomizedtesting/junit4-ant

/**
 * Initializes custom prefix for all junit4 properties. This must be consistent
 * across all junit4 invocations if done from the same classpath. Use only when REALLY needed.
 */
public void setPrefix(String prefix) {
 if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_PREFIX()))) {
  log("Ignoring prefix attribute because it is overridden by user properties.", Project.MSG_WARN);
 } else {
  SysGlobals.initializeWith(prefix);
 }
}

相关文章