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

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

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

Project.getProperty介绍

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

代码示例

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

/**
 * Checks for the magic property that enables class loader reuse
 * for <taskdef> and <typedef> in Ant 1.5 and earlier.
 */
private static boolean isMagicPropertySet(Project p) {
  return p.getProperty(REUSE_LOADER_REF) != null;
}

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

/**
 * Returns the current temporary file. Replaced by a fresh (inexistent)
 * file before each test.
 */
public File currentTempFile() {
  String tmpname = buildRule.getProject().getProperty("tmpfile");
  return tmpname == null ? null : new File(tmpname);
}

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

/**
 * @return true if the property exists
 * @exception BuildException if the property attribute is not set
 */
@Override
public boolean eval() throws BuildException {
  if (property == null) {
    throw new BuildException(
      "No property specified for isset condition");
  }
  return getProject().getProperty(property) != null;
}

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

/**
 * Gets the target VM that the classes will be compiled for.
 * @return the target VM
 */
public String getTarget() {
  return targetAttribute != null
    ? targetAttribute
    : getProject().getProperty(MagicNames.BUILD_JAVAC_TARGET);
}

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

/**
 * Get the value of source.
 * @return value of source.
 */
public String getSource() {
  return source != null
    ? source : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Sets the current thread's context loader to this classloader, storing
 * the current loader value for later resetting.
 */
public void setThreadContextLoader() {
  if (isContextLoaderSaved) {
    throw new BuildException("Context loader has not been reset");
  }
  if (LoaderUtils.isContextLoaderAvailable()) {
    savedContextLoader = LoaderUtils.getContextClassLoader();
    ClassLoader loader = this;
    if (project != null && "only".equals(project.getProperty("build.sysclasspath"))) {
      loader = this.getClass().getClassLoader();
    }
    LoaderUtils.setContextClassLoader(loader);
    isContextLoaderSaved = true;
  }
}

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

private String getProperty(BuildEvent event, String propertyName, String defaultValue) {
  String rv = defaultValue;
  if (event != null && event.getProject() != null && event.getProject().getProperty(propertyName) != null) {
    rv = event.getProject().getProperty(propertyName);
  }
  return rv;
}

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

/**
 * Report the content of ANT_HOME/lib directory
 * @param out the stream to print the content to
 */
private static void doReportAntProperties(PrintStream out) {
  Project p = new Project();
  p.initProperties();
  out.println(MagicNames.ANT_VERSION + ": " + p.getProperty(MagicNames.ANT_VERSION));
  out.println(MagicNames.ANT_JAVA_VERSION + ": "
      + p.getProperty(MagicNames.ANT_JAVA_VERSION));
  out.println("Is this the Apache Harmony VM? "
        + (JavaEnvUtils.isApacheHarmony() ? "yes" : "no"));
  out.println("Is this the Kaffe VM? "
        + (JavaEnvUtils.isKaffe() ? "yes" : "no"));
  out.println("Is this gij/gcj? "
        + (JavaEnvUtils.isGij() ? "yes" : "no"));
  out.println(MagicNames.ANT_LIB + ": " + p.getProperty(MagicNames.ANT_LIB));
  out.println(MagicNames.ANT_HOME + ": " + p.getProperty(MagicNames.ANT_HOME));
}

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

private ClassLoader getClassLoader(ClassLoader classLoader) {
  String buildSysclasspath = project.getProperty(MagicNames.BUILD_SYSCLASSPATH);
  if (project.getCoreLoader() != null
    && !(BUILD_SYSCLASSPATH_ONLY.equals(buildSysclasspath))) {
    classLoader = project.getCoreLoader();
  }
  return classLoader;
}

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

/**
   * check if the attribute value is blank or not
   * {@inheritDoc}
   */
  public boolean isEnabled(UnknownElement el, String value) {
    return convertResult(getProject().getProperty(value) != null);
  }
}

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

/**
 * Sets the current thread's context loader to this classloader, storing
 * the current loader value for later resetting.
 */
