Skip to content

Commit 559ce87

Browse files
authored
Merge branch 'master' into remove-warnings
2 parents 65fc158 + d335340 commit 559ce87

6 files changed

Lines changed: 42 additions & 13 deletions

File tree

DEVELOPMENT.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,40 @@
1515
## Running the Plugin
1616

1717
1. Clone [googleapis](https://github.com/googleapis/googleapis) and
18-
[gapic-showcase](https://github.com/googleapis/gapic-showcase/) and install
19-
protoc.
18+
[gapic-showcase](https://github.com/googleapis/gapic-showcase/).
2019

2120
2. Copy the protos from Showcase into googleapis/google/showcase.
2221

2322
```sh
24-
cp gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta
23+
mkdir googleapis/google/showcase
24+
cp -r gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta1
2525
```
2626

27-
3. Add the new microgenerator rules to the protobuf directory's `BUILD.bazel`
28-
file as follows:
27+
3. Add the new microgenerator rules to
28+
`googleapis/google/showcase/v1beta1/BUILD.bazel` file as follows:
2929

3030
```python
3131
load(
3232
"@com_google_googleapis_imports//:imports.bzl",
3333
# Existing rules here.
3434
"java_gapic_assembly_gradle_pkg",
3535
"java_gapic_library",
36+
"java_proto_library",
37+
"proto_library_with_info",
38+
)
39+
40+
proto_library_with_info(
41+
name = "showcase_proto_with_info",
42+
deps = [
43+
":showcase_proto",
44+
],
45+
)
46+
47+
java_proto_library(
48+
name = "showcase_java_proto",
49+
deps = [
50+
"showcase_proto",
51+
],
3652
)
3753
3854
# This should either replace the existing monolith target or have a unique name

src/main/java/com/google/api/generator/gapic/protoparser/BatchingSettingsConfigParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.common.base.Strings;
2121
import java.io.File;
2222
import java.io.IOException;
23+
import java.nio.charset.StandardCharsets;
2324
import java.nio.file.Files;
2425
import java.nio.file.Paths;
2526
import java.util.ArrayList;
@@ -69,7 +70,9 @@ static Optional<List<GapicBatchingSettings>> parse(String gapicYamlConfigFilePat
6970
String fileContents = null;
7071

7172
try {
72-
fileContents = new String(Files.readAllBytes(Paths.get(gapicYamlConfigFilePath)));
73+
fileContents =
74+
new String(
75+
Files.readAllBytes(Paths.get(gapicYamlConfigFilePath)), StandardCharsets.UTF_8);
7376
} catch (IOException e) {
7477
return Optional.empty();
7578
}
@@ -104,7 +107,7 @@ private static Optional<List<GapicBatchingSettings>> parseFromMap(Map<String, Ob
104107
batchingOuterYamlConfig.containsKey(YAML_KEY_DESCRIPTOR),
105108
String.format(
106109
"%s key expected but not found for method %s",
107-
YAML_KEY_DESCRIPTOR, (String) methodYamlConfig.get(YAML_KEY_NAME)));
110+
YAML_KEY_DESCRIPTOR, methodYamlConfig.get(YAML_KEY_NAME)));
108111

109112
// Parse the threshold values first.
110113
Map<String, Object> batchingYamlConfig =

src/main/java/com/google/api/generator/gapic/protoparser/GapicLanguageSettingsParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.common.base.Strings;
2020
import java.io.File;
2121
import java.io.IOException;
22+
import java.nio.charset.StandardCharsets;
2223
import java.nio.file.Files;
2324
import java.nio.file.Paths;
2425
import java.util.Map;
@@ -48,7 +49,9 @@ static Optional<GapicLanguageSettings> parse(String gapicYamlConfigFilePath) {
4849
String fileContents = null;
4950

5051
try {
51-
fileContents = new String(Files.readAllBytes(Paths.get(gapicYamlConfigFilePath)));
52+
fileContents =
53+
new String(
54+
Files.readAllBytes(Paths.get(gapicYamlConfigFilePath)), StandardCharsets.UTF_8);
5255
} catch (IOException e) {
5356
return Optional.empty();
5457
}

src/main/java/com/google/api/generator/gapic/protoparser/GapicLroRetrySettingsParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.common.base.Strings;
2020
import java.io.File;
2121
import java.io.IOException;
22+
import java.nio.charset.StandardCharsets;
2223
import java.nio.file.Files;
2324
import java.nio.file.Paths;
2425
import java.util.ArrayList;
@@ -56,7 +57,9 @@ static Optional<List<GapicLroRetrySettings>> parse(String gapicYamlConfigFilePat
5657
String fileContents = null;
5758

5859
try {
59-
fileContents = new String(Files.readAllBytes(Paths.get(gapicYamlConfigFilePath)));
60+
fileContents =
61+
new String(
62+
Files.readAllBytes(Paths.get(gapicYamlConfigFilePath)), StandardCharsets.UTF_8);
6063
} catch (IOException e) {
6164
return Optional.empty();
6265
}

src/main/java/com/google/api/generator/gapic/protoparser/ServiceYamlParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.protobuf.util.JsonFormat;
2222
import java.io.File;
2323
import java.io.IOException;
24+
import java.nio.charset.StandardCharsets;
2425
import java.nio.file.Files;
2526
import java.nio.file.Paths;
2627
import java.util.LinkedHashMap;
@@ -37,7 +38,8 @@ public static Optional<com.google.api.Service> parse(String serviceYamlFilePath)
3738

3839
String fileContents = null;
3940
try {
40-
fileContents = new String(Files.readAllBytes(Paths.get(serviceYamlFilePath)));
41+
fileContents =
42+
new String(Files.readAllBytes(Paths.get(serviceYamlFilePath)), StandardCharsets.UTF_8);
4143
} catch (IOException e) {
4244
return Optional.empty();
4345
}

src/main/java/com/google/api/generator/gapic/protowriter/Writer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
2525
import com.google.protobuf.util.JsonFormat;
2626
import java.io.IOException;
27+
import java.nio.charset.StandardCharsets;
2728
import java.util.List;
2829
import java.util.jar.JarEntry;
2930
import java.util.jar.JarOutputStream;
@@ -61,7 +62,7 @@ public static CodeGeneratorResponse write(
6162
JarEntry jarEntry = new JarEntry(String.format("%s/%s.java", path, className));
6263
try {
6364
jos.putNextEntry(jarEntry);
64-
jos.write(code.getBytes());
65+
jos.write(code.getBytes(StandardCharsets.UTF_8));
6566
} catch (IOException e) {
6667
throw new GapicWriterException(
6768
String.format(
@@ -80,7 +81,7 @@ public static CodeGeneratorResponse write(
8081
JarEntry jarEntry = new JarEntry(String.format("%s/package-info.java", path));
8182
try {
8283
jos.putNextEntry(jarEntry);
83-
jos.write(code.getBytes());
84+
jos.write(code.getBytes(StandardCharsets.UTF_8));
8485
} catch (IOException e) {
8586
throw new GapicWriterException("Could not write code for package-info.java");
8687
}
@@ -90,7 +91,8 @@ public static CodeGeneratorResponse write(
9091
jarEntry = new JarEntry(String.format("%s/gapic_metadata.json", path));
9192
try {
9293
jos.putNextEntry(jarEntry);
93-
jos.write(JsonFormat.printer().print(context.gapicMetadata()).getBytes());
94+
jos.write(
95+
JsonFormat.printer().print(context.gapicMetadata()).getBytes(StandardCharsets.UTF_8));
9496
} catch (IOException e) {
9597
throw new GapicWriterException("Could not write gapic_metadata.json");
9698
}

0 commit comments

Comments
 (0)