use of org.gradle.plugins.javascript.envjs.http.HttpFileServer in project gradle by gradle.
the class BrowserEvaluate method doEvaluate.
@TaskAction
void doEvaluate() {
HttpFileServer fileServer = new SimpleHttpFileServerFactory().start(getContent(), 0);
try {
Writer resultWriter = new FileWriter(getResult());
getEvaluator().evaluate(fileServer.getResourceUrl(getResource()), resultWriter);
resultWriter.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
fileServer.stop();
}
setDidWork(true);
}
use of org.gradle.plugins.javascript.envjs.http.HttpFileServer 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);
}
}
Aggregations