/** * 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)); }
/** * sets the build file to which the XML context belongs * @param buildFile Ant build file * @throws MalformedURLException if parent URL cannot be constructed * @since Ant 1.8.0 */ public void setBuildFile(URL buildFile) throws MalformedURLException { this.buildFileURL = buildFile; this.buildFileParentURL = new URL(buildFile, "."); if (implicitTarget.getLocation() == null) { implicitTarget.setLocation(new Location(buildFile.toString())); } }
/** * 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; } }
/** * 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; } }
target.getLocation()); throw new BuildException("onMissingExtensionPoint attribute cannot " + "be specified unless extensionOf is specified", target.getLocation());
/** * 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<>(); for (final Map.Entry<String, Target> entry : targets.entrySet()) { final String name = entry.getKey(); final Target target = entry.getValue(); 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 it's 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 } } final Map<String, Target> ret = new HashMap<>(); for (final Target target : locationMap.values()) { ret.put(target.getName(), target); } return ret; }
@Override public void addTarget(Target newTarget, int line, int column) { AntTargetNode targetNode = AntTargetNode.newAntTargetNode(newTarget); fProjectNode.addChildNode(targetNode); fCurrentTargetNode = targetNode; fStillOpenElements.push(targetNode); if (fNodeBeingResolved instanceof AntImportNode) { targetNode.setImportNode(fNodeBeingResolved); targetNode.setExternal(true); targetNode.setFilePath(newTarget.getLocation().getFileName()); } else { String targetFileName = newTarget.getLocation().getFileName(); boolean external = isNodeExternal(targetFileName); targetNode.setExternal(external); if (external) { targetNode.setFilePath(targetFileName); } } computeOffset(targetNode, line, column); }
String location = target.getLocation().toString(); if (!targetMap.containsKey(location) || targetMap.get(location).length() > targetName.length()) {