Skip to content

Commit abf18e0

Browse files
committed
remove discovery doc output from get-client-lib
Local discovery introduced intermediate discovery doc output in get-client-lib due to the removal of gen-discovery-doc. This change reverts to the previous behavior.
1 parent 653dfe5 commit abf18e0

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

endpoints-framework-tools/src/main/java/com/google/api/server/spi/tools/GetClientLibAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public Object getClientLib(URL[] classPath, String language, String outputDirPat
8282
String warPath, List<String> serviceClassNames, String buildSystem, boolean debug)
8383
throws ClassNotFoundException, IOException, ApiConfigException {
8484
Map<String, String> discoveryDocs = new GetDiscoveryDocAction().getDiscoveryDoc(
85-
classPath, outputDirPath, warPath, serviceClassNames, debug);
85+
classPath, outputDirPath, warPath, serviceClassNames, debug, false /* outputToDisk */);
8686
for (Map.Entry<String, String> entry : discoveryDocs.entrySet()) {
8787
new GenClientLibAction().genClientLib(language, outputDirPath, entry.getValue(), buildSystem);
8888
}

endpoints-framework-tools/src/main/java/com/google/api/server/spi/tools/GetDiscoveryDocAction.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ public boolean execute() throws ClassNotFoundException, IOException, ApiConfigEx
9393
public Map<String, String> getDiscoveryDoc(URL[] classPath, String outputDirPath,
9494
String warPath, List<String> serviceClassNames, boolean debug)
9595
throws ClassNotFoundException, IOException, ApiConfigException {
96+
return getDiscoveryDoc(classPath, outputDirPath, warPath, serviceClassNames, debug, true);
97+
}
98+
99+
/**
100+
* Generates a Java client library for an API. Combines the steps of generating API
101+
* configuration, generating Discovery doc and generating client library into one.
102+
* @param classPath Class path to load service classes and their dependencies
103+
* @param outputDirPath Directory to write output files into
104+
* @param warPath Directory or file containing a WAR layout
105+
* @param serviceClassNames Array of service class names of the API
106+
* @param debug Whether or not to output intermediate output files
107+
* @param outputToDisk Whether or not to output discovery docs to disk
108+
*/
109+
public Map<String, String> getDiscoveryDoc(URL[] classPath, String outputDirPath,
110+
String warPath, List<String> serviceClassNames, boolean debug, boolean outputToDisk)
111+
throws ClassNotFoundException, IOException, ApiConfigException {
96112
File outputDir = new File(outputDirPath);
97113
if (!outputDir.isDirectory()) {
98114
throw new IllegalArgumentException(outputDirPath + " is not a directory");
@@ -120,9 +136,11 @@ public Map<String, String> getDiscoveryDoc(URL[] classPath, String outputDirPath
120136
String discoveryDocFilePath =
121137
outputDir + "/" + key.getName() + "-" + key.getVersion() + "-rest.discovery";
122138
String docString = writer.writeValueAsString(entry.getValue());
123-
Files.write(docString, new File(discoveryDocFilePath), UTF_8);
139+
if (outputToDisk) {
140+
Files.write(docString, new File(discoveryDocFilePath), UTF_8);
141+
System.out.println("API Discovery Document written to " + discoveryDocFilePath);
142+
}
124143
builder.put(discoveryDocFilePath, docString);
125-
System.out.println("API Discovery Document written to " + discoveryDocFilePath);
126144
}
127145
return builder.build();
128146
}

0 commit comments

Comments
 (0)