/** * Notes the name of the target so it can be logged * if it generates any messages. * * @param event A BuildEvent containing target information. * Must not be <code>null</code>. */ @Override public void targetStarted(BuildEvent event) { targetName = event.getTarget().getName(); }
/** * Override point, extract the target name * @param event the event to work on * @return the target name to print * @since Ant1.7.1 */ protected String extractTargetName(BuildEvent event) { return event.getTarget().getName(); }
/** * Add a target to the project, or replaces one with the same * name. * * @param target The target to be added or replaced in the project. * Must not be <code>null</code>. */ public void addOrReplaceTarget(final Target target) { addOrReplaceTarget(target.getName(), target); }
/** * Add a <em>new</em> target to the project. * * @param target The target to be added to the project. * Must not be <code>null</code>. * * @exception BuildException if the target already exists in the project * * @see Project#addOrReplaceTarget(Target) */ public void addTarget(final Target target) throws BuildException { addTarget(target.getName(), target); }
/** * Sets the list of targets this target is dependent on. * The targets themselves are not resolved at this time. * * @param depS A comma-separated list of targets this target * depends on. Must not be <code>null</code>. */ public void setDepends(String depS) { for (String dep : parseDepends(depS, getName(), "depends")) { addDependency(dep); } }
/** * 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)); }
/** * Targets in imported files with a project name * and not overloaded by the main build file will * be in the target map twice. This method * removes the duplicate target. * @param targets the targets to filter. * @return the filtered targets. */ private static Map<String, Target> removeDuplicateTargets(final Map<String, Target> targets) { final Map<Location, Target> locationMap = new HashMap<>(); targets.forEach((name, target) -> { final Target otherTarget = locationMap.get(target.getLocation()); // Place this entry in the location map if // a) location is not in the map // b) location is in map, but its name is longer // (an imported target will have a name. prefix) if (otherTarget == null || otherTarget.getName().length() > name.length()) { locationMap.put(target.getLocation(), target); // Smallest name wins } }); return locationMap.values().stream() .collect(Collectors.toMap(Target::getName, target -> target, (a, b) -> b)); }
/** * Fired when a target starts building, this pushes a timed element * for the target onto the stack of elements for the current thread, * remembering the current time and the name of the target. * * @param event An event with any relevant extra information. * Will not be <code>null</code>. */ @Override public void targetStarted(BuildEvent event) { Target target = event.getTarget(); TimedElement targetElement = new TimedElement(); targetElement.startTime = System.currentTimeMillis(); targetElement.element = doc.createElement(TARGET_TAG); targetElement.element.setAttribute(NAME_ATTR, target.getName()); targets.put(target, targetElement); getStack().push(targetElement); }
/** * Logs a message to say that the target has started. * * @param event * An event with any relevant extra information. Must not be * <code>null</code>. */ @Override public void targetStarted(BuildEvent event) { Date now = new Date(); String name = "Target " + event.getTarget().getName(); logStart(event, now, name); profileData.put(event.getTarget(), now); }
/** * Logs a message to say that the target has started if this * logger allows information-level messages. * * @param event An event with any relevant extra information. * Must not be <code>null</code>. */ public void targetStarted(BuildEvent event) { if (Project.MSG_INFO <= msgOutputLevel && !event.getTarget().getName().isEmpty()) { String msg = String.format("%n%s:", event.getTarget().getName()); printMessage(msg, out, event.getPriority()); log(msg); } }
/** * Logs a message to say that the target has finished. * * @param event * An event with any relevant extra information. Must not be * <code>null</code>. */ @Override public void targetFinished(BuildEvent event) { Date start = profileData.remove(event.getTarget()); String name = "Target " + event.getTarget().getName(); logFinish(event, start, name); }
/** * @see org.apache.tools.ant.BuildListener#targetStarted(BuildEvent) * {@inheritDoc}. */ public void targetStarted(BuildEvent event) { log(">> TARGET STARTED -- " + event.getTarget(), Project.MSG_DEBUG); log(String.format("%n%s:", event.getTarget().getName()), Project.MSG_INFO); targetStartTime = System.currentTimeMillis(); }
canExecute = false; log(curtarget, "Cannot execute '" + curtarget.getName() + "' - '" + dependencyName + "' failed or was not executed.", MSG_ERR); try { curtarget.performTasks(); succeededTargets.add(curtarget.getName()); } catch (final RuntimeException ex) { if (!keepGoingMode) { if (thrownException instanceof BuildException) { log(curtarget, "Target '" + curtarget.getName() + "' failed with message '" + thrownException.getMessage() + "'.", MSG_ERR); "Target '" + curtarget.getName() + "' failed with message '" + thrownException.getMessage() + "'.", MSG_ERR);
@Override public void execute() throws BuildException { if (extensionPoint == null) { throw new BuildException("extensionPoint required", getLocation()); } if (getOwningTarget() == null || !getOwningTarget().getName().isEmpty()) { throw new BuildException("bindtargets only allowed as a top-level task"); } if (onMissingExtensionPoint == null) { onMissingExtensionPoint = OnMissingExtensionPoint.FAIL; } final ProjectHelper helper = getProject().getReference( ProjectHelper.PROJECTHELPER_REFERENCE); for (String target : targets) { helper.getExtensionStack().add(new String[] {extensionPoint, target, onMissingExtensionPoint.name()}); } } }
final String targetName = currentTarget.getName(); if (targetName.isEmpty()) { continue;
|| !getOwningTarget().getName().isEmpty()) { throw new BuildException("import only allowed as a top-level task");
/** * @see BuildListener#targetStarted * {@inheritDoc} */ public void targetStarted(final BuildEvent event) { _log.debug("Start: " + event.getTarget().getName()); }
public boolean isDefaultTarget() { String targetName = fTarget.getName(); if (targetName == null) { return false; } return targetName.equals(fTarget.getProject().getDefaultTarget()); }