Skip to content
This repository was archived by the owner on Apr 26, 2025. It is now read-only.

Commit 70f78c2

Browse files
committed
Added integration test for test sources generation with javalite
1 parent 6b6c1dd commit 70f78c2

File tree

8 files changed

+167
-13
lines changed

8 files changed

+167
-13
lines changed

src/it/TEST-36/invoker.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
2+
# Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
1515
#
1616

1717
# An optional description for this build job to be included in the build reports.
18-
invoker.description = Verifies that Java generation works for lite runtime, using additional generator options
18+
invoker.description=Verifies that Java generation works for lite runtime, using additional generator options
1919

2020
# A comma or space separated list of goals/phases to execute, may
2121
# specify an empty list to execute the default goal of the IT project
22-
invoker.goals = clean compile
22+
invoker.goals=clean compile

src/it/TEST-36/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<!--
4-
~ Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
4+
~ Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
55
~
66
~ Licensed under the Apache License, Version 2.0 (the "License");
77
~ you may not use this file except in compliance with the License.
@@ -32,9 +32,9 @@
3232
<version>1.0.0</version>
3333

3434
<name>Integration Test 36</name>
35-
35+
3636
<properties>
37-
<protobufJavaArtifact>protobuf-javalite</protobufJavaArtifact>
37+
<protobufJavaArtifact>protobuf-javalite</protobufJavaArtifact>
3838
</properties>
3939

4040
<build>
@@ -43,7 +43,6 @@
4343
<groupId>org.xolstice.maven.plugins</groupId>
4444
<artifactId>protobuf-maven-plugin</artifactId>
4545
<version>@project.version@</version>
46-
<extensions>true</extensions>
4746
<executions>
4847
<execution>
4948
<goals>

src/it/TEST-37/invoker.properties

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# An optional description for this build job to be included in the build reports.
18+
invoker.description=Verifies that Java generation works for test protos and lite runtime, using additional generator options
19+
20+
# A comma or space separated list of goals/phases to execute, may
21+
# specify an empty list to execute the default goal of the IT project
22+
invoker.goals=clean test-compile

src/it/TEST-37/pom.xml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
~ Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
5+
~
6+
~ Licensed under the Apache License, Version 2.0 (the "License");
7+
~ you may not use this file except in compliance with the License.
8+
~ You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<groupId>org.xolstice.maven.plugins.protobuf.its</groupId>
27+
<artifactId>it-parent</artifactId>
28+
<version>1.0.0</version>
29+
</parent>
30+
31+
<artifactId>test-37</artifactId>
32+
<version>1.0.0</version>
33+
34+
<name>Integration Test 37</name>
35+
36+
<properties>
37+
<protobufJavaArtifact>protobuf-javalite</protobufJavaArtifact>
38+
</properties>
39+
40+
<build>
41+
<plugins>
42+
<plugin>
43+
<groupId>org.xolstice.maven.plugins</groupId>
44+
<artifactId>protobuf-maven-plugin</artifactId>
45+
<version>@project.version@</version>
46+
<executions>
47+
<execution>
48+
<goals>
49+
<goal>test-compile</goal>
50+
</goals>
51+
<configuration>
52+
<javaOptions>lite</javaOptions>
53+
</configuration>
54+
</execution>
55+
</executions>
56+
<configuration>
57+
<protocArtifact>
58+
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
59+
</protocArtifact>
60+
</configuration>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
</project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
syntax = "proto3";
18+
19+
option java_package = "test";
20+
option java_outer_classname = "TestProtos";
21+
option optimize_for = SPEED;
22+
23+
message TestMessage {
24+
message NestedMessage {
25+
int32 bb = 1;
26+
}
27+
28+
enum NestedEnum {
29+
FOO = 0;
30+
BAR = 1;
31+
BAZ = 2;
32+
}
33+
34+
// Singular
35+
int32 optional_int32 = 1;
36+
}

src/it/TEST-37/verify.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/java');
18+
assert outputDirectory.exists();
19+
assert outputDirectory.isDirectory();
20+
21+
generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
22+
assert generatedJavaFile.exists();
23+
assert generatedJavaFile.isFile();
24+
25+
content = generatedJavaFile.text;
26+
assert content.contains('package test');
27+
assert content.contains('class Test');
28+
assert content.contains('class TestMessage');
29+
assert content.contains('com.google.protobuf.GeneratedMessageLite');
30+
31+
return true;

src/main/java/org/xolstice/maven/plugin/protobuf/ProtocCompileMojo.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.xolstice.maven.plugin.protobuf;
22

33
/*
4-
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
4+
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -47,10 +47,11 @@ public final class ProtocCompileMojo extends AbstractProtocCompileMojo {
4747
defaultValue = "${project.build.directory}/generated-sources/protobuf/java"
4848
)
4949
private File outputDirectory;
50-
50+
5151
/**
5252
* Additional comma-separated options to be passed to the Java generator.
5353
* <b>Cannot</b> contain colon (<tt>:</tt>) symbols.
54+
*
5455
* @since 0.7.0
5556
*/
5657
@Parameter(
@@ -67,7 +68,7 @@ protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
6768
}
6869
protocBuilder.setJavaOutputDirectory(getOutputDirectory());
6970
}
70-
71+
7172
@Override
7273
protected File getOutputDirectory() {
7374
return outputDirectory;

src/main/java/org/xolstice/maven/plugin/protobuf/ProtocTestCompileMojo.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.xolstice.maven.plugin.protobuf;
22

33
/*
4-
* Copyright (c) 2018 Maven Protocol Buffers Plugin Authors. All rights reserved.
4+
* Copyright (c) 2019 Maven Protocol Buffers Plugin Authors. All rights reserved.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -49,10 +49,11 @@ public final class ProtocTestCompileMojo extends AbstractProtocTestCompileMojo {
4949
defaultValue = "${project.build.directory}/generated-test-sources/protobuf/java"
5050
)
5151
private File outputDirectory;
52-
52+
5353
/**
5454
* Additional comma-separated options to be passed to the Java generator.
5555
* <b>Cannot</b> contain colon (<tt>:</tt>) symbols.
56+
*
5657
* @since 0.7.0
5758
*/
5859
@Parameter(
@@ -65,7 +66,7 @@ public final class ProtocTestCompileMojo extends AbstractProtocTestCompileMojo {
6566
protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) {
6667
super.addProtocBuilderParameters(protocBuilder);
6768
if (javaOptions != null) {
68-
protocBuilder.setNativePluginParameter(javaOptions);
69+
protocBuilder.setNativePluginParameter(javaOptions);
6970
}
7071
protocBuilder.setJavaOutputDirectory(getOutputDirectory());
7172
// We need to add project output directory to the protobuf import paths,

0 commit comments

Comments
 (0)