Search in sources :

Example 1 with BuildException

use of org.apache.tools.ant.BuildException in project jetty.project by eclipse.

the class JettyRunTask method execute.

/**
     * Executes this Ant task. The build flow is being stopped until Jetty
     * server stops.
     *
     * @throws BuildException if unable to build
     */
public void execute() throws BuildException {
    TaskLog.log("Configuring Jetty for project: " + getProject().getName());
    setSystemProperties();
    List<Connector> connectorsList = null;
    if (connectors != null)
        connectorsList = connectors.getConnectors();
    else
        connectorsList = new Connectors(jettyPort, 30000).getDefaultConnectors();
    List<LoginService> loginServicesList = (loginServices != null ? loginServices.getLoginServices() : new ArrayList<LoginService>());
    ServerProxyImpl server = new ServerProxyImpl();
    server.setConnectors(connectorsList);
    server.setLoginServices(loginServicesList);
    server.setRequestLog(requestLog);
    server.setJettyXml(jettyXml);
    server.setDaemon(daemon);
    server.setStopPort(stopPort);
    server.setStopKey(stopKey);
    server.setContextHandlers(contextHandlers);
    server.setTempDirectory(tempDirectory);
    server.setScanIntervalSecs(scanIntervalSeconds);
    try {
        for (WebAppContext webapp : webapps) {
            server.addWebApplication((AntWebAppContext) webapp);
        }
    } catch (Exception e) {
        throw new BuildException(e);
    }
    server.start();
}
Also used : Connectors(org.eclipse.jetty.ant.types.Connectors) Connector(org.eclipse.jetty.ant.types.Connector) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) ArrayList(java.util.ArrayList) BuildException(org.apache.tools.ant.BuildException) LoginService(org.eclipse.jetty.security.LoginService) BuildException(org.apache.tools.ant.BuildException)

Example 2 with BuildException

use of org.apache.tools.ant.BuildException in project jetty.project by eclipse.

the class JettyStopTask method execute.

/** 
     * @see org.apache.tools.ant.Task#execute()
     */
