use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class GeneratePluginDescriptors method writePropertiesTo.
private void writePropertiesTo(Properties properties, File descriptorFile) {
try {
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(descriptorFile));
GUtil.savePropertiesNoDateComment(properties, outputStream);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class NestedModelRuleDescriptor method describeTo.
@Override
public void describeTo(Appendable appendable) {
parent.describeTo(appendable);
try {
appendable.append(" > ");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
child.describeTo(appendable);
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class SimpleHttpFileServerFactory method start.
public HttpFileServer start(File contentRoot, int port) {
Container container = new SimpleFileServerContainer(new FileContext(contentRoot));
try {
final Server server = new ContainerServer(container);
Connection connection = new SocketConnection(server);
InetSocketAddress address = new InetSocketAddress(port);
InetSocketAddress usedAddress = (InetSocketAddress) connection.connect(address);
return new SimpleHttpFileServer(contentRoot, usedAddress.getPort(), new Stoppable() {
public void stop() {
try {
server.stop();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
});
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class SimpleFileServerContainer method handle.
public void handle(Request req, Response resp) {
Index requestIndex = context.getIndex(req.getTarget());
File targetFile = requestIndex.getFile();
if (!targetFile.exists()) {
resp.setCode(404);
resp.setText("Not Found");
try {
resp.getPrintStream().println(String.format("File '%s' does not exist", targetFile.getAbsolutePath()));
resp.commit();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
String contentType = requestIndex.getContentType();
resp.set("Content-Type", contentType);
OutputStream output = null;
try {
output = resp.getOutputStream();
if (contentType.startsWith("text/")) {
resp.set("Content-Encoding", Charset.defaultCharset().name());
Reader input = new FileReader(requestIndex.getFile());
IOUtils.copy(input, output);
IOUtils.closeQuietly(input);
} else {
InputStream input = new FileInputStream(requestIndex.getFile());
IOUtils.copy(input, output);
IOUtils.closeQuietly(input);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
IOUtils.closeQuietly(output);
}
}
use of org.gradle.api.UncheckedIOException in project gradle by gradle.
the class OutputScrapingExecutionResult method normalize.
public static String normalize(String output) {
StringBuilder result = new StringBuilder();
List<String> lines;
try {
lines = CharSource.wrap(output).readLines();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
int i = 0;
while (i < lines.size()) {
String line = lines.get(i);
if (line.contains(DaemonStartupMessage.STARTING_DAEMON_MESSAGE)) {
// Remove the "daemon starting" message
i++;
} else if (line.contains(DaemonStateCoordinator.DAEMON_WILL_STOP_MESSAGE)) {
// Remove the "Daemon will be shut down" message
i++;
} else if (i == lines.size() - 1 && line.matches("Total time: [\\d\\.]+ secs")) {
result.append("Total time: 1 secs");
result.append('\n');
i++;
} else {
result.append(line);
result.append('\n');
i++;
}
}
return result.toString();
}
Aggregations