Skip to content

Various cleanup and removing unused stuff #782

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

Merged
merged 1 commit into from
Oct 26, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,15 @@ public void execute() throws MojoExecutionException {
this.testsDirectory = Paths.get(outputDirectory).resolve("generated-test-sources").resolve("sdk-tests");

findModelRoots().forEach(p -> {
try {
getLog().info("Loading from: " + p.toString());
generateCode(C2jModels.builder()
.applyMutation(b -> loadCodeGenConfig(p).ifPresent(b::codeGenConfig))
.customizationConfig(loadCustomizationConfig(p))
.serviceModel(loadServiceModel(p))
.waitersModel(loadWaiterModel(p))
.paginatorsModel(loadPaginatorModel(p))
.examplesModel(loadExamplesModel(p))
.build());
} catch (MojoExecutionException e) {
throw new RuntimeException(e);
}
getLog().info("Loading from: " + p.toString());
generateCode(C2jModels.builder()
.applyMutation(b -> loadCodeGenConfig(p).ifPresent(b::codeGenConfig))
.customizationConfig(loadCustomizationConfig(p))
.serviceModel(loadServiceModel(p))
.waitersModel(loadWaiterModel(p))
.paginatorsModel(loadPaginatorModel(p))
.examplesModel(loadExamplesModel(p))
.build());
});
project.addCompileSourceRoot(sourcesDirectory.toFile().getAbsolutePath());
project.addTestCompileSourceRoot(testsDirectory.toFile().getAbsolutePath());
Expand Down Expand Up @@ -120,11 +116,13 @@ private Optional<BasicCodeGenConfig> loadCodeGenConfig(Path root) {
}

private CustomizationConfig loadCustomizationConfig(Path root) {
return loadOptionalModel(CustomizationConfig.class, root.resolve(CUSTOMIZATION_CONFIG_FILE))
.orElse(CustomizationConfig.create());
return ModelLoaderUtils.loadOptionalModel(CustomizationConfig.class,
root.resolve(CUSTOMIZATION_CONFIG_FILE).toFile(),
true)
.orElse(CustomizationConfig.create());
}

private ServiceModel loadServiceModel(Path root) throws MojoExecutionException {
private ServiceModel loadServiceModel(Path root) {
return loadRequiredModel(ServiceModel.class, root.resolve(MODEL_FILE));
}

Expand All @@ -143,7 +141,7 @@ private Paginators loadPaginatorModel(Path root) {
/**
* Load required model from the project resources.
*/
private <T> T loadRequiredModel(Class<T> clzz, Path location) throws MojoExecutionException {
private <T> T loadRequiredModel(Class<T> clzz, Path location) {
return ModelLoaderUtils.loadModel(clzz, location.toFile());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public static Metadata constructMetadata(ServiceModel serviceModel,
.withTransformPackageName(namingStrategy.getTransformPackageName(serviceName))
.withRequestTransformPackageName(namingStrategy.getRequestTransformPackageName(serviceName))
.withPaginatorsPackageName(namingStrategy.getPaginatorsPackageName(serviceName))
.withSmokeTestsPackageName(namingStrategy.getSmokeTestPackageName(serviceName))
.withServiceAbbreviation(serviceMetadata.getServiceAbbreviation())
.withServiceFullName(serviceMetadata.getServiceFullName())
.withSyncClient(String.format(Constant.SYNC_CLIENT_CLASS_NAME_PATTERN, serviceName))
Expand All @@ -103,9 +102,6 @@ public static Metadata constructMetadata(ServiceModel serviceModel,
String jsonVersion = getJsonVersion(metadata, serviceMetadata);
metadata.setJsonVersion(jsonVersion);

// TODO: iterate through all the operations and check whether any of
// them accept stream input
metadata.setHasApiWithStreamInput(false);
return metadata;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package software.amazon.awssdk.codegen.emitters;

import software.amazon.awssdk.codegen.internal.Constant;
import software.amazon.awssdk.codegen.internal.Utils;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;

Expand Down Expand Up @@ -50,10 +49,6 @@ public String getTransformDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullTransformPackageName());
}

public String getRequestTransformDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullRequestTransformPackageName());
}

public String getClientDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullClientPackageName());
}
Expand All @@ -62,15 +57,7 @@ public String getPaginatorsDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullPaginatorsPackageName());
}

public String getPolicyEnumDirectory() {
return sourceDirectory + "/" + Constant.AUTH_POLICY_ENUM_CLASS_DIR;
}

public String getAuthorizerDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullAuthPolicyPackageName());
}

public String getSmokeTestDirectory() {
return testDirectory + '/' + Utils.packageToDirectory(model.getMetadata().getFullSmokeTestsPackageName());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@

package software.amazon.awssdk.codegen.internal;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
Expand All @@ -32,42 +29,48 @@

public final class Jackson {

private static final ObjectMapper MAPPER = new ObjectMapper();
private static final ObjectMapper MAPPER = new ObjectMapper()
.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

private static final ObjectWriter WRITER = MAPPER
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true)
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.writerWithDefaultPrettyPrinter();

static {
MAPPER.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
private static final ObjectMapper FAIL_ON_UNKNOWN_PROPERTIES_MAPPER = new ObjectMapper()
.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);

MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
}
private static final ObjectWriter WRITER = MAPPER
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true)
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.writerWithDefaultPrettyPrinter();

