Skip to content

Commit

Permalink
Make various improvements geared towards Gradle/CLI
Browse files Browse the repository at this point in the history
AWS protocol tests:
- Use the Gradle plugin to build the AWS protocol tests.

SmithyBuild:
- Only run parallel projections if there's more than one.

SmithyCli (breaking CLI changes):
- to allow the writing to stderr and stdout to be completely customized
  using a Consumer<String>. This allows the Gradle plugin to log writes
  to stdout rather than rely on the non-thread-safe default behavior of
  intercepting calls.
- Colors nows is used by calling out and err directly on an enum variant
  rather than a static method.
- Adding the --logging parameter to every command and removed the static
  `configureLogging` method.
- Adding `stdout` and `stderr` methods to the Cli. These are now called
  by Colors when writing.
- Enabling disabling ANSI colors is done on Cli and not on Colors now.
  All of the methods used to influence the CLI globally is now all on
  the Cli.
- Logging is only configured when a logging option is passed in. A
  custom logger is used that makes calls to the intercepted stderr
  method.
- Running `build` now shows validation results too.

SmithyModel:
- ValidationEvents are now sorted by filename, line number, column,
  severity, shape ID, message, then finally the event ID.
- Introducing the ValidationEventFormatter interface. There are
  now implementations of the current display (showing the event on
  a single line like CheckStyle), and a contextual formatter that
  shows the line of the source file that has the error.
  • Loading branch information
mtdowling committed Jan 24, 2020
1 parent eeade32 commit 0fbc82a
Show file tree
Hide file tree
Showing 66 changed files with 504 additions and 229 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ Then, apply the Smithy Gradle Plugin in your `build.gradle.kts` file and run

```kotlin
plugins {
java
id("software.amazon.smithy").version("0.4.2")
id("software.amazon.smithy").version("0.4.3")
}
```

Expand Down
6 changes: 3 additions & 3 deletions docs/source/guides/building-models/gradle-plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The following example configures a project to use the Smithy Gradle plugin:
.. code-tab:: kotlin

plugins {
id("software.amazon.smithy").version("0.4.2")
id("software.amazon.smithy").version("0.4.3")
}


Expand Down Expand Up @@ -138,7 +138,7 @@ The following example ``build.gradle.kts`` will build a Smithy model using a
.. code-tab:: kotlin

plugins {
id("software.amazon.smithy").version("0.4.2")
id("software.amazon.smithy").version("0.4.3")
}

// The SmithyExtension is used to customize the build. This example
Expand Down Expand Up @@ -184,7 +184,7 @@ build that uses the "external" projection.
.. code-tab:: kotlin

plugins {
id("software.amazon.smithy").version("0.4.2")
id("software.amazon.smithy").version("0.4.3")
}

buildscript {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/guides/converting-to-openapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ specification from a Smithy model using a buildscript dependency:
plugins {
java
id("software.amazon.smithy").version("0.4.2")
id("software.amazon.smithy").version("0.4.3")
}
buildscript {
Expand Down
9 changes: 7 additions & 2 deletions smithy-aws-protocol-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ description = "Defines protocol tests for AWS HTTP protocols."
extra["displayName"] = "Smithy :: AWS :: Protocol Tests"
extra["moduleName"] = "software.amazon.smithy.aws.protocoltests"

plugins {
id("software.amazon.smithy").version("0.4.3")
}

dependencies {
api(project(":smithy-protocol-test-traits"))
api(project(":smithy-aws-traits"))
compile(project(":smithy-cli"))
implementation(project(":smithy-protocol-test-traits"))
implementation(project(":smithy-aws-traits"))
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,25 @@ void applyAllProjections(
} else {
parallelProjectionNameOrder.add(name);
parallelProjections.add(() -> {
ProjectionResult projectionResult = applyProjection(name, config, resolvedModel);
projectionResultConsumer.accept(projectionResult);
executeSerialProjection(resolvedModel, name, config,
projectionResultConsumer, projectionExceptionConsumer);
return null;
});
}
}

if (!parallelProjections.isEmpty()) {
// Common case of only executing a single plugin per/projection.
if (parallelProjections.size() == 1) {
try {
parallelProjections.get(0).call();
} catch (Throwable e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
} else if (!parallelProjections.isEmpty()) {
executeParallelProjections(parallelProjections, parallelProjectionNameOrder, projectionExceptionConsumer);
}
}
Expand Down
Loading

0 comments on commit 0fbc82a

Please sign in to comment.