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

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

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

Project.setNewProperty介绍

[英]Set a property if no value currently exists. If the property exists already, a message is logged and the method returns with no other effect.
[中]如果当前不存在值,请设置属性。如果该属性已经存在,则会记录一条消息,该方法返回时不会产生其他影响。

代码示例

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

/**
 * Utility method to set the appropriate property
 * to indicate that specified file satisfies library
 * requirements.
 *
 * @param file the library
 */
private void setLibraryProperty(final File file) {
  getProject().setNewProperty(propertyName, file.getAbsolutePath());
}

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

private void setProperty(String name, String value) {
    if (name != null) {
      getProject().setNewProperty(name, value);
    }
  }
}

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

/**
 * Helper method to set result property to the
 * passed in value if appropriate.
 *
 * @param result the exit code
 */
protected void maybeSetResultPropertyValue(int result) {
  String res = Integer.toString(result);
  if (resultProperty != null) {
    getProject().setNewProperty(resultProperty, res);
  }
}

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

/**
 * helper that encapsulates prefix logic and property setting
 * policy (i.e. we use setNewProperty instead of setProperty).
 */
private void setProperty(String name, String value) {
  getProject().setNewProperty(prefix + name, value);
}

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

/**
 * Close the PropertyOutputStream, storing the property.
 */
@Override
public void close() {
  if (project != null && property != null) {
    String s = new String(toByteArray());
    project.setNewProperty(property, trim ? s.trim() : s);
  }
}

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

/**
 * Helper method to set result property to the
 * passed in value if appropriate.
 *
 * @param result value desired for the result property value.
 */
protected void maybeSetResultPropertyValue(int result) {
  if (resultProperty != null) {
    String res = Integer.toString(result);
    getProject().setNewProperty(resultProperty, res);
  }
}

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

private void setProperty(String name, String value) {
  getProject().setNewProperty(prefix + name, value);
}

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

/**
 * Set a property from a ByteArrayOutputStream
 *
 * @param baos
 *            contains the property value.
 * @param propertyName
 *            the property name.
 */
private void setPropertyFromBAOS(final ByteArrayOutputStream baos,
                 final String propertyName) {
  final BufferedReader in = new BufferedReader(new StringReader(Execute.toString(baos)));
  managingTask.getProject().setNewProperty(propertyName,
      in.lines().collect(Collectors.joining(System.lineSeparator())));
}

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

/**
 * Calculate the checksum(s).
 * @throws BuildException on error
 */
@Override
public void execute() throws BuildException {
  isCondition = false;
  boolean value = validateAndExecute();
  if (verifyProperty != null) {
    getProject().setNewProperty(verifyProperty,
      Boolean.toString(value));
  }
}

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

/**
   * Execute this task.
   * @throws BuildException on error
   */
  @Override
  public void execute() throws BuildException {
    if (property == null) {
      throw new BuildException("property attribute required", getLocation());
    }
    if (file == null) {
      throw new BuildException("file attribute required", getLocation());
    }
    getProject().setNewProperty(property, file.getParent());
  }
}

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

/**
 * Run task.
 *
 * @exception BuildException if an error occurs
 */
@Override
public void execute() throws BuildException {
  File savedFile = myFile; // may be altered in validate
  validate();
  final Properties properties = loadProperties();
  final int buildNumber = getBuildNumber(properties);
  properties.put(DEFAULT_PROPERTY_NAME,
    String.valueOf(buildNumber + 1));
  // Write the properties file back out
  try (OutputStream output = Files.newOutputStream(myFile.toPath())) {
    properties.store(output, "Build Number for ANT. Do not edit!");
  } catch (final IOException ioe) {
    throw new BuildException("Error while writing " + myFile, ioe);
  } finally {
    myFile = savedFile;
  }
  //Finally set the property
  getProject().setNewProperty(DEFAULT_PROPERTY_NAME,
    String.valueOf(buildNumber));
}

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

/**
 * do the work
 * @throws BuildException if required attributes are not supplied
 * property and attribute are required attributes
 */
@Override
public void execute() throws BuildException {
  if (property == null) {
    throw new BuildException("property attribute required", getLocation());
  }
  if (file == null) {
    throw new BuildException("file attribute required", getLocation());
  }
  getProject().setNewProperty(property,
    removeExtension(file.getName(), suffix));
}

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

