-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Go client codegen plugin to follow idiomatic plugin name
- Loading branch information
Steven Yuan
committed
Nov 6, 2023
1 parent
ea97698
commit af38939
Showing
6 changed files
with
68 additions
and
46 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
59 changes: 59 additions & 0 deletions
59
...thy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/GoClientCodegenPlugin.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,59 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.go.codegen; | ||
|
||
import java.util.logging.Logger; | ||
import software.amazon.smithy.build.PluginContext; | ||
import software.amazon.smithy.build.SmithyBuildPlugin; | ||
import software.amazon.smithy.codegen.core.SymbolProvider; | ||
import software.amazon.smithy.model.Model; | ||
import software.amazon.smithy.utils.SmithyInternalApi; | ||
|
||
/** | ||
* Plugin to trigger Go client code generation. | ||
*/ | ||
@SmithyInternalApi | ||
public class GoClientCodegenPlugin implements SmithyBuildPlugin { | ||
private static final Logger LOGGER = Logger.getLogger(GoClientCodegenPlugin.class.getName()); | ||
|
||
@Override | ||
public String getName() { | ||
return "go-client-codegen"; | ||
} | ||
|
||
@Override | ||
public void execute(PluginContext context) { | ||
String onlyBuild = System.getenv("SMITHY_GO_BUILD_API"); | ||
if (onlyBuild != null && !onlyBuild.isEmpty()) { | ||
String targetServiceId = GoSettings.from(context.getSettings()).getService().toString(); | ||
|
||
boolean found = false; | ||
for (String includeServiceId : onlyBuild.split(",")) { | ||
if (targetServiceId.startsWith(includeServiceId)) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
LOGGER.info("skipping " + targetServiceId); | ||
return; | ||
} | ||
} | ||
|
||
new CodegenVisitor(context).execute(); | ||
} | ||
|
||
/** | ||
* Creates a Go symbol provider. | ||
* | ||
* @param model The model to generate symbols for. | ||
* @param settings The Gosettings to use to create symbol provider | ||
* @return Returns the created provider. | ||
*/ | ||
public static SymbolProvider createSymbolProvider(Model model, GoSettings settings) { | ||
return new SymbolVisitor(model, settings); | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
...degen/src/main/resources/META-INF/services/software.amazon.smithy.build.SmithyBuildPlugin
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
software.amazon.smithy.go.codegen.GoClientCodegenPlugin | ||
software.amazon.smithy.go.codegen.GoCodegenPlugin |