public void execute() throws BuildException {
    try {
        Socket s = new Socket(InetAddress.getByName("127.0.0.1"), stopPort);
        if (stopWait > 0)
            s.setSoTimeout(stopWait * 1000);
        try {
            OutputStream out = s.getOutputStream();
            out.write((stopKey + "\r\nstop\r\n").getBytes());
            out.flush();
            if (stopWait > 0) {
                TaskLog.log("Waiting" + (stopWait > 0 ? (" " + stopWait + "sec") : "") + " for jetty to stop");
                LineNumberReader lin = new LineNumberReader(new InputStreamReader(s.getInputStream()));
                String response = lin.readLine();
                if ("Stopped".equals(response))
                    System.err.println("Stopped");
            }
        } finally {
            s.close();
        }
    } catch (ConnectException e) {
        TaskLog.log("Jetty not running!");
    } catch (Exception e) {
        TaskLog.log(e.getMessage());
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) OutputStream(java.io.OutputStream) Socket(java.net.Socket) ConnectException(java.net.ConnectException) BuildException(org.apache.tools.ant.BuildException) LineNumberReader(java.io.LineNumberReader) ConnectException(java.net.ConnectException)

Example 3 with BuildException

use of org.apache.tools.ant.BuildException in project tomcat by apache.

the class SignCode method execute.

@Override
public void execute() throws BuildException {
    List<File> filesToSign = new ArrayList<>();
    // signed.
    for (FileSet fileset : filesets) {
        DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
        File basedir = ds.getBasedir();
        String[] files = ds.getIncludedFiles();
        if (files.length > 0) {
            for (int i = 0; i < files.length; i++) {
                File file = new File(basedir, files[i]);
                filesToSign.add(file);
            }
        }
    }
    try {
        String signingSetID = makeSigningRequest(filesToSign);
        downloadSignedFiles(filesToSign, signingSetID);
    } catch (SOAPException | IOException e) {
        throw new BuildException(e);
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) SOAPException(javax.xml.soap.SOAPException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) File(java.io.File)

Example 4 with BuildException

use of org.apache.tools.ant.BuildException in project checkstyle by checkstyle.

the class CheckstyleAntTaskTest method testNonExistingConfig.

@Test
public final void testNonExistingConfig() throws IOException {
    final CheckstyleAntTask antTask = new CheckstyleAntTask();
    antTask.setConfig(new File(getPath(NOT_EXISTING_FILE)));
    antTask.setProject(new Project());
    antTask.setFile(new File(getPath(FLAWLESS_INPUT)));
    try {
        antTask.execute();
        fail("Exception is expected");
    } catch (BuildException ex) {
        assertTrue(ex.getMessage().startsWith("Unable to create Root Module: configLocation"));
    }
}
Also used : Project(org.apache.tools.ant.Project) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) Test(org.junit.Test)

Example 5 with BuildException

use of org.apache.tools.ant.BuildException in project SIMRacingApps by SIMRacingApps.

the class Launch4jTask method execute.

public void execute() throws BuildException {
    try {
        if (tmpdir != null) {
            System.setProperty("launch4j.tmpdir", tmpdir.getPath());
        }
        if (bindir != null) {
            System.setProperty("launch4j.bindir", bindir.getPath());
        }
        if (_configFile != null && _config != null) {
            throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
        } else if (_configFile != null) {
            ConfigPersister.getInstance().load(_configFile);
            Config c = ConfigPersister.getInstance().getConfig();
            if (jar != null) {
                c.setJar(jar);
            }
            if (outfile != null) {
                c.setOutfile(outfile);
            }
            if (fileVersion != null) {
                c.getVersionInfo().setFileVersion(fileVersion);
            }
            if (txtFileVersion != null) {
                c.getVersionInfo().setTxtFileVersion(txtFileVersion);
            }
            if (productVersion != null) {
                c.getVersionInfo().setProductVersion(productVersion);
            }
            if (txtProductVersion != null) {
                c.getVersionInfo().setTxtProductVersion(txtProductVersion);
            }
        } else if (_config != null) {
            _config.unwrap();
            ConfigPersister.getInstance().setAntConfig(_config, getProject().getBaseDir());
        } else {
            throw new BuildException(Messages.getString("Launch4jTask.specify.config"));
        }
        final Builder b = new Builder(Log.getAntLog());
        b.build();
    } catch (ConfigPersisterException e) {
        throw new BuildException(e);
    } catch (BuilderException e) {
        throw new BuildException(e);
    }
}
Also used : BuilderException(net.sf.launch4j.BuilderException) ConfigPersisterException(net.sf.launch4j.config.ConfigPersisterException) Config(net.sf.launch4j.config.Config) Builder(net.sf.launch4j.Builder) BuildException(org.apache.tools.ant.BuildException)

Aggregations

BuildException (org.apache.tools.ant.BuildException)930 IOException (java.io.IOException)390 File (java.io.File)365 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)75 ArrayList (java.util.ArrayList)65 InputStream (java.io.InputStream)62 Project (org.apache.tools.ant.Project)61 Resource (org.apache.tools.ant.types.Resource)58 FileSet (org.apache.tools.ant.types.FileSet)52 Path (org.apache.tools.ant.types.Path)52 Commandline (org.apache.tools.ant.types.Commandline)51 Properties (java.util.Properties)50 OutputStream (java.io.OutputStream)44 FileOutputStream (java.io.FileOutputStream)42 FileResource (org.apache.tools.ant.types.resources.FileResource)42 FileInputStream (java.io.FileInputStream)41 URL (java.net.URL)40 BufferedReader (java.io.BufferedReader)37 Writer (java.io.Writer)37 MalformedURLException (java.net.MalformedURLException)37