Class GenerateJsonSchema

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.creekservice.api.json.schema.gradle.plugin.task.GenerateJsonSchema
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="Runs an external schema generator process, whose output is not guaranteed to be relocatable between machines. Up-to-date checking within a single build tree is still enabled, so the task reruns when its inputs or declared outputs change.") public abstract class GenerateJsonSchema extends org.gradle.api.DefaultTask
Task for generating JSON schemas from code
  • Nested Class Summary

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

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

    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
    GenerateJsonSchema(org.gradle.process.ExecOperations execOps)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    abstract org.gradle.api.provider.ListProperty<String>
     
    abstract org.gradle.api.file.ConfigurableFileCollection
    The schema generator itself, and its dependencies.
    abstract org.gradle.api.provider.Property<String>
    Optionally, provide a specific directory to generate schemas into.
    abstract org.gradle.api.file.ConfigurableFileCollection
    The dependencies the project needs at runtime, which are on the generator's classpath so it can resolve the types it scans.
    abstract org.gradle.api.file.DirectoryProperty
    The resource root where generated schemas should be stored
    abstract org.gradle.api.provider.ListProperty<String>
    An optional list of module name used to limit the search for subtypes to only those types under the supplied module.
    abstract org.gradle.api.provider.ListProperty<String>
    An optional list of package name used to limit the search for subtypes to only those types under the supplied packages.
    abstract org.gradle.api.provider.ListProperty<String>
    An optional list of module names used to limit the generation of schemas to only those @GeneratesSchema annotated types within the named modules.
    abstract org.gradle.api.provider.ListProperty<String>
    An optional list of package name used to limit the generation of schemas to only those @GeneratesSchema annotated types under the supplied packages.
    void
    run()
    The task action.
    void
    Method to allow setting extra arguments from the command line.
    void
    Method to allow setting allowed subtype packages from the command line.
    void
    Method to allow setting allowed subtype modules from the command line.
    void
    Method to allow setting allowed subtype packages from the command line.
    void
    Method to allow setting allowed subtype packages from the command line.

    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, getLoggingManager, 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
  • Constructor Details

    • GenerateJsonSchema

      @Inject public GenerateJsonSchema(org.gradle.process.ExecOperations execOps)
      Constructor
      Parameters:
      execOps - Gradle exec operations service for executing JVM processes.
  • Method Details

    • getTypeScanningModuleWhiteList

      @Input public abstract org.gradle.api.provider.ListProperty<String> getTypeScanningModuleWhiteList()
      An optional list of module names used to limit the generation of schemas to only those @GeneratesSchema annotated types within the named modules.

      Allowed module names can include the glob wildcard * character.

      Setting this will speed up schema generation.

      Default: empty, meaning all modules.

      Returns:
      type scanning module white list property.
    • setTypeScanningModuleWhiteListFromOption

      public void setTypeScanningModuleWhiteListFromOption(List<String> args)
      Method to allow setting allowed subtype packages from the command line.
      Parameters:
      args - the modules to whitelist
    • getTypeScanningPackageWhiteList

      @Input public abstract org.gradle.api.provider.ListProperty<String> getTypeScanningPackageWhiteList()
      An optional list of package name used to limit the generation of schemas to only those @GeneratesSchema annotated types under the supplied packages.

      Allowed package names can include the glob wildcard * character.

      Setting this will speed up schema generation.

      Default: empty, meaning all packages.

      Returns:
      type scanning packaging white list property.
    • setTypeScanningPackageWhiteListFromOption

      public void setTypeScanningPackageWhiteListFromOption(List<String> args)
      Method to allow setting allowed subtype packages from the command line.
      Parameters:
      args - the packages to whitelist
    • getSubtypeScanningModuleWhiteList

      @Input public abstract org.gradle.api.provider.ListProperty<String> getSubtypeScanningModuleWhiteList()
      An optional list of module name used to limit the search for subtypes to only those types under the supplied module.

      Allowed module names can include the glob wildcard * character.

      Setting this will speed up schema generation.

      Default: empty, meaning all modules.

      Returns:
      subtype scanning module white list property.
    • setSubtypeScanningModuleWhiteListFromOption

      public void setSubtypeScanningModuleWhiteListFromOption(List<String> args)
      Method to allow setting allowed subtype modules from the command line.
      Parameters:
      args - the modules to whitelist
    • getSubtypeScanningPackageWhiteList

      @Input public abstract org.gradle.api.provider.ListProperty<String> getSubtypeScanningPackageWhiteList()
      An optional list of package name used to limit the search for subtypes to only those types under the supplied packages.

      Allowed package names can include the glob wildcard * character.

      Setting this will speed up schema generation.

      Default: empty, meaning all packages.

      Returns:
      subtype scanning package white list property.
    • setSubtypePackageWhiteListFromOption

      public void setSubtypePackageWhiteListFromOption(List<String> args)
      Method to allow setting allowed subtype packages from the command line.
      Parameters:
      args - the packages to whitelist
    • getSchemaResourceRoot

      @OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getSchemaResourceRoot()
      The resource root where generated schemas should be stored

      Default: $buildDir/generated/resources/schema

      Returns:
      the resource root property
    • getOutputDirectoryName

      @Input @Optional public abstract org.gradle.api.provider.Property<String> getOutputDirectoryName()
      Optionally, provide a specific directory to generate schemas into.

      By default, schemas will be generated in a package directory structure under the resource root, and the schema filename will match the simple name of the type.

      If this directory name is set, schemas will be generated into a single flat directly under the resource root, and the schema filename will match the types fully-qualified name.

      For example, given a type io.acme.financial.model.Account, the default schema location is resource-root /io/acme/financial/model/Account.yml. If this output directory property is set, then the schema location is resource-root /output-directory/io.acme.financial.model.Account.yml.

      Returns:
      output directory property.
    • getExtraArguments

      @Input public abstract org.gradle.api.provider.ListProperty<String> getExtraArguments()
      Returns:
      additional command line arguments to pass to the generator
    • setExtraArgumentsFromOption

      public void setExtraArgumentsFromOption(List<String> args)
      Method to allow setting extra arguments from the command line.
      Parameters:
      args - the extra arguments to set.
    • getClassFiles

      @Classpath public abstract org.gradle.api.file.ConfigurableFileCollection getClassFiles()
      Returns:
      the class files to scan, e.g. the output of the compileJava task or other compile task.
    • getGeneratorDeps

      @Classpath public abstract org.gradle.api.file.ConfigurableFileCollection getGeneratorDeps()
      The schema generator itself, and its dependencies.

      Tracked as a classpath input so that upgrading the generator correctly triggers a regeneration of the schemas.

      Returns:
      the generator and its dependencies.
    • getProjectDeps

      @Internal public abstract org.gradle.api.file.ConfigurableFileCollection getProjectDeps()
      The dependencies the project needs at runtime, which are on the generator's classpath so it can resolve the types it scans.

      Deliberately not tracked: for the test schema task this is testRuntimeClasspath, which includes this task's own output directory. Tracking it would make the task depend on its own output, so it would never be up-to-date. The compiled classes the generator actually scans are tracked via getClassFiles().

      Returns:
      the project dependencies to put on the generator's classpath.
    • run

      public void run()
      The task action.