File tree 15 files changed +37
-14
lines changed
src/main/proto/com/example/tutorial
testProjectJavaAndKotlin/src/test
15 files changed +37
-14
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import org.gradle.kotlin.dsl.provider.gradleKotlinDslOf
7
7
plugins {
8
8
java
9
9
idea
10
- id(" com.google.protobuf" ) version " 0.8.8-SNAPSHOT "
10
+ id(" com.google.protobuf" ) version " 0.8.8"
11
11
}
12
12
13
13
repositories {
@@ -34,10 +34,10 @@ dependencies {
34
34
// Extra proto source files besides the ones residing under
35
35
// "src/main".
36
36
protobuf(files(" lib/protos.tar.gz" ))
37
- protobuf(fileTree (" ext/" ))
37
+ protobuf(files (" ext/" ))
38
38
39
39
// Adding dependency for configuration from custom sourceSet
40
- " sampleProtobuf" (fileTree (" ext/" ))
40
+ " sampleProtobuf" (files (" ext/" ))
41
41
42
42
testCompile(" junit:junit:4.12" )
43
43
// Extra proto source files for test besides the ones residing under
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ dependencies {
31
31
// Extra proto source files besides the ones residing under
32
32
// "src/main".
33
33
protobuf files(" lib/protos.tar.gz" )
34
- protobuf fileTree (" ext/" )
34
+ protobuf files (" ext/" )
35
35
36
36
testCompile ' junit:junit:4.12'
37
37
// Extra proto source files for test besides the ones residing under
Original file line number Diff line number Diff line change @@ -20,9 +20,11 @@ public static List<MessageLite> getDefaultInstances() {
20
20
list .add (More .MoreMsg .getDefaultInstance ());
21
21
list .add (More .Foo .getDefaultInstance ());
22
22
// from ext/test1.proto
23
- list .add (Test1 .Test1Msg .getDefaultInstance ());
23
+ list .add (test1 .Test1 .Test1Msg .getDefaultInstance ());
24
+ // from ext/ext1/test1.proto
25
+ list .add (ext1 .Ext1Test1 .Ext1Test1Msg .getDefaultInstance ());
24
26
// from ext/test2.proto
25
- list .add (Test2 .Test2Msg .getDefaultInstance ());
27
+ list .add (test2 . Test2 .Test2Msg .getDefaultInstance ());
26
28
return list ;
27
29
}
28
30
}
Original file line number Diff line number Diff line change 4
4
public class FooTest {
5
5
@ org .junit .Test
6
6
public void testMainProtos () {
7
- assertEquals (11 , Foo .getDefaultInstances ().size ());
7
+ assertEquals (12 , Foo .getDefaultInstances ().size ());
8
8
}
9
9
10
10
@ org .junit .Test
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def protobufDep = 'com.google.protobuf:protobuf-java:3.0.0'
28
28
29
29
dependencies {
30
30
protobuf files(" lib/protos.tar.gz" )
31
- protobuf fileTree (" ext/" )
31
+ protobuf files (" ext/" )
32
32
testProtobuf files(" lib/protos-test.tar.gz" )
33
33
34
34
compile protobufDep
Original file line number Diff line number Diff line change
1
+ syntax = "proto3" ;
2
+
3
+ option java_package = "ext1" ;
4
+ option java_outer_classname = "Ext1Test1" ;
5
+
6
+ message Ext1Test1Msg {
7
+ string bar = 1 ;
8
+ }
Original file line number Diff line number Diff line change 7
7
*/
8
8
syntax = "proto3" ;
9
9
10
+ option java_package = "test1" ;
11
+
10
12
message Test1Msg {
11
13
string bar = 1 ;
12
14
}
Original file line number Diff line number Diff line change 1
1
syntax = "proto3" ;
2
2
3
+ option java_package = "test2" ;
4
+
3
5
message Test2Msg {
4
6
string bar = 1 ;
5
7
}
Original file line number Diff line number Diff line change @@ -4,10 +4,16 @@ option java_package = "com.example.tutorial";
4
4
option java_outer_classname = "OuterSample" ;
5
5
option java_multiple_files = true ;
6
6
7
+ import "test1.proto" ;
8
+ import "ext1/test1.proto" ;
9
+ import "test2.proto" ;
7
10
8
11
message Msg {
9
12
string foo = 1 ;
10
13
SecondMsg blah = 2 ;
14
+ Test1Msg test1 = 3 ;
15
+ Test2Msg test2 = 4 ;
16
+ Ext1Test1Msg ext1test1 = 5 ;
11
17
}
12
18
13
19
message SecondMsg {
Original file line number Diff line number Diff line change @@ -5,6 +5,6 @@ public class CallKotlinClass {
5
5
@ org .junit .Test
6
6
public void testMainProtosKotlin () {
7
7
// call kotlin class from java
8
- assertEquals (11 , new KotlinFoo ().getDefaultInstances ().size ());
8
+ assertEquals (12 , new KotlinFoo ().getDefaultInstances ().size ());
9
9
}
10
10
}
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ import org.junit.Assert.assertTrue
4
4
class CallJavaClass {
5
5
@org.junit.Test
6
6
fun testCallJavaFoo () {
7
- assertEquals(11 , Foo .getDefaultInstances().size)
7
+ assertEquals(12 , Foo .getDefaultInstances().size)
8
8
}
9
9
}
Original file line number Diff line number Diff line change @@ -18,9 +18,11 @@ class KotlinFoo {
18
18
list.add(More .MoreMsg .getDefaultInstance());
19
19
list.add(More .Foo .getDefaultInstance());
20
20
// from ext/test1.proto
21
- list.add(Test1 .Test1Msg .getDefaultInstance());
21
+ list.add(test1.Test1 .Test1Msg .getDefaultInstance());
22
+ // from ext/ext1/test1.proto
23
+ list.add(ext1.Ext1Test1 .Ext1Test1Msg .getDefaultInstance());
22
24
// from ext/test2.proto
23
- list.add(Test2 .Test2Msg .getDefaultInstance());
25
+ list.add(test2. Test2 .Test2Msg .getDefaultInstance());
24
26
return list
25
27
}
26
28
}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import org.junit.Assert.assertTrue
4
4
class KotlinFooTest {
5
5
@org.junit.Test
6
6
fun testMainProtos () {
7
- assertEquals(11 , KotlinFoo ().getDefaultInstances().size)
7
+ assertEquals(12 , KotlinFoo ().getDefaultInstances().size)
8
8
}
9
9
10
10
@org.junit.Test
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ val protobufDep = "com.google.protobuf:protobuf-java:3.0.0"
60
60
61
61
dependencies {
62
62
protobuf(files(" lib/protos.tar.gz" ))
63
- protobuf(fileTree (" ext/" ))
63
+ protobuf(files (" ext/" ))
64
64
testProtobuf(files(" lib/protos-test.tar.gz" ))
65
65
66
66
compile(protobufDep)
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ targetCompatibility = JavaVersion.VERSION_1_7
12
12
13
13
dependencies {
14
14
compile ' com.google.protobuf:protobuf-lite:3.0.0'
15
+ protobuf files(" ext/" )
15
16
testCompile ' junit:junit:4.12'
16
17
}
17
18
You can’t perform that action at this time.
0 commit comments