* adding package_java to build java files. collasping all client messages into client_container.java

This commit is contained in:
Seth Call 2012-08-05 23:59:22 -05:00
parent 00dd36a8f7
commit 316c225cac
7 changed files with 65 additions and 5 deletions

3
build
View File

@ -9,7 +9,8 @@ rm -rf $TARGET
mkdir $TARGET
# find all protocol buffer files in src directory
PROTO_FILES=`find src -name *.proto`
#PROTO_FILES=`find src -name *.proto`
PROTO_FILES=src/client_container.proto
# make variables available to sub-scripts
export SRC TARGET PROTO_FILES

View File

@ -3,9 +3,12 @@
# this build file uses protoc to build all protocol buffers
# http://code.google.com/p/protobuf/downloads/list
TARGET_CPP="$TARGET/cpp"
TARGET_JAVA="$TARGET/java"
mkdir -p "$TARGET_CPP"
mkdir -p "$TARGET_JAVA"
# if you don't want to put protoc on the command line,
# then set a PROTOC environment variable
@ -20,3 +23,5 @@ set -e
echo "building cpp protocol buffers"
$PROTOC $PROTO_FILES --cpp_out=$TARGET_CPP --proto_path=$SRC
echo "building java protocol buffers"
$PROTOC $PROTO_FILES --java_out=$TARGET_JAVA --proto_path=$SRC

10
ivy.xml Normal file
View File

@ -0,0 +1,10 @@
<ivy-module version="1.0">
<info organisation="pgmigrate" module="java"/>
<configurations>
<conf name="default"/>
<conf name="test"/>
</configurations>
<dependencies>
<dependency org="com.google.protobuf" name="protobuf-java" rev="2.4.1"/>
</dependencies>
</ivy-module>

8
ivysettings.xml Normal file
View File

@ -0,0 +1,8 @@
<ivysettings>
<settings defaultResolver="maven"/>
<resolvers>
<chain name="maven">
<ibiblio name="ibiblio" m2compatible="true" />
</chain>
</resolvers>
</ivysettings>

16
package_java Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
# not yet integrated into any formal build step.
# usage: after you've run ./build, run ./package_java to generate a jar
set -e
echo "packaging java"
# retrieve protocol buffer dependency
java -jar $IVY -sync -retrieve "target/lib/[conf]/[artifact]-[type].[ext]"
# compile java file generated by protocol buffrs
javac -cp target/lib/default/protobuf-java-jar.jar target/java/jampb/ClientContainer.java
pushd target/java/jampb
# create jar with all classes generated by javac
jar cvf jampb-clientcontainer.jar `find . -name \*.class`
popd

View File

@ -0,0 +1,24 @@
package jampb;
message ClientMessage {
enum Type { LOGIN = 1; JOIN_JAM_SESSION = 2;}
// Identifies which inner message is filled in
required Type type = 1;
required string target = 2;
// One of the following messages can be populated
optional Login login = 100;
optional JoinJamSession join_jam_session = 101;
}
message JoinJamSession {
optional string user_token = 1; // token provided from previous login
optional string jam_session_id = 2; // id for jam_session
}
message Login {
optional string username = 1; // username
optional string token = 2; // a token provided by the server that validates this user
}

View File

@ -1,4 +0,0 @@
message Login {
optional string username = 1; // username
optional string token = 2; // a token provided by the server that validates this user
}