Class SmithyFormatCheckTask
- All Implemented Interfaces:
Comparable<org.gradle.api.Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.TaskInternal,org.gradle.api.Named,org.gradle.api.plugins.ExtensionAware,org.gradle.api.Task,org.gradle.util.Configurable<org.gradle.api.Task>
This task passes --check to the Smithy CLI format command. Source
files are left untouched; the build fails if any file is not already formatted. This
is intended for CI pipelines that want to enforce consistent formatting.
Unlike SmithyFormatTask, this task is not wired into the build lifecycle
by default. Wire it into the check task or invoke it explicitly in CI:
./gradlew smithyFormatCheck
Requires Smithy CLI version 1.72.0 or later.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Named
org.gradle.api.Named.Namer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.gradle.api.model.ObjectFactoryObject factory used to create new gradle domain objects such asFileCollections.Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
ConstructorsConstructorDescriptionSmithyFormatCheckTask(org.gradle.api.model.ObjectFactory objectFactory, org.gradle.StartParameter startParameter) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureLoggingOptions(List<String> args) Add --stacktrace and --logging settings based on Gradle's settings.voidexecute()protected voidexecuteCliProcess(String command, List<String> additionalArgs, org.gradle.api.file.FileCollection sources, boolean disableModelDiscovery) Executes the given CLI command.abstract org.gradle.api.provider.Property<Boolean>Sets whether to fail a Smithy CLI task if an unknown trait is encountered.abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection>Classpath to use for build dependencies.abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection>Base classpath used for executing the smithy cli.abstract org.gradle.api.provider.Property<Boolean>getFork()Whether to fork a new process for executing the smithy cli.abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection>Classpath used for discovery of additional Smithy models during cli execution.abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection>Gets the list of models to execute a CLI command on.abstract org.gradle.api.provider.Property<org.gradle.api.logging.configuration.ShowStacktrace>Sets the detail to include in stack traces.protected voidwriteHeading(String text) Writes header-formatted text to the build output.Methods inherited from class software.amazon.smithy.gradle.tasks.SmithyFormatTask
formatModelsMethods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, notCompatibleWithConfigurationCache
-
Field Details
-
objectFactory
protected final org.gradle.api.model.ObjectFactory objectFactoryObject factory used to create new gradle domain objects such asFileCollections.
-
-
Constructor Details
-
SmithyFormatCheckTask
@Inject public SmithyFormatCheckTask(org.gradle.api.model.ObjectFactory objectFactory, org.gradle.StartParameter startParameter)
-
-
Method Details
-
execute
public void execute()- Overrides:
executein classSmithyFormatTask
-
getCliClasspath
@Classpath public abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection> getCliClasspath()Base classpath used for executing the smithy cli.Note: this classpath must contain the smithy-cli jar.
-
getAllowUnknownTraits
Sets whether to fail a Smithy CLI task if an unknown trait is encountered.Defaults to
false- Returns:
- flag indicating state of allowUnknownTraits setting
-
getModelDiscoveryClasspath
@Classpath @Optional public abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection> getModelDiscoveryClasspath()Classpath used for discovery of additional Smithy models during cli execution.Defaults to an empty collection.
-
getBuildClasspath
@Classpath @Optional public abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection> getBuildClasspath()Classpath to use for build dependencies. -
getModels
@InputFiles @Optional @PathSensitive(RELATIVE) public abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection> getModels()Gets the list of models to execute a CLI command on.These models are also considered "sources" when building a JAR for a project. A source model is a model that appears in the
META-INF/smithydirectory of a JAR.This method will return an empty
FileCollectionand nevernull.- Returns:
- Returns the models to validate.
-
getFork
Whether to fork a new process for executing the smithy cli.If false, the smithy cli will be executed in a new thread instead of a new process
Defaults to
false- Returns:
- flag indicating fork setting.
-
getShowStackTrace
@Input @Optional public abstract org.gradle.api.provider.Property<org.gradle.api.logging.configuration.ShowStacktrace> getShowStackTrace()Sets the detail to include in stack traces.Defaults to
ShowStacktrace.INTERNAL_EXCEPTIONS- Returns:
- stack trace setting.
-
executeCliProcess
protected void executeCliProcess(String command, List<String> additionalArgs, org.gradle.api.file.FileCollection sources, boolean disableModelDiscovery) Executes the given CLI command.This method will take care of adding --discover, --discover-classpath, and --allow-unknown-traits.
- Parameters:
command- The command to execute.additionalArgs- Custom arguments that aren't one of the shared args.sources- Source files to execute the command on
-
writeHeading
Writes header-formatted text to the build output.- Parameters:
text- text to write as a header.
-
configureLoggingOptions
Add --stacktrace and --logging settings based on Gradle's settings.
-