aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2013-04-14 19:09:29 +0000
committerFlorian Dold <florian.dold@gmail.com>2013-04-14 19:09:29 +0000
commit3e7f0a0aefbd357bd10586c8bff9536ba1a73529 (patch)
treeac3bf0aa5530da26c076bfa7282c65f826433d5e
parent04e201c146bd83f9c14a35202c4896acdbe1b9bb (diff)
downloadgnunet-java-ext-3e7f0a0aefbd357bd10586c8bff9536ba1a73529.tar.gz
gnunet-java-ext-3e7f0a0aefbd357bd10586c8bff9536ba1a73529.zip
updated extension template build system
-rw-r--r--README5
-rwxr-xr-xbin/gnunet-ext3
-rwxr-xr-xbin/gnunet-greeting4
-rwxr-xr-xbin/gnunet-service-greeting4
-rw-r--r--build.gradle61
-rw-r--r--config/greeting.conf1
-rwxr-xr-xenvcfg9
-rw-r--r--src/org/gnunet/ext/GreetingService.java4
-rwxr-xr-xtools/build25
-rwxr-xr-xtools/update-msgtypes20
10 files changed, 70 insertions, 66 deletions
diff --git a/README b/README
index 06a2112..8d692ef 100644
--- a/README
+++ b/README
@@ -1,4 +1 @@
1Template directory for gnunet extensions. Template directory for gnunet extensions written in Java.
2
3tools/build: script to build the extension, if it adheres to the default folder structure
4tools/update-msgtypes: extract a mapping from message IDs to java classes from the source code
diff --git a/bin/gnunet-ext b/bin/gnunet-ext
index 8b9a826..f63f077 100755
--- a/bin/gnunet-ext
+++ b/bin/gnunet-ext
@@ -4,8 +4,7 @@
4 4
5BASEDIR=`dirname $0`/.. 5BASEDIR=`dirname $0`/..
6 6
7source $BASEDIR/envcfg 7CP="$BASEDIR/build-gradle/libs/*:$GNJ_HOME/*:$GNJ_DEPS/*"
8CP="$BASEDIR/build/:$BASEDIR/lib/*:$GNUNET_JAVA_CLASSPATH:$GNUNET_JAVA_DEPS/*"
9 8
10java -ea -cp "$CP" org.gnunet.ext.MyExt "$@" 9java -ea -cp "$CP" org.gnunet.ext.MyExt "$@"
11 10
diff --git a/bin/gnunet-greeting b/bin/gnunet-greeting
index b814b53..087cc76 100755
--- a/bin/gnunet-greeting
+++ b/bin/gnunet-greeting
@@ -4,7 +4,7 @@
4 4
5BASEDIR=`dirname $0`/.. 5BASEDIR=`dirname $0`/..
6 6
7source $BASEDIR/envcfg 7CP="$BASEDIR/build-gradle/libs/*:$GNJ_HOME/*:$GNJ_DEPS/*"
8 8
9java -ea -cp "$BASEDIR/build/:$BASEDIR/lib/*:$GNUNET_JAVA_CLASSPATH:$GNUNET_JAVA_DEPS/*" org.gnunet.ext.GreetingClient "$@" 9java -ea -cp $CP org.gnunet.ext.GreetingClient "$@"
10 10
diff --git a/bin/gnunet-service-greeting b/bin/gnunet-service-greeting
index 7b2dede..e9c7c1e 100755
--- a/bin/gnunet-service-greeting
+++ b/bin/gnunet-service-greeting
@@ -4,7 +4,7 @@
4 4
5BASEDIR=`dirname $0`/.. 5BASEDIR=`dirname $0`/..
6 6
7source $BASEDIR/envcfg 7CP="$BASEDIR/build-gradle/libs/*:$GNJ_HOME/*:$GNJ_DEPS/*"
8 8
9java -ea -cp "$BASEDIR/build/:$BASEDIR/lib/*:$GNUNET_JAVA_CLASSPATH:$GNUNET_JAVA_DEPS/*" org.gnunet.ext.GreetingService "$@" 9java -ea -cp "$CP" org.gnunet.ext.GreetingService "$@"
10 10
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..c789821
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,61 @@
1/*
2 buildfile for gradle (http://gradle.org/)
3*/
4
5apply plugin: 'java'
6
7buildDir = "$projectDir/build-gradle"
8
9if (null == System.getenv('GNJ_HOME')) {
10 throw new InvalidUserDataException('environment variable GNJ_HOME not set')
11}
12
13if (null == System.getenv('GNJ_DEPS')) {
14 throw new InvalidUserDataException('environment variable GNJ_DEPS not set')
15}
16
17repositories {
18 flatDir {
19 dirs "$System.env.GNJ_HOME", "$System.env.GNJ_DEPS"
20 }
21}
22
23dependencies {
24 compile name: 'gnunet-java'
25 compile name: 'guava', version: '12.0'
26}
27
28sourceSets {
29 main {
30 java {
31 srcDir 'src'
32 }
33 resources {
34 srcDir 'src'
35 }
36 }
37 test {
38 java {
39 srcDir 'test'
40 }
41 resources {
42 srcDir 'test'
43 }
44 }
45}
46
47compileJava.options.debugOptions.debugLevel = "source,lines,vars"
48
49/*
50TODO: should we really use the compile task for this?
51*/
52task msgtypes (type: JavaCompile) {
53 description = "Updates the index of GNUnet message types known to gnunet-java."
54 classpath = project.sourceSets.main.runtimeClasspath
55 source = files(project.sourceSets.main.allJava)
56 options.setCompilerArgs(["-processor", "org.gnunet.construct.MessageIdAnnotationProcessor",
57 "-proc:only",
58 "-s", "src"])
59 destinationDir = file("$buildDir/classes/main/")
60}
61
diff --git a/config/greeting.conf b/config/greeting.conf
index d4a01c5..86c93c3 100644
--- a/config/greeting.conf
+++ b/config/greeting.conf
@@ -1,3 +1,4 @@
1# this is an example configuration for the greeting service
1[greeting] 2[greeting]
2PORT = 3001 3PORT = 3001
3HOSTNAME = localhost 4HOSTNAME = localhost
diff --git a/envcfg b/envcfg
deleted file mode 100755
index ae5e782..0000000
--- a/envcfg
+++ /dev/null
@@ -1,9 +0,0 @@
1#!/bin/sh
2
3# location the the gnunet-java-jar
4#GNUNET_JAVA_CLASSPATH= # e.g. /home/<your-name>/gnunet-java/gnunet-java.jar
5GNUNET_JAVA_CLASSPATH="/home/dold/svn/gnunet-java/gnunet-java.jar"
6
7# location of gnunet-java's lib directory
8#GNUNET_JAVA_DEPS= # e.g. /home/<your-name>/gnunet-java/lib/
9GNUNET_JAVA_DEPS="/home/dold/svn/gnunet-java/lib/"
diff --git a/src/org/gnunet/ext/GreetingService.java b/src/org/gnunet/ext/GreetingService.java
index 4c917e6..ea68671 100644
--- a/src/org/gnunet/ext/GreetingService.java
+++ b/src/org/gnunet/ext/GreetingService.java
@@ -28,8 +28,8 @@ public class GreetingService {
28 28
29 @Override 29 @Override
30 public void run() { 30 public void run() {
31 final String bannedStr = getConfiguration().getValueString("greeting", "BANNED"); 31 final String bannedStr = getConfiguration().getValueString("greeting", "BANNED").or("");
32 final String banMessage = getConfiguration().getValueString("greeting", "BAN_MESSAGE"); 32 final String banMessage = getConfiguration().getValueString("greeting", "BAN_MESSAGE").or("banned");
33 final List<String> banned; 33 final List<String> banned;
34 if (bannedStr != null) { 34 if (bannedStr != null) {
35 banned = Arrays.asList(bannedStr.split(";")); 35 banned = Arrays.asList(bannedStr.split(";"));
diff --git a/tools/build b/tools/build
deleted file mode 100755
index 3ca8a76..0000000
--- a/tools/build
+++ /dev/null
@@ -1,25 +0,0 @@
1#!/bin/bash
2
3# environment variables:
4# $JFLAGS: additional flags passed to the java compiler
5
6BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
7
8source $BASEDIR/envcfg
9
10CLASSPATH="$BASEDIR/build/:$BASEDIR/lib/*:$GNUNET_JAVA_CLASSPATH:$GNUNET_JAVA_DEPS"
11
12echo "using classpath $CLASSPATH"
13
14# collect all source files
15SOURCES=`find "$BASEDIR/src/" "$BASEDIR/test/" -name "*.java"`
16
17mkdir -p $BASEDIR/build
18
19javac $JFLAGS -cp $CLASSPATH -d $BASEDIR/build/ $SOURCES
20
21cd "$BASEDIR/src/"
22
23# collect resources from src/ and copy to build/
24find "." \( -name "*.txt" -o -name "*.properties" \) \
25 -exec cp --parents '{}' "../build" \;
diff --git a/tools/update-msgtypes b/tools/update-msgtypes
deleted file mode 100755
index a294ce5..0000000
--- a/tools/update-msgtypes
+++ /dev/null
@@ -1,20 +0,0 @@
1#!/bin/bash
2
3BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
4SOURCES=$( mktemp "/tmp/gnunet-java-sources-XXX" )
5
6source $BASEDIR/envcfg
7
8CP="$BASEDIR/build/:$BASEDIR/lib/*:$GNUNET_JAVA_CLASSPATH:$GNUNET_JAVA_DEPS/*"
9
10# collect all source files
11find $BASEDIR/src/ $BASEDIR/test/ -name "*.java" > $SOURCES
12
13# run annotation processor
14javac -cp $CP -processor org.gnunet.construct.MessageIdAnnotationProcessor -proc:only -s src @$SOURCES
15
16if [ $? ] ; then
17 rm $SOURCES
18else
19 exit 1
20fi