Refine search
private void badRecipient(EmailAddress rcpt, IOException reason) { String msg = "Failed to send mail to " + rcpt; if (shouldIgnoreInvalidRecipients()) { msg += " because of :" + reason.getMessage(); if (task != null) { task.log(msg, Project.MSG_WARN); } else { System.err.println(msg); } } else { throw new BuildException(msg, reason); } } }
/** * Run the task, which is skipped if null. * When invoked again, the task is re-run. */ public void run() { try { if (task != null) { task.execute(); } } catch (Throwable thrown) { caught(thrown); } finally { synchronized (notify) { finished = true; //reset the task. //wake up our owner, if it is waiting notify.notifyAll(); } } } }
/** * Checks if there are any collected errors and throws a BuildException * with all messages if there was one or more. * @throws BuildException if one or more errors were registered */ public void checkErrors() throws BuildException { if (!errors.isEmpty()) { StringBuilder sb = new StringBuilder(String.format("Configuration error on <%s>:%n", task.getTaskName())); for (String msg : errors) { sb.append(String.format("- %s%n", msg)); } throw new BuildException(sb.toString(), task.getLocation()); } }
/** * Bind and initialise a task * @param task task to bind */ private void bind(Task task) { task.bindToOwner(this); task.init(); }
/** * Construct a BuildEvent for a task level event. * The project and target associated with the event * are derived from the given task. * * @param task the task that emitted the event. * Must not be <code>null</code>. */ public BuildEvent(Task task) { super(task); this.project = task.getProject(); this.target = task.getOwningTarget(); this.task = task; }
/** * Bind a task to another; use this when configuring a newly created * task to do work on behalf of another. * Project, OwningTarget, TaskName, Location and Description are all copied * * Important: this method does not call {@link Task#init()}. * If you are creating a task to delegate work to, call {@link Task#init()} * to initialize it. * * @param owner owning target * @since Ant1.7 */ public final void bindToOwner(Task owner) { setProject(owner.getProject()); setOwningTarget(owner.getOwningTarget()); setTaskName(owner.getTaskName()); setDescription(owner.getDescription()); setLocation(owner.getLocation()); setTaskType(owner.getTaskType()); } }
@Override public void execute() throws BuildException { super.execute(); try { List<File> fileList = createListOfAllFilesToMerge(); // If there is nothing to merge, don't if (fileList.isEmpty()) { return; } // if the merge target doesn't exist yet, then the first file // becomes // the merge target File to = new File(into); if (!to.exists()) { File from = fileList.remove(0); copyFile(from, to); } // If there was only one file, and it has been copied as // the merge target then you're done if (fileList.isEmpty()) { return; } UnionResults.main(createCommandArgumentsArray(fileList)); } catch (Exception e) { throw new BuildException(e); } }
/** * 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); } }
/** * Add any task validation needed to ensure internal code quality * @param task task * @param role role of the task */ private void validateTask(Task task, String role) { if (task != null && task.getProject() == null) { throw new BuildException("%s task is not bound to the project %s", role, task); } }
UnknownElement ue = getReplacement(); Task task = ue.getTask(); task.perform(); } else { getProject().fireTaskStarted(this); Throwable reason = null; try { maybeConfigure(); DispatchUtils.execute(this); } catch (BuildException ex) { if (ex.getLocation() == Location.UNKNOWN_LOCATION) { ex.setLocation(getLocation()); } catch (Exception ex) { reason = ex; BuildException be = new BuildException(ex); be.setLocation(getLocation()); throw be; } catch (Error ex) { throw ex; } finally { getProject().fireTaskFinished(this, reason);
/** * A utility method that runs an external command. Writes the output and * error streams of the command to the project log. * * @param task The task that the command is part of. Used for logging * @param cmdline The command to execute. * @throws BuildException if the command does not exit successfully. */ public static void runCommand(Task task, String... cmdline) throws BuildException { try { task.log(Commandline.describeCommand(cmdline), Project.MSG_VERBOSE); Execute exe = new Execute( new LogStreamHandler(task, Project.MSG_INFO, Project.MSG_ERR)); exe.setAntRun(task.getProject()); exe.setCommandline(cmdline); int retval = exe.execute(); if (isFailure(retval)) { throw new BuildException(cmdline[0] + " failed with return code " + retval, task.getLocation()); } } catch (IOException exc) { throw new BuildException("Could not launch " + cmdline[0] + ": " + exc, task.getLocation()); } }
Project project = getTask().getProject(); execTask.setAntRun(project); execTask.setWorkingDirectory(project.getBaseDir()); int result = execTask.execute(); if (Execute.isFailure(result)) { throw new BuildException( "Failed executing java2iiop (ret code is " + result + ")", getTask().getLocation()); throw new BuildException(e, getTask().getLocation());
|| "javac1.1".equalsIgnoreCase(compilerType) || "javac1.2".equalsIgnoreCase(compilerType)) { task.log( "This version of java does not support the classic compiler; upgrading to modern", Project.MSG_WARN); return new Javac13(); throw new BuildException( "Unable to find a javac compiler;\n%s is not on the classpath.\nPerhaps JAVA_HOME does not point to the JDK.\nIt is currently set to \"%s\"", MODERN_COMPILER, JavaEnvUtils.getJavaHome()); task.getProject().createClassLoader(classpath));
for (int i = 0; i <= retryCount; i++) { try { nestedTask.perform(); break; } catch (Exception e) { errorMessages.append(e.getMessage()); if (i >= retryCount) { throw new BuildException(String.format( "Task [%s] failed after [%d] attempts; giving up.%nError messages:%n%s", nestedTask.getTaskName(), retryCount, errorMessages), getLocation());
throw new BuildException("Unable to write EJB jar", e); = getTask().getProject().getProperty("build.compiler"); throw new BuildException("Ejbc reported an error"); throw new BuildException("Exception while calling " + ejbcClassName + ". Details: " + e.toString(), e);
/** * Generate the client jar corresponding to the jar file passed as parameter * the method uses the BorlandGenerateClient task. * @param sourceJar java.io.File representing the produced jar file */ private void generateClient(File sourceJar) { getTask().getProject().addTaskDefinition("internal_bas_generateclient", org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient.class); BorlandGenerateClient gentask; log("generate client for " + sourceJar, Project.MSG_INFO); try { Project project = getTask().getProject(); gentask = (BorlandGenerateClient) project.createTask("internal_bas_generateclient"); gentask.setEjbjar(sourceJar); gentask.setDebug(java2iiopdebug); Path classpath = getCombinedClasspath(); if (classpath != null) { gentask.setClasspath(classpath); } gentask.setVersion(version); gentask.setTaskName("generate client"); gentask.execute(); } catch (Exception e) { //TO DO : delete the file if it is not a valid file. throw new BuildException("Exception while calling " + VERIFY, e); } }
final String taskName = task.getTaskName(); throw new BuildException("antcall not supported within AntBuilder, consider using 'ant.project.executeTarget('targetName')' instead."); if (currentStreamCount == 0) { savedProjectInputStream = project.getDefaultInputStream(); savedIn = System.in; savedErr = System.err; project.setDefaultInputStream(savedIn); demuxInputStream = new DemuxInputStream(project); System.setIn(demuxInputStream); if (currentStreamCount == 0) { project.setDefaultInputStream(savedProjectInputStream); System.setOut(savedOut); System.setErr(savedErr);
public AntBuilder(final Task parentTask) { this(parentTask.getProject(), parentTask.getOwningTarget()); // define "owning" task as wrapper to avoid having tasks added to the target // but it needs to be an UnknownElement and no access is available from // task to its original UnknownElement final UnknownElement ue = new UnknownElement(parentTask.getTaskName()); ue.setProject(parentTask.getProject()); ue.setTaskType(parentTask.getTaskType()); ue.setTaskName(parentTask.getTaskName()); ue.setLocation(parentTask.getLocation()); ue.setOwningTarget(parentTask.getOwningTarget()); ue.setRuntimeConfigurableWrapper(parentTask.getRuntimeConfigurableWrapper()); parentTask.getRuntimeConfigurableWrapper().setProxy(ue); antXmlContext.pushWrapper(parentTask.getRuntimeConfigurableWrapper()); }
/** * Sets the 'useCommonsLang3' property of this class * * @param useCommonsLang3 */ public void setUseCommonsLang3(boolean useCommonsLang3) { super.log("useCommonsLang3 is deprecated. Please remove it from your config.", Project.MSG_WARN); }
if (!fileDTD.exists()) { fileDTD = owningTask.getProject().resolveFile(location); if (publicId != null) { fileDTDs.put(publicId, fileDTD); owningTask.log("Mapped publicId " + publicId + " to file " + fileDTD, Project.MSG_VERBOSE); if (publicId != null) { resourceDTDs.put(publicId, location); owningTask.log("Mapped publicId " + publicId + " to resource " + location, Project.MSG_VERBOSE);