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();
}
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());
}
}
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);
}
}
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"));
}
}
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);
}
}
Aggregations