summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-22 15:35:29 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-22 15:35:29 +0100
commit7863a228b54722d7b1b42f9e39e2ee115a97aee5 (patch)
tree01576c5e63d15786001d56fcfb3ee76e8082694d
parent3134a588789cde591daa6065cf5e5db4b3c82523 (diff)
downloadRustAndDust-7863a228b54722d7b1b42f9e39e2ee115a97aee5.zip
RustAndDust-7863a228b54722d7b1b42f9e39e2ee115a97aee5.tar.gz
-rw-r--r--build.gradle9
-rw-r--r--server/build.gradle27
-rw-r--r--server/src/ch/asynk/rustanddust/server/Server.java37
-rw-r--r--settings.gradle2
4 files changed, 74 insertions, 1 deletions
diff --git a/build.gradle b/build.gradle
index bd67a0a..24ada65 100644
--- a/build.gradle
+++ b/build.gradle
@@ -77,6 +77,15 @@ project(":core") {
}
}
+project(":server") {
+ apply plugin: "java"
+
+
+ dependencies {
+ compile project(":core")
+ }
+}
+
task ctags(type: Exec) {
executable "ctags"
args "-R", "--language-force=java", "-f.tags", "core/src/"
diff --git a/server/build.gradle b/server/build.gradle
new file mode 100644
index 0000000..d2c6481
--- /dev/null
+++ b/server/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: "java"
+
+sourceCompatibility = 1.7
+sourceSets.main.java.srcDirs = [ "src/" ]
+
+project.ext.mainClassName = "ch.asynk.rustanddust.server.Server"
+
+task run(dependsOn: classes, type: JavaExec) {
+ main = project.mainClassName
+ classpath = sourceSets.main.runtimeClasspath
+ standardInput = System.in
+ /* workingDir = project.assetsDir */
+ ignoreExitValue = true
+}
+
+task dist(type: Jar) {
+ from files(sourceSets.main.output.classesDir)
+ from files(sourceSets.main.output.resourcesDir)
+ from {configurations.compile.collect {zipTree(it)}}
+ /* from files(project.assetsDir); */
+
+ manifest {
+ attributes 'Main-Class': project.mainClassName
+ }
+}
+
+dist.dependsOn classes
diff --git a/server/src/ch/asynk/rustanddust/server/Server.java b/server/src/ch/asynk/rustanddust/server/Server.java
new file mode 100644
index 0000000..4a2000c
--- /dev/null
+++ b/server/src/ch/asynk/rustanddust/server/Server.java
@@ -0,0 +1,37 @@
+package ch.asynk.rustanddust.server;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+public class Server
+{
+
+ public static void main(String[] args) throws Exception
+ {
+ HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
+ server.createContext("/test", new MyHandler());
+ server.setExecutor(null);
+ server.start();
+ // System.exit(0);
+ }
+
+ static class MyHandler implements HttpHandler
+ {
+ @Override
+ public void handle(HttpExchange t) throws IOException
+ {
+ System.err.print("answering ...");
+ String response = "This is the response";
+ t.sendResponseHeaders(200, response.length());
+ OutputStream os = t.getResponseBody();
+ os.write(response.getBytes());
+ os.close();
+ System.err.print("done.");
+ }
+ }
+}
diff --git a/settings.gradle b/settings.gradle
index 13eeafe..d729d0d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include 'desktop', 'android', 'core', 'assets'
+include 'desktop', 'android', 'core', 'assets', 'server'