-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: update dependency com.google.cloud:sdk-platform-java-config to …
…v3.36.1 (#2738) * deps: update dependency com.google.cloud:sdk-platform-java-config to v3.36.1 * chore: add program to regenerate reflect-config.json * chore: regenerate reflect-config.json for protobuf 1.68.0 --------- Co-authored-by: BenWhitehead <[email protected]>
- Loading branch information
1 parent
f195f55
commit eb320e1
Showing
10 changed files
with
277 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...oud-storage/src/test/java/com/google/cloud/storage/GenerateGrpcProtobufReflectConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.storage; | ||
|
||
import com.google.protobuf.AbstractMessage; | ||
import com.google.protobuf.GeneratedMessageV3; | ||
import com.google.protobuf.ProtocolMessageEnum; | ||
import io.github.classgraph.ClassGraph; | ||
import io.github.classgraph.ClassInfo; | ||
import io.github.classgraph.ScanResult; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public final class GenerateGrpcProtobufReflectConfig { | ||
|
||
public static void main(String[] args) throws IOException { | ||
try (ScanResult scanResult = | ||
new ClassGraph().enableAllInfo().acceptPackages("io.grpc").scan()) { | ||
String json = | ||
Stream.of( | ||
Stream.of( | ||
"{\n" | ||
+ " \"name\":\"org.apache.commons.logging.LogFactory\",\n" | ||
+ " \"allDeclaredFields\":true,\n" | ||
+ " \"allDeclaredMethods\":true,\n" | ||
+ " \"allDeclaredConstructors\": true\n" | ||
+ " }", | ||
"{\n" | ||
+ " \"name\":\"org.apache.commons.logging.impl.Jdk14Logger\",\n" | ||
+ " \"methods\":[{\"name\":\"<init>\",\"parameterTypes\":[\"java.lang.String\"] }]\n" | ||
+ " }", | ||
"{\n" | ||
+ " \"name\":\"org.apache.commons.logging.impl.LogFactoryImpl\",\n" | ||
+ " \"allDeclaredFields\":true,\n" | ||
+ " \"allDeclaredMethods\":true,\n" | ||
+ " \"methods\":[{\"name\":\"<init>\",\"parameterTypes\":[] }]\n" | ||
+ " }"), | ||
Stream.of( | ||
scanResult.getSubclasses(GeneratedMessageV3.class).stream(), | ||
scanResult.getSubclasses(AbstractMessage.Builder.class).stream(), | ||
scanResult.getAllEnums() | ||
.filter(ci -> ci.implementsInterface(ProtocolMessageEnum.class)) | ||
.stream()) | ||
.flatMap(s -> s) | ||
.map(ClassInfo::getName) | ||
.sorted() | ||
.map( | ||
name -> | ||
String.format( | ||
"{ \"name\": \"%s\", \"queryAllDeclaredConstructors\": true, \"queryAllPublicConstructors\": true, \"queryAllDeclaredMethods\": true, \"allPublicMethods\": true, \"allDeclaredClasses\": true, \"allPublicClasses\": true }", | ||
name))) | ||
.flatMap(s -> s) | ||
.collect(Collectors.joining(",\n ", "[\n ", "\n]\n")); | ||
String workingDirectory = System.getProperty("user.dir"); // should be google-cloud-storage | ||
String testResourcesPath = "src/test/resources"; | ||
String reflectConfigResourcePath = | ||
"META-INF/native-image/com/google/cloud/storage/reflect-config.json"; | ||
Path path = Paths.get(workingDirectory, testResourcesPath, reflectConfigResourcePath); | ||
System.err.println("Writing reflect-config.json at path: " + path); | ||
Files.write(path, json.getBytes(StandardCharsets.UTF_8)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.