private Jackson() {
}

public static <T> T load(Class<T> clazz, File file)
throws JsonParseException, JsonMappingException, IOException {
public static <T> T load(Class<T> clazz, File file) throws IOException {
return load(clazz, new FileInputStream(file));
}

public static <T> T load(Class<T> clazz, InputStream is)
throws JsonParseException, JsonMappingException, IOException {
public static <T> T load(Class<T> clazz, File file, boolean failOnUnknownProperties) throws IOException {
try (FileInputStream fis = new FileInputStream(file)) {
if (failOnUnknownProperties) {
return FAIL_ON_UNKNOWN_PROPERTIES_MAPPER.readValue(fis, clazz);
} else {
return load(clazz, fis);
}
}
}

public static <T> T load(Class<T> clazz, InputStream is) throws IOException {
return MAPPER.readValue(is, clazz);
}

public static <T> T load(Class<T> clazz, String fileLocation)
throws JsonParseException, JsonMappingException, IOException {
public static <T> T load(Class<T> clazz, String fileLocation) throws IOException {
InputStream is = Jackson.class.getClassLoader().getResourceAsStream(
fileLocation);
fileLocation);
return MAPPER.readValue(is, clazz);
}

public static void write(Object value, Writer w)
throws JsonGenerationException, JsonMappingException, IOException {
public static void write(Object value, Writer w) throws IOException {
WRITER.writeValue(w, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ public class CustomizationConfig {
* different type that is adapted to the real type
*/
private final List<ConvenienceTypeOverload> convenienceTypeOverloads = new ArrayList<>();
/**
* Overrides the request-level service name that will be used for request metrics and service
* exceptions. If not specified, the client will use the service interface name by default.
*
* Example: for backwards compatibility, this is set to "AmazonDynamoDBv2" for DynamoDB client.
*
* @see {@link software.amazon.awssdk.core.Request#getServiceName()}
*/
private String customServiceNameForRequest;
/**
* True if the generated code should enable client-side validation on required input
* parameters.
*/
private boolean requiredParamValidationEnabled;
/**
* Specifies the name of the client configuration class to use if a service
* has a specific advanced client configuration class. Null if the service
Expand Down Expand Up @@ -86,10 +72,6 @@ public class CustomizationConfig {
* Service calculates CRC32 checksum from compressed file when Accept-Encoding: gzip header is provided.
*/
private boolean calculateCrc32FromCompressedData;
/**
* Skips generating smoketests if set to true.
*/
private boolean skipSmokeTests;

/**
* Exclude the create() method on a client. This is useful for global services that will need a global region configured to
Expand Down Expand Up @@ -157,14 +139,6 @@ public static CustomizationConfig create() {
return new CustomizationConfig();
}

public String getCustomServiceNameForRequest() {
return customServiceNameForRequest;
}

public void setCustomServiceNameForRequest(String customServiceNameForRequest) {
this.customServiceNameForRequest = customServiceNameForRequest;
}

public CodeGenTemplatesConfig getCustomCodeTemplates() {
return customCodeTemplates;
}
Expand Down Expand Up @@ -205,14 +179,6 @@ public void setShapeModifiers(Map<String, ShapeModifier> shapeModifiers) {
this.shapeModifiers = shapeModifiers;
}

public boolean isRequiredParamValidationEnabled() {
return requiredParamValidationEnabled;
}

public void setRequiredParamValidationEnabled(boolean requiredParamValidationEnabled) {
this.requiredParamValidationEnabled = requiredParamValidationEnabled;
}

public String getServiceSpecificClientConfigClass() {
return serviceSpecificClientConfigClass;
}
Expand Down Expand Up @@ -282,14 +248,6 @@ public void setCalculateCrc32FromCompressedData(
this.calculateCrc32FromCompressedData = calculateCrc32FromCompressedData;
}

public boolean isSkipSmokeTests() {
return skipSmokeTests;
}

public void setSkipSmokeTests(boolean skipSmokeTests) {
this.skipSmokeTests = skipSmokeTests;
}

public boolean isExcludeClientCreateMethod() {
return excludeClientCreateMethod;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ public String getCustomRetryPolicy() {
return customizationConfig.getCustomRetryPolicy();
}

public String getServiceBaseExceptionFqcn() {
// TODO Move this into Metadata
return metadata.getProtocol().getProvider().getBaseExceptionFqcn();
}

public String getSdkModeledExceptionBaseFqcn() {
return String.format("%s.%s",
metadata.getFullModelPackageName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.Map;
import software.amazon.awssdk.codegen.internal.TypeUtils;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.runtime.transform.PathMarshaller;
import software.amazon.awssdk.protocols.core.PathMarshaller;
import software.amazon.awssdk.utils.StringUtils;

public class MemberModel extends DocumentationModel {
Expand Down
Loading