/**
 * Execute as a Task.
 */
@Override
public void execute() {
  if (rc == null) {
    throw new BuildException(ONE_NESTED_MESSAGE);
  }
  if (property == null) {
    log("resource count = " + rc.size());
  } else {
    getProject().setNewProperty(property, Integer.toString(rc.size()));
  }
}

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

/**
   * Creates the temporary file.
   *
   * @exception  BuildException  if something goes wrong with the build
   */
  @Override
  public void execute() throws BuildException {
    if (property == null || property.isEmpty()) {
      throw new BuildException("no property specified");
    }
    if (destDir == null) {
      destDir = getProject().resolveFile(".");
    }
    File tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir,
          deleteOnExit, createFile);
    getProject().setNewProperty(property, tfile.toString());
  }
}

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

/**
 * Actions to be taken on an unsuccessful wait.
 * This is an override point. It is where the timeout processing takes place.
 * The base implementation sets the timeoutproperty if there was a timeout
 * and the property was defined.
 * @since Ant1.7
 */
protected void processTimeout() {
  log(getTaskName() + ": timeout", Project.MSG_VERBOSE);
  if (timeoutProperty != null) {
    getProject().setNewProperty(timeoutProperty, "true");
  }
}

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

/**
 * Execute the task.
 *
 * @throws BuildException if something goes wrong.
 */
@Override
public void execute() throws BuildException {
  validate();
  final Project prj = getProject();
  final Stream<Extension> extensions;
  // Check if list of files to check has been specified
  if (!extensionFileSets.isEmpty()) {
    extensions = extensionFileSets.stream()
      .map(xset -> xset.toExtensions(prj)).flatMap(Stream::of);
  } else {
    extensions = Stream.of(
      Extension.getAvailable(ExtensionUtil.getManifest(libraryFile)));
  }
  final Extension test = requiredExtension.toExtension();
  if (extensions.anyMatch(x -> x.isCompatibleWith(test))) {
    prj.setNewProperty(propertyName, "true");
  }
}

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

/**
 * Run as a task.
 * @throws BuildException if an error occurs.
 */
@Override
public void execute() throws BuildException {
  if (propertyname == null) {
    throw new BuildException("'property' must be set.");
  }
  if (atLeast != null || exactly != null) {
    // If condition values are set, evaluate the condition
    if (eval()) {
      getProject().setNewProperty(propertyname, getVersion().toString());
    }
  } else {
    // Raw task
    getProject().setNewProperty(propertyname, getVersion().toString());
  }
}

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

getProject().setNewProperty(m_failurePropertyName, "true");
getProject().setNewProperty(m_failurePropertyName, "true");
getProject().setNewProperty(m_skippedPropertyName, "true");
getProject().setNewProperty(m_fspPropertyName, "true");

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

/**
 * Sets property to true if target file(s) have a more recent timestamp
 * than (each of) the corresponding source file(s).
 * @throws BuildException on error
 */
@Override
public void execute() throws BuildException {
  if (property == null) {
    throw new BuildException("property attribute is required.",
                 getLocation());
  }
  boolean upToDate = eval();
  if (upToDate) {
    getProject().setNewProperty(property, getValue());
    if (mapperElement == null) {
      log("File \"" + targetFile.getAbsolutePath()
        + "\" is up-to-date.", Project.MSG_VERBOSE);
    } else {
      log("All target files are up-to-date.",
        Project.MSG_VERBOSE);
    }
  }
}

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

/**
 * Executes the task.
 * @exception BuildException if an error occurs
 */
@Override
public void execute() throws BuildException {
  checkParameters();
  resetFileLists();
  // scan source directories and dest directory to build up
  // compile list
  if (hasPath(src)) {
    collectFileListFromSourcePath();
  } else {
    assert hasPath(moduleSourcepath) : "Either srcDir or moduleSourcepath must be given";
    collectFileListFromModulePath();
  }
  compile();
  if (updatedProperty != null
    && taskSuccess
    && compileList.length != 0) {
    getProject().setNewProperty(updatedProperty, "true");
  }
}

相关文章