Skip to content

Copy only req extra files if using compiled rules #6101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-0b9a472.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "Don't generate the unused files for the service endpoint provider when compiled endpoint rules are enabled (the default behavior). This lowers the overall size of the built JAR."
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected List<GeneratorTask> createTasks() throws Exception {
tasks.add(generateParams());
if (shouldGenerateCompiledEndpointRules()) {
tasks.add(generateDefaultProvider2());
tasks.add(new RulesEngineRuntimeGeneratorTask(generatorTaskParams));
tasks.add(new RulesEngineRuntimeLiteGeneratorTask(generatorTaskParams));
tasks.add(new RulesEngineRuntimeGeneratorTask2(generatorTaskParams));
} else {
tasks.add(generateDefaultProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import software.amazon.awssdk.utils.StringUtils;
import software.amazon.awssdk.utils.Validate;

public final class RulesEngineRuntimeGeneratorTask extends BaseGeneratorTasks {
public class RulesEngineRuntimeGeneratorTask extends BaseGeneratorTasks {
public static final String RUNTIME_CLASS_NAME = "WaitersRuntime";

private final String engineInternalClassDir;
Expand Down Expand Up @@ -63,7 +63,7 @@ protected List<GeneratorTask> createTasks() throws Exception {
return copyTasks;
}

private List<String> rulesEngineJavaFilePaths(Collection<String> runtimeEngineFiles) {
protected List<String> rulesEngineJavaFilePaths(Collection<String> runtimeEngineFiles) {
return runtimeEngineFiles.stream()
.filter(e -> e.endsWith(".java.resource"))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.codegen.emitters.tasks;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;

/** A version of {@link software.amazon.awssdk.codegen.emitters.tasks.RulesEngineRuntimeGeneratorTask} that copies a minimal
* set of the interpreter related classes. This set represents the only classes that need to be copied when compiled rules are
* enabled.
*
* @see CustomizationConfig#isEnableGenerateCompiledEndpointRules()
*/
public final class RulesEngineRuntimeLiteGeneratorTask extends RulesEngineRuntimeGeneratorTask {
// Note: leading slashes are important to disambiguate between files that share the same suffix
private static final List<String> FILES_TO_COPY = Stream.of("/Outputs.java.resource",
"/RegionOverride.java.resource",
"/Partition.java.resource",
"/PartitionDataProvider.java.resource",
"/AwsEndpointProviderUtils.java.resource",
"/Arn.java.resource",
"/Value.java.resource",
"/Identifier.java.resource",
"/EndpointAuthSchemeStrategy.java.resource",
"/EndpointAttributeProvider.java.resource",
"/EndpointAuthSchemeStrategyFactory.java.resource",
"/DefaultEndpointAuthSchemeStrategy.java.resource")
.collect(Collectors.toList());

public RulesEngineRuntimeLiteGeneratorTask(GeneratorTaskParams generatorTaskParams) {
super(generatorTaskParams);
}

protected List<String> rulesEngineJavaFilePaths(Collection<String> runtimeEngineFiles) {
return super.rulesEngineJavaFilePaths(runtimeEngineFiles)
.stream()
.filter(e -> FILES_TO_COPY.stream().anyMatch(e::endsWith))
.collect(Collectors.toList());
}
}
Loading