/** * 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; }
/** * 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); }
/** * @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; }
/** * 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); }
/** * Get the value of source. * @return value of source. */ public String getSource() { return source != null ? source : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE); }
/** * 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; } }
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; }
/** * 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)); }
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; }
/** * check if the attribute value is blank or not * {@inheritDoc} */ public boolean isEnabled(UnknownElement el, String value) { return convertResult(getProject().getProperty(value) != null); } }
/** * 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; } }
/** * 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())); }
/** * 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(); }
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; } } }
/** * 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(); }
@Override public void setUp() throws Exception { configureProject(SRC_TESTFILES + "groovyDocTests.xml"); tmpDir = new File(getProject().getProperty("tmpdir")); }
/** * 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()); }
/** * 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); } }
/** * 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(); }
/** * 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); }