public void setThreadContextLoader() {
  if (isContextLoaderSaved) {
    throw new BuildException("Context loader has not been reset");
  }
  if (LoaderUtils.isContextLoaderAvailable()) {
    savedContextLoader = LoaderUtils.getContextClassLoader();
    ClassLoader loader = this;
    if (project != null && "only".equals(project.getProperty("build.sysclasspath"))) {
      loader = this.getClass().getClassLoader();
    }
    LoaderUtils.setContextClassLoader(loader);
    isContextLoaderSaved = true;
  }
}

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

/**
 * Initialize internal instance of XMLCatalog.
 * Initialize XPath for parameter evaluation.
 * @throws BuildException on error
 */
@Override
public void init() throws BuildException {
  super.init();
  xmlCatalog.setProject(getProject());
  xpathFactory = XPathFactory.newInstance();
  xpath = xpathFactory.newXPath();
  xpath.setXPathVariableResolver(
    variableName -> getProject().getProperty(variableName.toString()));
}

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

/**
 * get the name of the current compiler
 * @return the name of the compiler
 * @since Ant 1.5
 */
public String getCompiler() {
  facade.setMagicValue(getProject().getProperty("build.rmic"));
  return facade.getImplementation();
}

代码示例来源:origin: groovy/groovy-core

private void ensureExecutesWithJavaHome(String target) {
  if (project.getProperty("alt.java.home") != null) {
    ensureExecutes(target);
  } else {
    if (!warned) {
      System.err.println("Forked Java tests skipped, not a sun JDK layout");
      warned = true;
    }
  }
}

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

/**
 * The implementation for this particular task.
 *
 * <p>Defaults to the build.compiler property but can be overridden
 * via the compiler attribute.</p>
 *
 * <p>This method does not take the fork attribute into
 * account.</p>
 *
 * @see #getCompiler
 * @return the compiler.
 *
 * @since Ant 1.5
 */
public String getCompilerVersion() {
  facade.setMagicValue(getProject().getProperty("build.compiler"));
  return facade.getImplementation();
}

代码示例来源:origin: groovy/groovy-core

@Override
public void setUp() throws Exception {
  configureProject(SRC_TESTFILES + "groovyDocTests.xml");
  tmpDir = new File(getProject().getProperty("tmpdir"));
}

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

/**
 * Get the value of this PropertyResource.
 * @return the value of the specified Property.
 */
public String getValue() {
  if (isReference()) {
    return getCheckedRef().getValue();
  }
  Project p = getProject();
  return p == null ? null : p.getProperty(getName());
}

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

/**
 * Called to validate that the tool parameters have been configured.
 * @throws BuildException if there is an error.
 */
@Override
public void validateConfigured() throws BuildException {
  super.validateConfigured();
  if (ejbdeploy) {
    String home = getTask().getProject().getProperty("websphere.home");
    if (home == null) {
      throw new BuildException(
        "The 'websphere.home' property must be set when 'ejbdeploy=true'");
    }
    websphereHome = getTask().getProject().resolveFile(home);
  }
}

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

/**
 * Delegate the work to the ant task instance, after setting it up.
 * @throws BuildException on validation failure or if the target didn't
 * execute.
 */
public void execute() throws BuildException {
  if (callee == null) {
    init();
  }
  if (!targetSet) {
    throw new BuildException(
      "Attribute target or at least one nested target is required.",
       getLocation());
  }
  callee.setAntfile(getProject().getProperty("ant.file"));
  callee.setInheritAll(inheritAll);
  callee.setInheritRefs(inheritRefs);
  callee.execute();
}

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

/**
 * Execute the given command, and return it's output
 * @param cmdline command line to execute
 * @return output of the command line
 */
protected String runS(Commandline cmdline) {
  String   outV  = "opts.cc.runS.output" + pcnt++;
  ExecTask exe   = new ExecTask(this);
  Commandline.Argument arg = exe.createArg();
  exe.setExecutable(cmdline.getExecutable());
  arg.setLine(Commandline.toString(cmdline.getArguments()));
  exe.setOutputproperty(outV);
  exe.execute();
  return getProject().getProperty(outV);
}

相关文章