Class CommonTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
com.graphql_java_generator.gradleplugin.CommonTask
All Implemented Interfaces:
com.graphql_java_generator.plugin.conf.CommonConfiguration, 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>
Direct Known Subclasses:
GenerateCodeCommonTask, GenerateGraphQLSchemaTask

public class CommonTask extends org.gradle.api.DefaultTask implements com.graphql_java_generator.plugin.conf.CommonConfiguration

This class contain the parameters that are common to all Gradle Extensions for this plugin, that is the parameters that are common to all the tasks of this plugin.

This avoids to redeclare each common parameter in each Extension, including its comment. When a comment is updated, only one update is necessary, instead of updating it in each Extension.

Note: The attribute have no default values: their default values is read from the GenerateCodeCommonExtension, whose attributes can be either the default value, or a value set in the build script.

  • 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 CommonExtension
    This is the extension, that contains default value for the task attributes
    This parameter is now deprecated: it's value used in the plugin is always true, that is: if the generated sources or resources are older than the GraphQL schema file(s), then there is no source or resource generation.

    Fields inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration

    DEFAULT_ADD_RELAY_CONNECTIONS, DEFAULT_JSON_GRAPHQL_SCHEMA_FILE, DEFAULT_MAX_TOKENS, DEFAULT_PACKAGE_NAME, DEFAULT_PREFIX, DEFAULT_SCHEMA_FILE_FOLDER, DEFAULT_SCHEMA_FILE_PATTERN, DEFAULT_SCHEMA_SUB_FOLDER, DEFAULT_SKIP_GENERATION_IF_SCHEMA_HAS_NOT_CHANGED, DEFAULT_SUFFIX, DEFAULT_TARGET_SCHEMA_SUBFOLDER

    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
    CommonTask(CommonExtension extension, org.gradle.api.file.ProjectLayout projectLayout)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final String
     
    An optional prefix to add to the classnames of the generated java classes for GraphQL enums.
    An optional suffix to add to the classnames of the generated java classes for GraphQL enums.
    protected CommonExtension
     
    protected File
    getFileValue(String taskValue, File extensionValue)
     
    An optional prefix to add to the classnames of the generated java classes for GraphQL input objects.
    An optional suffix to add to the classnames of the generated java classes for GraphQL input objects.
    An optional prefix to add to the classnames of the generated java classes for GraphQL interfaces.
    An optional suffix to add to the classnames of the generated java classes for GraphQL interfaces.
    If defined, the plugin loads the GraphQL schema from this json file.
     
     
    final File
     
    final File
     
    final File
     
    final String
     
    An optional prefix to add to the classnames of the generated java classes for GraphQL types.
     
    Defines the folder in the classpath that will contain the GraphQL schema, as needed by spring-graphql.
    An optional suffix to add to the classnames of the generated java classes for GraphQL types.
    An optional prefix to add to the classnames of the generated java classes for GraphQL unions.
    An optional suffix to add to the classnames of the generated java classes for GraphQL unions.
    protected <T> T
    getValue(T taskValue, T extensionValue)
     
    final boolean
     
    boolean
     
    boolean
    Returns true if either this task or its extension has been initialized, that is: at least one of their setters has been called.
    final boolean
    Deprecated.
    void
     
    final void
    setAddRelayConnections(Boolean addRelayConnections)
     
    void
    setEnumPrefix(String enumPrefix)
     
    void
    setEnumSuffix(String enumSuffix)
     
    void
     
    protected void
    setInitialized(boolean initialized)
    When initialized is set to true, this marks This task is now configured.
    void
    setInputPrefix(String inputPrefix)
     
    void
    setInputSuffix(String inputSuffix)
     
    void
    setInterfacePrefix(String interfacePrefix)
     
    void
    setInterfaceSuffix(String interfaceSuffix)
     
    void
    setJsonGraphqlSchemaFilename(String jsonGraphqlSchemaFilename)
     
    void
     
    final void
    setSchemaFileFolder(String schemaFileFolder)
     
    final void
    setSchemaFilePattern(String schemaFilePattern)
     
    final void
    setSkipGenerationIfSchemaHasNotChanged(boolean skipGenerationIfSchemaHasNotChanged)
     
    void
    setTargetSchemaSubFolder(String targetSchemaSubFolder)
     
    final void
     
    void
    setTypePrefix(String typePrefix)
     
    void
    setTypeSuffix(String typeSuffix)
     
    void
    setUnionPrefix(String unionPrefix)
     
    void
    setUnionSuffix(String unionSuffix)
     

    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, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface com.graphql_java_generator.plugin.conf.CommonConfiguration

    logCommonConfiguration

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Field Details

    • skipGenerationIfSchemaHasNotChanged

      public Boolean skipGenerationIfSchemaHasNotChanged

      This parameter is now deprecated: it's value used in the plugin is always true, that is: if the generated sources or resources are older than the GraphQL schema file(s), then there is no source or resource generation. In clear, the source and resource generation is executed only if the provided input (GraphQL schema...) has been updated since the last plugin execution.

    • extension

      protected CommonExtension extension
      This is the extension, that contains default value for the task attributes
  • Constructor Details

    • CommonTask

      @Inject public CommonTask(CommonExtension extension, org.gradle.api.file.ProjectLayout projectLayout)
  • Method Details

    • getValue

      protected <T> T getValue(T taskValue, T extensionValue)
    • getFileValue

      protected File getFileValue(String taskValue, File extensionValue)
    • isAddRelayConnections

      @Input public final boolean isAddRelayConnections()
      Specified by:
      isAddRelayConnections in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setAddRelayConnections

      public final void setAddRelayConnections(Boolean addRelayConnections)
    • getDefaultTargetSchemaFileName

      @Internal public final String getDefaultTargetSchemaFileName()
      Specified by:
      getDefaultTargetSchemaFileName in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • getEnumPrefix

      @Input public String getEnumPrefix()
      An optional prefix to add to the classnames of the generated java classes for GraphQL enums. The prefix is added at the beginning of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getEnumPrefix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setEnumPrefix

      public void setEnumPrefix(String enumPrefix)
    • getEnumSuffix

      @Input public String getEnumSuffix()
      An optional suffix to add to the classnames of the generated java classes for GraphQL enums. The suffix is added at the end of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getEnumSuffix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setEnumSuffix

      public void setEnumSuffix(String enumSuffix)
    • getInputPrefix

      @Input public String getInputPrefix()
      An optional prefix to add to the classnames of the generated java classes for GraphQL input objects. The prefix is added at the beginning of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getInputPrefix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setInputPrefix

      public void setInputPrefix(String inputPrefix)
    • getInputSuffix

      @Input public String getInputSuffix()
      An optional suffix to add to the classnames of the generated java classes for GraphQL input objects. The suffix is added at the end of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getInputSuffix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setInputSuffix

      public void setInputSuffix(String inputSuffix)
    • isInitialized

      @Input public boolean isInitialized()
      Returns true if either this task or its extension has been initialized, that is: at least one of their setters has been called.
      Returns:
      The value for initialized
    • getInterfacePrefix

      @Input public String getInterfacePrefix()
      An optional prefix to add to the classnames of the generated java classes for GraphQL interfaces. The prefix is added at the beginning of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getInterfacePrefix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setInterfacePrefix

      public void setInterfacePrefix(String interfacePrefix)
    • getInterfaceSuffix

      @Input public String getInterfaceSuffix()
      An optional suffix to add to the classnames of the generated java classes for GraphQL interfaces. The suffix is added at the end of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getInterfaceSuffix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setInterfaceSuffix

      public void setInterfaceSuffix(String interfaceSuffix)
    • getJsonGraphqlSchemaFilename

      @Input public String getJsonGraphqlSchemaFilename()

      If defined, the plugin loads the GraphQL schema from this json file. This allows to generate the code from the result of a GraphQL introspection query executed against an existing GraphQL server, for instance if you don't have its GraphQL schema file.

      This json file should have been retrieved by the full introspection query. You can find the introspection query from the getIntrospectionQuery of the graphql-js or from this graphql-java class. You then have to run it against the GraphQL server, and store the response into a schema.json file.

      Specified by:
      getJsonGraphqlSchemaFilename in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
      Returns:
    • setJsonGraphqlSchemaFilename

      public void setJsonGraphqlSchemaFilename(String jsonGraphqlSchemaFilename)
    • getMaxTokens

      @Input public Integer getMaxTokens()
      Specified by:
      getMaxTokens in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setParserOptions

      public void setParserOptions(Integer maxTokens)
    • getProjectBuildDir

      @Internal public File getProjectBuildDir()
      Specified by:
      getProjectBuildDir in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • getProjectDir

      @Internal public final File getProjectDir()
      Specified by:
      getProjectDir in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • getProjectMainSourceFolder

      @Internal public final File getProjectMainSourceFolder()
      Specified by:
      getProjectMainSourceFolder in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • getTargetSchemaSubFolder

      @Input public String getTargetSchemaSubFolder()
      An optional prefix to add to the classnames of the generated java classes for GraphQL types. The prefix is added at the beginning of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getTargetSchemaSubFolder in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setTargetSchemaSubFolder

      public void setTargetSchemaSubFolder(String targetSchemaSubFolder)
    • getTypePrefix

      @Input public String getTypePrefix()

      Defines the folder in the classpath that will contain the GraphQL schema, as needed by spring-graphql. The default is the default for spring-graphql, that is: graphql.

      Note: If you change this plugin parameter, you must then also define the spring property spring.graphql.schema.location to "classpath*:yourGraphQLSchemaFolder/, in you application.properties or application.yml project file.

      *

      Since 3.0.x

      *

      *Mandatory if you're using JPMS (java modules), as the default folder is /graphql, which triggers a conflict with the graphql package exposed by graphql-java

      Specified by:
      getTypePrefix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setTypePrefix

      public void setTypePrefix(String typePrefix)
    • getTypeSuffix

      @Input public String getTypeSuffix()
      An optional suffix to add to the classnames of the generated java classes for GraphQL types. The suffix is added at the end of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getTypeSuffix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setTypeSuffix

      public void setTypeSuffix(String typeSuffix)
    • getUnionPrefix

      @Input public String getUnionPrefix()
      An optional prefix to add to the classnames of the generated java classes for GraphQL unions. The prefix is added at the beginning of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getUnionPrefix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setUnionPrefix

      public void setUnionPrefix(String unionPrefix)
    • getUnionSuffix

      @Input public String getUnionSuffix()
      An optional suffix to add to the classnames of the generated java classes for GraphQL unions. The suffix is added at the end of the java classname, and must be compatible with java naming rules (no space, dot, comma, etc.)
      Specified by:
      getUnionSuffix in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setUnionSuffix

      public void setUnionSuffix(String unionSuffix)
    • isGenerateJacksonAnnotations

      @Internal public boolean isGenerateJacksonAnnotations()
      Specified by:
      isGenerateJacksonAnnotations in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • isSkipGenerationIfSchemaHasNotChanged

      @Input @Deprecated public final boolean isSkipGenerationIfSchemaHasNotChanged()
      Deprecated.
      Specified by:
      isSkipGenerationIfSchemaHasNotChanged in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setSkipGenerationIfSchemaHasNotChanged

      public final void setSkipGenerationIfSchemaHasNotChanged(boolean skipGenerationIfSchemaHasNotChanged)
    • getSchemaFileFolder

      @InputDirectory @Optional public final File getSchemaFileFolder()
      Specified by:
      getSchemaFileFolder in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setSchemaFileFolder

      public final void setSchemaFileFolder(String schemaFileFolder)
    • getSchemaFilePattern

      @Input public final String getSchemaFilePattern()
      Specified by:
      getSchemaFilePattern in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setSchemaFilePattern

      public final void setSchemaFilePattern(String schemaFilePattern)
    • getTemplates

      @Input public final Map<String,String> getTemplates()
      Specified by:
      getTemplates in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • setTemplates

      public final void setTemplates(Map<String,String> templates)
    • logConfiguration

      public void logConfiguration()
      Specified by:
      logConfiguration in interface com.graphql_java_generator.plugin.conf.CommonConfiguration
    • getExtension

      @Internal protected CommonExtension getExtension()
    • setExtension

      public void setExtension(CommonExtension extension)
    • setInitialized

      protected void setInitialized(boolean initialized)
      When initialized is set to true, this marks This task is now configured. So we'll mark compileJava and processResources as depending on it.
      Parameters:
      initialized - The new value for initialized