Class SmithyValidateTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
software.amazon.smithy.gradle.tasks.SmithyValidateTask
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>

@DisableCachingByDefault(because="Only validates models and has no cacheable outputs") public abstract class SmithyValidateTask extends org.gradle.api.DefaultTask
Validates the Smithy models.

The validation task will execute the Smithy CLI in a new process to ensure that it uses an explicit classpath. Doing so will ensure that the generated JAR works correctly when used alongside its dependencies.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.gradle.api.model.ObjectFactory
    Object factory used to create new gradle domain objects such as FileCollections.

    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

    Constructors
    Constructor
    Description
    SmithyValidateTask(org.gradle.api.model.ObjectFactory objectFactory, org.gradle.StartParameter startParameter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Add --stacktrace and --logging settings based on Gradle's settings.
    void
     
    protected void
    executeCliProcess(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>
    Disable model discovery.
    abstract org.gradle.api.provider.Property<Boolean>
    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<String>
    Set the minimum reported validation severity.
    abstract org.gradle.api.provider.Property<org.gradle.api.logging.configuration.ShowStacktrace>
    Sets the detail to include in stack traces.
    abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection>
    Files to use as a sources for the Smithy CLI validate command.
    protected void
    Writes header-formatted text to the build output.

    Methods 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, usesService

    Methods 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, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Field Details

    • objectFactory

      protected final org.gradle.api.model.ObjectFactory objectFactory
      Object factory used to create new gradle domain objects such as FileCollections.
  • Constructor Details

    • SmithyValidateTask

      @Inject public SmithyValidateTask(org.gradle.api.model.ObjectFactory objectFactory, org.gradle.StartParameter startParameter)
  • Method Details

    • getSources

      @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.provider.Property<org.gradle.api.file.FileCollection> getSources()
      Files to use as a sources for the Smithy CLI validate command.

      This is a required input of the SmithyValidate task.

      Returns:
      file collection to use as sources for the validate task.
    • getDisableModelDiscovery

      @Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getDisableModelDiscovery()
      Disable model discovery.

      Defaults to false. This option is ignored if an explicit model discovery classpath is provided in the getModelDiscoveryClasspath() property.

      Returns:
      flag indicating whether to disable model discovery
    • getSeverity

      @Input @Optional public abstract org.gradle.api.provider.Property<String> getSeverity()
      Set the minimum reported validation severity.

      This value should be one of: NOTE, WARNING, DANGER, ERROR [default].

      Returns:
      minimum validator severity
    • execute

      public void execute()
    • 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

      @Input @Optional public abstract org.gradle.api.provider.Property<Boolean> 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/smithy directory of a JAR.

      This method will return an empty FileCollection and never null.

      Returns:
      Returns the models to validate.
    • getFork

      @Input @Optional public abstract org.gradle.api.provider.Property<Boolean> 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

      protected void writeHeading(String text)
      Writes header-formatted text to the build output.
      Parameters:
      text - text to write as a header.
    • configureLoggingOptions

      protected void configureLoggingOptions(List<String> args)
      Add --stacktrace and --logging settings based on Gradle's settings.