diff --git a/aws/aws-mcp-types/build.gradle.kts b/aws/aws-mcp-types/build.gradle.kts index c140f41ee..6dc42e529 100644 --- a/aws/aws-mcp-types/build.gradle.kts +++ b/aws/aws-mcp-types/build.gradle.kts @@ -14,16 +14,14 @@ dependencies { } afterEvaluate { - val typePath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val typesPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(typePath) - include("software/**") + srcDir("$typesPath/java") } resources { - srcDir(typePath) - include("META-INF/**") + srcDir("$typesPath/resources") } } } diff --git a/buildSrc/src/main/kotlin/CodegenExtension.kt b/buildSrc/src/main/kotlin/CodegenExtension.kt index 6a8828f64..9dbdea754 100644 --- a/buildSrc/src/main/kotlin/CodegenExtension.kt +++ b/buildSrc/src/main/kotlin/CodegenExtension.kt @@ -23,7 +23,8 @@ fun Project.addGenerateSrcsTask( val taskOutput = layout.buildDirectory.dir(generatedDir).get() val sourceSets = project.the() sourceSets.named("it") { - java.srcDir(taskOutput) + java.srcDirs("${taskOutput}/java", "${taskOutput}/resources") + } val task = tasks.register(taskName) { dependsOn("test") @@ -37,6 +38,7 @@ fun Project.addGenerateSrcsTask( } tasks.getByName("integ").dependsOn(task) tasks.getByName("compileItJava").dependsOn(task) + tasks.getByName("processItResources").dependsOn(task) return task } diff --git a/buildSrc/src/main/kotlin/smithy-java.codegen-plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/smithy-java.codegen-plugin-conventions.gradle.kts index f1ebde812..4773d7a70 100644 --- a/buildSrc/src/main/kotlin/smithy-java.codegen-plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/smithy-java.codegen-plugin-conventions.gradle.kts @@ -25,7 +25,10 @@ val generatedSrcDir = layout.buildDirectory.dir("generated-src").get() sourceSets { named("it") { java { - srcDir(generatedSrcDir) + srcDir("$generatedSrcDir/java") + } + resources { + srcDir("$generatedSrcDir/resources") } } } diff --git a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/CodegenUtils.java b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/CodegenUtils.java index 6b4e10c69..45015f731 100644 --- a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/CodegenUtils.java +++ b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/CodegenUtils.java @@ -95,7 +95,7 @@ public static Symbol fromClass(Class clazz) { /** * Gets a Symbol for a class with both a boxed and unboxed variant. * - * @param boxed Boxed variant of class + * @param boxed Boxed variant of class * @param unboxed Unboxed variant of class * @return Symbol representing java class */ @@ -162,9 +162,8 @@ public static boolean isJavaArray(Symbol symbol) { /** * Determines if a given member represents a nullable type. * - * @param model Model to use for resolving Nullable index. + * @param model Model to use for resolving Nullable index. * @param member member to check for nullability. - * * @return if the shape is a nullable type */ public static boolean isNullableMember(Model model, MemberShape member) { @@ -242,8 +241,8 @@ public static boolean requiresSetterNullCheck(SymbolProvider provider, MemberSha * *

Documents are also not set because they use a null default for error correction. * - * @see client error correction * @return true if the member shape has a builtin default + * @see client error correction */ public static boolean hasBuiltinDefault(SymbolProvider provider, Model model, MemberShape memberShape) { var target = model.expectShape(memberShape.getTarget()); @@ -267,7 +266,7 @@ public static String toDefaultValueName(String memberName) { * Gets the name to use when defining a member as instance variable in a class. * * @param memberShape MemberShape - * @param model Model + * @param model Model * @return Instance variable name of a member. */ public static String toMemberName(MemberShape memberShape, Model model) { @@ -277,7 +276,7 @@ public static String toMemberName(MemberShape memberShape, Model model) { /** * Gets the name to use when defining the getter method of a member. * - * @param memberShape memberShape. + * @param memberShape memberShape. * @return Getter method name of a member. */ public static String toGetterName(MemberShape memberShape, Model model) { @@ -296,7 +295,7 @@ public static String toGetterName(MemberShape memberShape, Model model) { * @return serde file name */ public static String getSerdeFileName(JavaCodegenSettings settings) { - return String.format("./%s/model/SharedSerde.java", settings.packageNamespace().replace(".", "/")); + return getJavaFilePath(settings, "model", "SharedSerde"); } /** @@ -306,7 +305,7 @@ public static String getSerdeFileName(JavaCodegenSettings settings) { * @return shared registry file name */ public static String getSharedRegistryFileName(JavaCodegenSettings settings) { - return String.format("./%s/model/SharedTypeRegistry.java", settings.packageNamespace().replace(".", "/")); + return getJavaFilePath(settings, "model", "SharedTypeRegistry"); } /** @@ -359,11 +358,11 @@ public static boolean recursiveShape(Model model, Shape shape) { *

NOTE: The provided class must have a public, no-arg constructor. * * @param clazz interface to get implementation of - * @param name fully-qualified class name + * @param name fully-qualified class name + * @param Type to get implementation for. * @return Class instance. - * @param Type to get implementation for. * @throws CodegenException if no valid implementation with a public no-arg constructor could be found on the - * classpath for the given class name. + * classpath for the given class name. */ @SuppressWarnings("unchecked") public static Class getImplementationByName(Class clazz, String name) { @@ -419,9 +418,9 @@ public static boolean isISO8601Date(String string) { * created, and property is found). * * @param directive Directive to get the service from. - * @param prop Property to get from the symbol of the service. + * @param prop Property to get from the symbol of the service. + * @param the property type. * @return the property if found, or null. - * @param the property type. */ public static T tryGetServiceProperty(ShapeDirective directive, Property prop) { var service = directive.service(); @@ -441,12 +440,12 @@ public static T tryGetServiceProperty(ShapeDirective directive, Pro * code generated to extend from this exception. * * @param packageNamespace The package namespace to use for the service exception. - * @param serviceName The name of the service to use for the service exception. + * @param serviceName The name of the service to use for the service exception. * @return the service exception symbol. */ public static Symbol getServiceExceptionSymbol(String packageNamespace, String serviceName) { var name = serviceName + "Exception"; - var filename = String.format("./%s/model/%s.java", packageNamespace.replace(".", "/"), name); + var filename = getJavaFilePath(packageNamespace, "model", name); return Symbol.builder() .name(name) .namespace(packageNamespace + ".model", ".") @@ -459,12 +458,12 @@ public static Symbol getServiceExceptionSymbol(String packageNamespace, String s * Returns the class used as the {@link ApiService} for the service. * * @param packageNamespace The package namespace to use for the service. - * @param serviceName The name of the service to use for the service. + * @param serviceName The name of the service to use for the service. * @return the service ApiService symbol. */ public static Symbol getServiceApiSymbol(String packageNamespace, String serviceName) { var name = serviceName + "ApiService"; - var filename = String.format("./%s/model/%s.java", packageNamespace.replace(".", "/"), name); + var filename = getJavaFilePath(packageNamespace, "model", name); return Symbol.builder() .name(name) .namespace(packageNamespace + ".model", ".") @@ -473,6 +472,31 @@ public static Symbol getServiceApiSymbol(String packageNamespace, String service .build(); } + /** + * Returns the file path for the java file with simple name using the configure package in settings. + * + * @param settings The settings to get the package namespace + * @param packageSuffix The suffix for the namespace for the file + * @param simpleName The simple name of the java file + * @return the file path for the java file + */ + public static String getJavaFilePath(JavaCodegenSettings settings, String packageSuffix, String simpleName) { + return getJavaFilePath(settings.packageNamespace(), packageSuffix, simpleName); + } + + /** + * Returns the file path for the java file with simple name using the configure package in settings. + * + * @param packageNamespace The package namespace for the file + * @param packageSuffix The suffix for the namespace for the file + * @param simpleName The simple name of the java file + * @return the file path for the java file + */ + public static String getJavaFilePath(String packageNamespace, String packageSuffix, String simpleName) { + var packagePath = packageNamespace.replace(".", "/"); + return String.format("java/%s/%s/%s.java", packagePath, packageSuffix, simpleName); + } + private static String getMemberName(MemberShape shape, Model model, boolean escape) { Shape containerShape = model.expectShape(shape.getContainer()); if (containerShape.isEnumShape() || containerShape.isIntEnumShape()) { diff --git a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/JavaSymbolProvider.java b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/JavaSymbolProvider.java index bd7f18abc..888f96891 100644 --- a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/JavaSymbolProvider.java +++ b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/JavaSymbolProvider.java @@ -299,14 +299,14 @@ public Symbol operationShape(OperationShape operationShape) { .putProperty(SymbolProperties.IS_PRIMITIVE, false) .namespace(format("%s.service", packageNamespace), ".") .declarationFile( - format("./%s/service/%s.java", packageNamespace.replace(".", "/"), stubName)) + CodegenUtils.getJavaFilePath(packageNamespace, "service", stubName)) .build(); var asyncStubSymbol = Symbol.builder() .name(asyncStubName) .putProperty(SymbolProperties.IS_PRIMITIVE, false) .namespace(format("%s.service", packageNamespace), ".") .declarationFile( - format("./%s/service/%s.java", packageNamespace.replace(".", "/"), asyncStubName)) + CodegenUtils.getJavaFilePath(packageNamespace, "service", asyncStubName)) .build(); return baseSymbol.toBuilder() .putProperty(SymbolProperties.IS_PRIMITIVE, false) @@ -380,7 +380,7 @@ private Symbol getJavaClassSymbol(Shape shape) { .putProperty(SymbolProperties.IS_PRIMITIVE, false) .putProperty(SymbolProperties.REQUIRES_STATIC_DEFAULT, true) .namespace(format("%s.model", packageNamespace), ".") - .declarationFile(format("./%s/model/%s.java", packageNamespace.replace(".", "/"), name)) + .declarationFile(CodegenUtils.getJavaFilePath(packageNamespace, "model", name)) .build(); } @@ -394,7 +394,7 @@ private Symbol getClientServiceSymbol() { .putProperty(SymbolProperties.SERVICE_API_SERVICE, CodegenUtils.getServiceApiSymbol(packageNamespace, serviceName)) .namespace(format("%s.client", packageNamespace), ".") - .definitionFile(format("./%s/client/%s.java", packageNamespace.replace(".", "/"), name)) + .definitionFile(CodegenUtils.getJavaFilePath(packageNamespace, "client", name)) .build(); return symbol.toBuilder() @@ -403,7 +403,7 @@ private Symbol getClientServiceSymbol() { symbol.toBuilder() .name(name + "Impl") .definitionFile( - format("./%s/client/%sImpl.java", packageNamespace.replace(".", "/"), name)) + CodegenUtils.getJavaFilePath(packageNamespace, "client", name + "Impl")) .build()) .build(); } @@ -419,7 +419,7 @@ private Symbol getServerServiceSymbol() { .putProperty(ServerSymbolProperties.TYPES_NAMESPACE, format("%s.model", packageNamespace)) .namespace(format("%s.service", packageNamespace), ".") .declarationFile( - format("./%s/service/%s.java", packageNamespace.replace(".", "/"), serviceName)) + CodegenUtils.getJavaFilePath(packageNamespace, "service", serviceName)) .build(); } } diff --git a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/generators/BddFileGenerator.java b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/generators/BddFileGenerator.java index 783c837e6..8ce8d5f7c 100644 --- a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/generators/BddFileGenerator.java +++ b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/generators/BddFileGenerator.java @@ -7,8 +7,7 @@ import static java.lang.String.format; -import java.io.IOException; -import java.nio.file.Files; +import java.io.ByteArrayInputStream; import java.util.function.Consumer; import software.amazon.smithy.codegen.core.directed.GenerateServiceDirective; import software.amazon.smithy.java.client.rulesengine.Bytecode; @@ -23,19 +22,11 @@ public class BddFileGenerator implements Consumer> { @Override public void accept(GenerateServiceDirective directive) { - try { - var baseDir = directive.fileManifest().getBaseDir(); - var serviceName = directive.service().toShapeId().getName(); - var fileDir = baseDir.resolve(format("resources/META-INF/endpoints/%s.bdd", serviceName)); - var parentDir = fileDir.getParent(); - if (parentDir != null) { - Files.createDirectories(parentDir); - } - var bytecode = compileBytecode(directive.service()); - Files.write(fileDir, bytecode.getBytecode()); - } catch (IOException e) { - throw new RuntimeException("Failed to write BDD bytecode binary file", e); - } + var fileManifest = directive.fileManifest(); + var serviceName = directive.service().toShapeId().getName(); + var bytecode = compileBytecode(directive.service()); + fileManifest.writeFile(format("resources/META-INF/endpoints/%s.bdd", serviceName), + new ByteArrayInputStream(bytecode.getBytecode())); } private Bytecode compileBytecode(ServiceShape serviceShape) { diff --git a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/waiters/WaiterCodegenUtils.java b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/waiters/WaiterCodegenUtils.java index a4d6e555d..fc49f80b7 100644 --- a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/waiters/WaiterCodegenUtils.java +++ b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/client/waiters/WaiterCodegenUtils.java @@ -8,6 +8,7 @@ import static java.lang.String.format; import software.amazon.smithy.codegen.core.Symbol; +import software.amazon.smithy.java.codegen.CodegenUtils; import software.amazon.smithy.java.codegen.JavaCodegenSettings; import software.amazon.smithy.java.codegen.SymbolProperties; @@ -25,9 +26,8 @@ public static Symbol getWaiterSymbol(Symbol clientSymbol, JavaCodegenSettings se .name(waiterName) .namespace(format("%s.client", settings.packageNamespace()), ".") .putProperty(SymbolProperties.IS_PRIMITIVE, false) - .definitionFile(format("./%s/client/%s.java", - settings.packageNamespace().replace(".", "/"), - waiterName)) + .definitionFile( + CodegenUtils.getJavaFilePath(settings.packageNamespace(), "client", waiterName)) .build(); } } diff --git a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemaIndexGenerator.java b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemaIndexGenerator.java index b06403923..1a2a70f0e 100644 --- a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemaIndexGenerator.java +++ b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemaIndexGenerator.java @@ -28,8 +28,7 @@ public final class SchemaIndexGenerator @Override public void accept(CustomizeDirective directive) { var className = "GeneratedSchemaIndex"; - var fileName = String - .format("./%s/model/%s.java", directive.settings().packageNamespace().replace(".", "/"), className); + var fileName = CodegenUtils.getJavaFilePath(directive.settings(), "model", className); directive.context() .writerDelegator() @@ -38,7 +37,7 @@ public void accept(CustomizeDirective generateSchemaIndexClass(writer, className, directive)); // Generate META-INF/services file - var serviceFileName = "./META-INF/services/" + SchemaIndex.class.getName(); + var serviceFileName = "./resources/META-INF/services/" + SchemaIndex.class.getName(); var schemaIndexClassName = CodegenUtils.getModelNamespace(directive.settings()) + "." + className; directive.context() diff --git a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemasGenerator.java b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemasGenerator.java index f58315d91..d7ee1bd95 100644 --- a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemasGenerator.java +++ b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/generators/SchemasGenerator.java @@ -54,8 +54,7 @@ public void accept(CustomizeDirective { diff --git a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/writer/JavaWriter.java b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/writer/JavaWriter.java index e246a1577..4c9fb2913 100644 --- a/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/writer/JavaWriter.java +++ b/codegen/codegen-plugin/src/main/java/software/amazon/smithy/java/codegen/writer/JavaWriter.java @@ -76,7 +76,7 @@ public String getFilename() { @Override public String toString() { // Do not add headers or attempt symbol resolution for resource files - if (filename.startsWith("META-INF")) { + if (filename.contains("META-INF")) { return super.toString(); } diff --git a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/SchemasTest.java b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/SchemasTest.java index 9248115ff..16174b770 100644 --- a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/SchemasTest.java +++ b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/SchemasTest.java @@ -94,7 +94,7 @@ private void verifySchemaReference(String structureName, String expectedSchema) private String getFileString(String fileName) { var fileStringOptional = manifest.getFileString( - Paths.get(String.format("/t/s/c/model/%s", fileName))); + Paths.get(String.format("/java/t/s/c/model/%s", fileName))); assertThat(fileStringOptional).isPresent(); return fileStringOptional.get(); } diff --git a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/client/utils/AbstractCodegenFileTest.java b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/client/utils/AbstractCodegenFileTest.java index 27fb5bb43..17141c299 100644 --- a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/client/utils/AbstractCodegenFileTest.java +++ b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/client/utils/AbstractCodegenFileTest.java @@ -51,7 +51,7 @@ protected ObjectNode settings() { protected String getFileStringForClass(String className) { var fileStringOptional = manifest.getFileString( - Paths.get(String.format("/test/smithy/codegen/%s.java", className))); + Paths.get(String.format("java/test/smithy/codegen/%s.java", className))); assertTrue(fileStringOptional.isPresent()); return fileStringOptional.get(); } diff --git a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/types/CodegenTest.java b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/types/CodegenTest.java index 2c334b9b1..9e2bfc5c1 100644 --- a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/types/CodegenTest.java +++ b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/types/CodegenTest.java @@ -51,14 +51,14 @@ void expectedFilesExist() { assertThat(manifest.getFiles()) .hasSize(8) .containsExactlyInAnyOrder( - Path.of("/test/smithy/codegen/types/test/model/EnumShape.java"), - Path.of("/test/smithy/codegen/types/test/model/IntEnumShape.java"), - Path.of("/test/smithy/codegen/types/test/model/Schemas.java"), - Path.of("/test/smithy/codegen/types/test/model/SharedSerde.java"), - Path.of("/test/smithy/codegen/types/test/model/StructureShape.java"), - Path.of("/test/smithy/codegen/types/test/model/UnionShape.java"), - Path.of("/test/smithy/codegen/types/test/model/GeneratedSchemaIndex.java"), - Path.of("/META-INF/services/software.amazon.smithy.java.core.schema.SchemaIndex")); + Path.of("/java/test/smithy/codegen/types/test/model/EnumShape.java"), + Path.of("/java/test/smithy/codegen/types/test/model/IntEnumShape.java"), + Path.of("/java/test/smithy/codegen/types/test/model/Schemas.java"), + Path.of("/java/test/smithy/codegen/types/test/model/SharedSerde.java"), + Path.of("/java/test/smithy/codegen/types/test/model/StructureShape.java"), + Path.of("/java/test/smithy/codegen/types/test/model/UnionShape.java"), + Path.of("/java/test/smithy/codegen/types/test/model/GeneratedSchemaIndex.java"), + Path.of("/resources/META-INF/services/software.amazon.smithy.java.core.schema.SchemaIndex")); } @Test @@ -71,11 +71,11 @@ void respectsSelector() { assertThat(manifest.getFiles()) .hasSize(5) .containsExactlyInAnyOrder( - Path.of("/test/smithy/codegen/types/test/model/Schemas.java"), - Path.of("/test/smithy/codegen/types/test/model/SharedSerde.java"), - Path.of("/test/smithy/codegen/types/test/model/StructureShape.java"), - Path.of("/test/smithy/codegen/types/test/model/GeneratedSchemaIndex.java"), - Path.of("/META-INF/services/software.amazon.smithy.java.core.schema.SchemaIndex")); + Path.of("/java/test/smithy/codegen/types/test/model/Schemas.java"), + Path.of("/java/test/smithy/codegen/types/test/model/SharedSerde.java"), + Path.of("/java/test/smithy/codegen/types/test/model/StructureShape.java"), + Path.of("/java/test/smithy/codegen/types/test/model/GeneratedSchemaIndex.java"), + Path.of("/resources/META-INF/services/software.amazon.smithy.java.core.schema.SchemaIndex")); } @Test @@ -90,12 +90,12 @@ void specificShapesAdded() { assertThat(manifest.getFiles()) .hasSize(6) .containsExactlyInAnyOrder( - Path.of("/test/smithy/codegen/types/test/model/Schemas.java"), - Path.of("/test/smithy/codegen/types/test/model/SharedSerde.java"), - Path.of("/test/smithy/codegen/types/test/model/StructureShape.java"), - Path.of("/test/smithy/codegen/types/test/model/UnionShape.java"), - Path.of("/test/smithy/codegen/types/test/model/GeneratedSchemaIndex.java"), - Path.of("/META-INF/services/software.amazon.smithy.java.core.schema.SchemaIndex")); + Path.of("/java/test/smithy/codegen/types/test/model/Schemas.java"), + Path.of("/java/test/smithy/codegen/types/test/model/SharedSerde.java"), + Path.of("/java/test/smithy/codegen/types/test/model/StructureShape.java"), + Path.of("/java/test/smithy/codegen/types/test/model/UnionShape.java"), + Path.of("/java/test/smithy/codegen/types/test/model/GeneratedSchemaIndex.java"), + Path.of("/resources/META-INF/services/software.amazon.smithy.java.core.schema.SchemaIndex")); } } diff --git a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/utils/AbstractCodegenFileTest.java b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/utils/AbstractCodegenFileTest.java index 51141d0f9..a76352a59 100644 --- a/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/utils/AbstractCodegenFileTest.java +++ b/codegen/codegen-plugin/src/test/java/software/amazon/smithy/java/codegen/utils/AbstractCodegenFileTest.java @@ -48,7 +48,7 @@ protected ObjectNode settings() { protected String getFileStringForClass(String className) { var fileStringOptional = manifest.getFileString( - Paths.get(String.format("/test/smithy/codegen/model/%s.java", className))); + Paths.get(String.format("java/test/smithy/codegen/model/%s.java", className))); assertTrue(fileStringOptional.isPresent()); return fileStringOptional.get(); } diff --git a/examples/basic-server/build.gradle.kts b/examples/basic-server/build.gradle.kts index 7e2b7ff85..8ba583a27 100644 --- a/examples/basic-server/build.gradle.kts +++ b/examples/basic-server/build.gradle.kts @@ -21,11 +21,11 @@ application { // Add generated Java files to the main sourceSet afterEvaluate { - val serverPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val serverPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(serverPath) + srcDir("$serverPath/java") } } } diff --git a/examples/event-streaming-client/build.gradle.kts b/examples/event-streaming-client/build.gradle.kts index 69ead6e69..51067aef8 100644 --- a/examples/event-streaming-client/build.gradle.kts +++ b/examples/event-streaming-client/build.gradle.kts @@ -21,11 +21,11 @@ dependencies { // Add generated Java sources to the main sourceset afterEvaluate { - val clientPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val clientPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(clientPath) + srcDir("$clientPath/java") } } create("it") { diff --git a/examples/lambda/build.gradle.kts b/examples/lambda/build.gradle.kts index e96975755..14cb7b625 100644 --- a/examples/lambda/build.gradle.kts +++ b/examples/lambda/build.gradle.kts @@ -37,11 +37,11 @@ tasks { // Add generated Java files to the main sourceSet afterEvaluate { - val serverPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val serverPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(serverPath) + srcDir("$serverPath/java") } } } diff --git a/examples/mcp-server/build.gradle.kts b/examples/mcp-server/build.gradle.kts index 1a4133d48..9b4f1d4c0 100644 --- a/examples/mcp-server/build.gradle.kts +++ b/examples/mcp-server/build.gradle.kts @@ -23,11 +23,11 @@ dependencies { // Add generated Java files to the main sourceSet afterEvaluate { - val serverPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val serverPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(serverPath) + srcDir("$serverPath/java") } } } @@ -58,4 +58,3 @@ tasks.assemble { java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } - diff --git a/examples/restjson-client/build.gradle.kts b/examples/restjson-client/build.gradle.kts index 25ca8468b..3d701abaf 100644 --- a/examples/restjson-client/build.gradle.kts +++ b/examples/restjson-client/build.gradle.kts @@ -25,11 +25,11 @@ application { // Add generated Java sources to the main sourceset afterEvaluate { - val clientPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val clientPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(clientPath) + srcDir("$clientPath/java") } } create("it") { diff --git a/examples/standalone-types/build.gradle.kts b/examples/standalone-types/build.gradle.kts index 6ade3faf1..444d3e982 100644 --- a/examples/standalone-types/build.gradle.kts +++ b/examples/standalone-types/build.gradle.kts @@ -18,16 +18,14 @@ dependencies { } afterEvaluate { - val typePath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val typesPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(typePath) - include("software/**") + srcDir("$typesPath/java") } resources { - srcDir(typePath) - include("META-INF/**") + srcDir("$typesPath/resources") } } } diff --git a/examples/transcribestreaming-client/build.gradle.kts b/examples/transcribestreaming-client/build.gradle.kts index 024405d94..2f1f62e7e 100644 --- a/examples/transcribestreaming-client/build.gradle.kts +++ b/examples/transcribestreaming-client/build.gradle.kts @@ -13,8 +13,8 @@ dependencies { implementation("software.amazon.smithy.java:aws-client-restjson:$smithyJavaVersion") implementation("software.amazon.smithy.java:client-core:$smithyJavaVersion") implementation("software.amazon.smithy.java:aws-sigv4:$smithyJavaVersion") - implementation("software.amazon.smithy.java:client-rulesengine:${smithyJavaVersion}") - implementation("software.amazon.smithy.java:aws-client-rulesengine:${smithyJavaVersion}") + implementation("software.amazon.smithy.java:client-rulesengine:$smithyJavaVersion") + implementation("software.amazon.smithy.java:aws-client-rulesengine:$smithyJavaVersion") implementation("org.slf4j:slf4j-simple:1.7.36") implementation(libs.smithy.aws.endpoints) implementation(libs.smithy.aws.smoke.test.model) @@ -28,15 +28,14 @@ dependencies { // Add generated Java sources to the main sourceset afterEvaluate { - val clientPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val clientPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(clientPath) + srcDir("$clientPath/java") } resources { - srcDir("${clientPath.get()}/META-INF") - srcDir("${clientPath.get()}/resources") + srcDir("$clientPath/resources") } } create("it") { diff --git a/framework-errors/build.gradle.kts b/framework-errors/build.gradle.kts index e46475d70..8158f14a9 100644 --- a/framework-errors/build.gradle.kts +++ b/framework-errors/build.gradle.kts @@ -21,16 +21,14 @@ dependencies { // Add generated Java sources to the main sourceSet afterEvaluate { - val typesPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val typesPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(typesPath) - include("software/**") + srcDir("$typesPath/java") } resources { - srcDir(typesPath) - include("META-INF/**") + srcDir("$typesPath/resources") } } } diff --git a/fuzz-test-harness/build.gradle.kts b/fuzz-test-harness/build.gradle.kts index 6eeb6ee21..0a7e5df90 100644 --- a/fuzz-test-harness/build.gradle.kts +++ b/fuzz-test-harness/build.gradle.kts @@ -28,16 +28,14 @@ dependencies { } afterEvaluate { - val typePath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val typePath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(typePath) - include("software/**") + srcDir("$typePath/java") } resources { - srcDir(typePath) - include("META-INF/**") + srcDir("$typePath/resources") } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cf1e50849..7687600cf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ smithy = "1.68.0" jmh = "0.7.3" test-logger-plugin = "4.0.0" spotbugs = "6.0.22" -spotless = "8.3.0" +spotless = "8.2.1" smithy-gradle-plugins = "1.4.0" assertj = "3.27.7" jackson = "3.1.0" diff --git a/mcp/mcp-schemas/build.gradle.kts b/mcp/mcp-schemas/build.gradle.kts index ac62e146d..45ff98f83 100644 --- a/mcp/mcp-schemas/build.gradle.kts +++ b/mcp/mcp-schemas/build.gradle.kts @@ -35,13 +35,13 @@ afterEvaluate { java { srcDir(codegenPath) srcDir(traitsPath) - include("software/**") + include("software/**", "java/software/**") } resources { srcDir(codegenPath) srcDir(traitsPath) exclude("**/*.java") - exclude("META-INF/services/**") // Exclude original service files, use merged ones instead + exclude("resources/META-INF/services/**") // Exclude original service files, use merged ones instead } smithy { diff --git a/model-bundle/model-bundle-api/build.gradle.kts b/model-bundle/model-bundle-api/build.gradle.kts index 0b1848ba9..b31688634 100644 --- a/model-bundle/model-bundle-api/build.gradle.kts +++ b/model-bundle/model-bundle-api/build.gradle.kts @@ -23,16 +23,14 @@ dependencies { } afterEvaluate { - val typePath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen") + val typesPath = smithy.getPluginProjectionPath(smithy.sourceProjection.get(), "java-codegen").get() sourceSets { main { java { - srcDir(typePath) - include("software/**") + srcDir("$typesPath/java") } resources { - srcDir(typePath) - include("META-INF/**") + srcDir("$typesPath/resources") } } }