All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.apollographql.apollo.gradle.ApolloExtension.groovy Maven / Gradle / Ivy

Go to download

Gradle plugin for generating java classes for graphql files. This plugin is deprecated, use apollo-gradle-plugin instead.

There is a newer version: 1.4.5
Show newest version
package com.apollographql.apollo.gradle

import com.apollographql.apollo.compiler.OperationIdGenerator
import com.apollographql.apollo.compiler.NullableValueType
import org.gradle.api.Project
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property

class ApolloExtension {
  static final String NAME = "apollo"

  final Property nullableValueType
  final Property useSemanticNaming
  final Property generateModelBuilder
  final Property useJavaBeansSemanticNaming
  final Property suppressRawTypesWarning
  final Property generateKotlinModels
  final Property generateVisitorForPolymorphicDatatypes
  final Property schemaFilePath
  final Property outputPackageName
  final Property generateOperationOutput
  final MapProperty customTypeMapping
  final Property operationIdGenerator
  final Property generateAsInternal

  ApolloExtension(Project project) {
    nullableValueType = project.objects.property(String.class)
    nullableValueType.set(NullableValueType.ANNOTATED.getValue())

    useSemanticNaming = project.objects.property(Boolean.class)
    useSemanticNaming.set(true)

    generateModelBuilder = project.objects.property(Boolean.class)
    generateModelBuilder.set(false)

    useJavaBeansSemanticNaming = project.objects.property(Boolean.class)
    useJavaBeansSemanticNaming.set(false)

    suppressRawTypesWarning = project.objects.property(Boolean.class)
    suppressRawTypesWarning.set(false)

    generateKotlinModels = project.objects.property(Boolean.class)
    generateKotlinModels.set(false)

    generateVisitorForPolymorphicDatatypes = project.objects.property(Boolean.class)
    generateVisitorForPolymorphicDatatypes.set(false)

    schemaFilePath = project.objects.property(String.class)
    schemaFilePath.set("")

    outputPackageName = project.objects.property(String.class)
    outputPackageName.set("")

    generateOperationOutput = project.objects.property(Boolean.class)
    generateOperationOutput.set(false)

    customTypeMapping = project.objects.mapProperty(String.class, String.class)
    customTypeMapping.set(new LinkedHashMap())

    operationIdGenerator = project.objects.property(OperationIdGenerator.class)
    operationIdGenerator.set(null)

    generateAsInternal = project.objects.property(Boolean.class)
    generateAsInternal.set(false)
  }

  void setNullableValueType(String nullableValueType) {
    this.nullableValueType.set(nullableValueType)
  }

  void setUseSemanticNaming(Boolean useSemanticNaming) {
    this.useSemanticNaming.set(useSemanticNaming)
  }

  void setGenerateModelBuilder(Boolean generateModelBuilder) {
    this.generateModelBuilder.set(generateModelBuilder)
  }

  void setUseJavaBeansSemanticNaming(Boolean useJavaBeansSemanticNaming) {
    this.useJavaBeansSemanticNaming.set(useJavaBeansSemanticNaming)
  }

  void setSuppressRawTypesWarning(Boolean suppressRawTypesWarning) {
    this.suppressRawTypesWarning.set(suppressRawTypesWarning)
  }

  void setGenerateKotlinModels(Boolean generateKotlinModels) {
    this.generateKotlinModels.set(generateKotlinModels)
  }

  void setGenerateVisitorForPolymorphicDatatypes(Boolean generateVisitorForPolymorphicDatatypes) {
    this.generateKotlinModels.set(generateVisitorForPolymorphicDatatypes)
  }

  void setSchemaFilePath(String schemaFilePath) {
    this.schemaFilePath.set(schemaFilePath)
  }

  void setOutputPackageName(String outputPackageName) {
    this.outputPackageName.set(outputPackageName)
  }

  void setGenerateOperationOutput(Boolean generateOperationOutput) {
    this.generateOperationOutput.set(generateOperationOutput)
  }

  void setGenerateAsInternal(Boolean generateAsInternal) {
    this.generateAsInternal.set(generateAsInternal)
  }

  void setCustomTypeMapping(Map customTypeMapping) {
    LinkedHashMap tmp = new LinkedHashMap()
    tmp.putAll(customTypeMapping)
    this.customTypeMapping.set(tmp)
  }

  void setOperationIdGenerator(OperationIdGenerator operationIdGenerator) {
    this.operationIdGenerator.set(operationIdGenerator)
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy