Skip to content

Commit 7aa0fff

Browse files
author
vishrgup
committed
Adding protobuf to java converter
0 parents  commit 7aa0fff

File tree

11 files changed

+278
-0
lines changed

11 files changed

+278
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
target/
2+
pom.xml.tag
3+
pom.xml.releaseBackup
4+
pom.xml.versionsBackup
5+
pom.xml.next
6+
release.properties
7+
*.iml
8+
.idea/

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org>
25+

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Protostuff multi-module project code generation example
2+
3+
This example shows how to import message declarations from `proto` file that is in another module.
4+
5+
1. Module `common` contains declaration of `KeyValue` message in the [common.proto](common/src/main/resources/common.proto).
6+
2. Module `foo` uses `KeyValue` from [common.proto](common/src/main/resources/common.proto), see [foo.proto](foo/src/main/resources/foo.proto).
7+
"# protobuf-multimodule-java-converter"

build/checkout-commit-hash.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
if [ ! -z "$COMMIT_HASH" ]
4+
then
5+
echo "Checking out $COMMIT_HASH"
6+
git checkout $COMMIT_HASH
7+
exit ${?}
8+
else
9+
echo "Error: no commit hash to checkout. Please set COMMIT_HASH."
10+
exit 1
11+
fi

build/invoke-sbt.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
export SPARK_LOCAL_IP=127.0.0.1
4+
DESIRED_JAVA_OPTS="-Xms2g -Xmx4g -Xss2m -XX:MaxMetaspaceSize=2g"
5+
# Setting java options to two different environment variables to be compatible with
6+
# different versions of the SBT launcher script
7+
JAVA_OPTS=${DESIRED_JAVA_OPTS} JVM_OPTS=${DESIRED_JAVA_OPTS} sbt "$@"

common/pom.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>com.company.json</groupId>
7+
<artifactId>converter</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>common</artifactId>
14+
15+
<build>
16+
<plugins>
17+
<plugin>
18+
<groupId>org.apache.maven.plugins</groupId>
19+
<artifactId>maven-compiler-plugin</artifactId>
20+
<version>3.7.0</version>
21+
<configuration>
22+
<source>1.6</source>
23+
<target>1.6</target>
24+
</configuration>
25+
</plugin>
26+
<plugin>
27+
<groupId>org.xolstice.maven.plugins</groupId>
28+
<artifactId>protobuf-maven-plugin</artifactId>
29+
<version>0.5.1</version>
30+
<configuration>
31+
<protocExecutable>C:/Users/vishrgup/Downloads/protoc-3.6.0-win32/bin/protoc.exe</protocExecutable>
32+
</configuration>
33+
<executions>
34+
<execution>
35+
<goals>
36+
<goal>compile</goal>
37+
<goal>test-compile</goal>
38+
</goals>
39+
</execution>
40+
</executions>
41+
</plugin>
42+
</plugins>
43+
</build>
44+
45+
<pluginRepositories>
46+
<pluginRepository>
47+
<id>dtrott</id>
48+
<url>http://maven.davidtrott.com/repository</url>
49+
</pluginRepository>
50+
</pluginRepositories>
51+
52+
<dependencies>
53+
<!-- https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java -->
54+
<dependency>
55+
<groupId>com.google.protobuf</groupId>
56+
<artifactId>protobuf-java</artifactId>
57+
<version>3.6.0</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>com.google.protobuf</groupId>
61+
<artifactId>protobuf-parent</artifactId>
62+
<version>3.6.0</version>
63+
<type>pom</type>
64+
</dependency>
65+
</dependencies>
66+
67+
</project>

common/src/main/proto/common.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package common;
2+
3+
option optimize_for = LITE_RUNTIME;
4+
option java_package = "io.protostuff.example.multimodule.common";
5+
6+
message KeyValue {
7+
required string key = 1;
8+
optional string value = 2;
9+
}

foo/pom.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>com.company.json</groupId>
7+
<artifactId>converter</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>foo</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>com.google.protobuf</groupId>
17+
<artifactId>protobuf-java</artifactId>
18+
</dependency>
19+
20+
<dependency>
21+
<groupId>junit</groupId>
22+
<artifactId>junit</artifactId>
23+
<scope>test</scope>
24+
</dependency>
25+
</dependencies>
26+
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>com.google.protobuf.tools</groupId>
31+
<artifactId>maven-protoc-plugin</artifactId>
32+
</plugin>
33+
</plugins>
34+
</build>
35+
36+
</project>

foo/src/main/resources/foo.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package foo;
2+
3+
import "common.proto";
4+
5+
option optimize_for = LITE_RUNTIME;
6+
option java_package = "io.protostuff.example.multimodule.foo";
7+
8+
message FooRequest {
9+
repeated common.KeyValue properties = 1;
10+
}

pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.company.json</groupId>
6+
<artifactId>converter</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
9+
<packaging>pom</packaging>
10+
<name>comverter</name>
11+
12+
<modules>
13+
<!--<module>schema</module>-->
14+
<module>common</module>
15+
</modules>
16+
17+
<dependencies>
18+
<!-- https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java -->
19+
<dependency>
20+
<groupId>com.google.protobuf</groupId>
21+
<artifactId>protobuf-java</artifactId>
22+
<version>3.6.0</version>
23+
</dependency>
24+
<dependency>
25+
<groupId>com.google.protobuf</groupId>
26+
<artifactId>protobuf-parent</artifactId>
27+
<version>3.6.0</version>
28+
<type>pom</type>
29+
</dependency>
30+
</dependencies>
31+
32+
</project>

0 commit comments

Comments
 (0)