Search in sources :

Example 1 with DefaultInputHandler

use of org.apache.tools.ant.input.DefaultInputHandler in project eclipse.platform by eclipse-platform.

the class InputHandlerSetter method setInputHandler.

protected void setInputHandler(Project project, String inputHandlerClassname) {
    InputHandler handler = null;
    if (inputHandlerClassname == null) {
        handler = new DefaultInputHandler();
    } else {
        try {
            handler = (InputHandler) (Class.forName(inputHandlerClassname).getConstructor().newInstance());
        } catch (ClassCastException e) {
            String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5"), new Object[] { // $NON-NLS-1$
            inputHandlerClassname });
            throw new BuildException(msg, e);
        } catch (Exception e) {
            String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6"), new Object[] { // $NON-NLS-1$
            inputHandlerClassname, e.getClass().getName() });
            throw new BuildException(msg, e);
        }
    }
    project.setInputHandler(handler);
}
Also used : InputHandler(org.apache.tools.ant.input.InputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) BuildException(org.apache.tools.ant.BuildException) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) BuildException(org.apache.tools.ant.BuildException)

Example 2 with DefaultInputHandler

use of org.apache.tools.ant.input.DefaultInputHandler in project CodenameOne by codenameone.

the class AbstractCN1Mojo method setupAnt.

private void setupAnt() throws MojoExecutionException, MojoFailureException {
    antProject = new Project();
    if (project.getBasedir() != null) {
        antProject.setBaseDir(project.getBasedir());
    } else {
        antProject.setBaseDir(new File("."));
    }
    antProject.setDefaultInputStream(System.in);
    InputHandler handler = new DefaultInputHandler();
    antProject.setProjectReference(handler);
    antProject.setInputHandler(handler);
    antProject.init();
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Project(org.apache.tools.ant.Project) InputHandler(org.apache.tools.ant.input.InputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) File(java.io.File) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler)

Example 3 with DefaultInputHandler

use of org.apache.tools.ant.input.DefaultInputHandler in project CodenameOne by codenameone.

the class GenerateAppProjectMojo method antProject.

private Project antProject() {
    if (antProject == null) {
        antProject = new Project();
        antProject.setBaseDir(sourceProject);
        antProject.setDefaultInputStream(System.in);
        InputHandler handler = new DefaultInputHandler();
        antProject.setProjectReference(handler);
        antProject.setInputHandler(handler);
        antProject.init();
    }
    return antProject;
}
Also used : Project(org.apache.tools.ant.Project) InputHandler(org.apache.tools.ant.input.InputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler)

Example 4 with DefaultInputHandler

use of org.apache.tools.ant.input.DefaultInputHandler in project CodenameOne by codenameone.

the class GenerateCn1libProjectMojo method antProject.

private Project antProject() {
    if (antProject == null) {
        antProject = new Project();
        antProject.setBaseDir(sourceProject);
        antProject.setDefaultInputStream(System.in);
        InputHandler handler = new DefaultInputHandler();
        antProject.setProjectReference(handler);
        antProject.setInputHandler(handler);
        antProject.init();
    }
    return antProject;
}
Also used : Project(org.apache.tools.ant.Project) InputHandler(org.apache.tools.ant.input.InputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler)

Example 5 with DefaultInputHandler

use of org.apache.tools.ant.input.DefaultInputHandler in project ant by apache.

the class Main method addInputHandler.

/**
 * Creates the InputHandler and adds it to the project.
 *
 * @param project the project instance.
 *
 * @exception BuildException if a specified InputHandler
 *                           implementation could not be loaded.
 */
private void addInputHandler(final Project project) throws BuildException {
    InputHandler handler = null;
    if (inputHandlerClassname == null) {
        handler = new DefaultInputHandler();
    } else {
        handler = ClasspathUtils.newInstance(inputHandlerClassname, Main.class.getClassLoader(), InputHandler.class);
        project.setProjectReference(handler);
    }
    project.setInputHandler(handler);
}
Also used : InputHandler(org.apache.tools.ant.input.InputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler)

Aggregations

DefaultInputHandler (org.apache.tools.ant.input.DefaultInputHandler)10 InputHandler (org.apache.tools.ant.input.InputHandler)8 Project (org.apache.tools.ant.Project)4 BuildException (org.apache.tools.ant.BuildException)3 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 PipedInputStream (java.io.PipedInputStream)2 PipedOutputStream (java.io.PipedOutputStream)2 MavenProject (org.apache.maven.project.MavenProject)2 Test (org.junit.Test)2 AssumptionViolatedException (org.junit.AssumptionViolatedException)1