/** * Construct a BuildEvent for a target level event. * The project associated with the event is derived * from the given target. * * @param target the target that emitted the event. * Must not be <code>null</code>. */ public BuildEvent(Target target) { super(target); this.project = target.getProject(); this.target = target; this.task = null; }
/** * Does this target depend on the named target? * @param other the other named target. * @return true if the target does depend on the named target * @since Ant 1.6 */ public boolean dependsOn(String other) { Project p = getProject(); Hashtable<String, Target> t = p == null ? null : p.getTargets(); return p != null && p.topoSort(getName(), t, false).contains(t.get(other)); }
/** * Sets the "unless" condition to test on execution. This is the * name of a property to test for existence - if the property * is set, the task will not execute. The property goes * through property substitution once before testing, so if * property <code>foo</code> has value <code>bar</code>, setting * the "unless" condition to <code>${foo}_x</code> will mean that the * task will only execute if property <code>bar_x</code> isn't set. * * @param property The property condition to test on execution. * May be <code>null</code>, in which case * no "unless" test is performed. */ public void setUnless(String property) { unlessString = property == null ? "" : property; setUnless(() -> { PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(getProject()); Object o = propertyHelper.parseProperties(unlessString); return !propertyHelper.testUnlessCondition(o); }); }
/** * Sets the "if" condition to test on execution. This is the * name of a property to test for existence - if the property * is not set, the task will not execute. The property goes * through property substitution once before testing, so if * property <code>foo</code> has value <code>bar</code>, setting * the "if" condition to <code>${foo}_x</code> will mean that the * task will only execute if property <code>bar_x</code> is set. * * @param property The property condition to test on execution. * May be <code>null</code>, in which case * no "if" test is performed. */ public void setIf(String property) { ifString = property == null ? "" : property; setIf(() -> { PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(getProject()); Object o = propertyHelper.parseProperties(ifString); return propertyHelper.testIfCondition(o); }); }
/** * Same as {@link #setIf(String)} but requires a {@link Condition} instance * * @param condition Condition * @since 1.9 */ public void setIf(Condition condition) { if (ifCondition == null) { ifCondition = condition; } else { And andCondition = new And(); andCondition.setProject(getProject()); andCondition.setLocation(getLocation()); andCondition.add(ifCondition); andCondition.add(condition); ifCondition = andCondition; } }
/** * Same as {@link #setUnless(String)} but requires a {@link Condition} instance * * @param condition Condition * @since 1.9 */ public void setUnless(Condition condition) { if (unlessCondition == null) { unlessCondition = condition; } else { Or orCondition = new Or(); orCondition.setProject(getProject()); orCondition.setLocation(getLocation()); orCondition.add(unlessCondition); orCondition.add(condition); unlessCondition = orCondition; } }
return; LocalProperties localProperties = LocalProperties.get(getProject()); localProperties.enterScope(); try {
/** * Constructor. * * @param target The current target */ public AntLogger(Target target) { this.project = target.getProject(); this.target = target; initialize(); }
/** * Constructor. * * @param target The current target */ public AntLogger(Target target) { this.project = target.getProject(); this.target = target; initialize(); }
@TaskAction protected void executeAntTarget() { File oldBaseDir = target.getProject().getBaseDir(); target.getProject().setBaseDir(baseDir); try { target.performTasks(); } finally { target.getProject().setBaseDir(oldBaseDir); } }
/** * Returns the name of a missing dependency or <code>null</code> if all dependencies exist in the project. */ public String checkDependencies() { Enumeration<String> dependencies = fTarget.getDependencies(); while (dependencies.hasMoreElements()) { String dependency = dependencies.nextElement(); if (fTarget.getProject().getTargets().get(dependency) == null) { return dependency; } } return null; }
public boolean isDefaultTarget() { String targetName = fTarget.getName(); if (targetName == null) { return false; } return targetName.equals(fTarget.getProject().getDefaultTarget()); }
private File pickOutputDir() { if (this.outputDir != null) { return this.outputDir; } return getOwningTarget().getProject().getBaseDir(); }
@Override public void reset() { super.reset(); Map<String, Target> currentTargets = fTarget.getProject().getTargets(); if (currentTargets.get(fTarget.getName()) != null) { currentTargets.remove(fTarget.getName()); } }
/** * @see org.apache.tools.ant.Task#execute() */ public void execute() throws BuildException { validateTaskConfiguration(); // because <echo> task lets you have the message in the XML text node, we need to trim all newlines and whitespace message = message.replaceAll( "\r\n", "" ).replaceAll( "\n", "" ).trim(); // let's get the arguments // let's convert the message (which is only a bundle key right now) to the actual localized message message = Msg.createMsg( m_bundle, m_locale, message, m_arguments.toArray() ).toString(); // if property is set, put the message text in that property, otherwise, we echo the message if ( m_property != null ) { Project proj = getOwningTarget().getProject(); proj.setNewProperty( m_property, message ); } else { super.execute(); } return; }
/** * method assumes sendor has checked whether to report problems */ private void checkCircularDependencies(IAntElement node) { Target target = ((AntTargetNode) node).getTarget(); String name = target.getName(); if (name == null) { return; } try { target.getProject().topoSort(name, target.getProject().getTargets()); } catch (BuildException be) { // possible circular dependency String message = be.getMessage(); if (message.startsWith("Circular")) { //$NON-NLS-1$ //we do our own checking for missing dependencies IProblem problem = createProblem(message, node.getProjectNode().getOffset(), node.getProjectNode().getSelectionLength(), AntModelProblem.SEVERITY_ERROR); acceptProblem(problem); markHierarchy(node.getProjectNode(), AntModelProblem.SEVERITY_ERROR, message); } } }
try { ExpressionEvaluator exprEvaluator = (ExpressionEvaluator) antTasks .getProject().getReference("maven.expressionEvaluator"); Project antProject = antTasks.getProject(); PropertyHelper propertyHelper = PropertyHelper .getPropertyHelper(antProject);
final Project antProject = getOwningTarget().getProject(); final Project newProject = new Project(); newProject.init();
final Project antProject = getOwningTarget().getProject(); final Project newProject = new Project(); newProject.init();
final Project antProject = getOwningTarget().getProject(); final Project newProject = new Project(); newProject.init();