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

com.apollographql.apollo.gradle.android.AndroidTaskConfigurator.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.android

import com.android.build.gradle.api.BaseVariant
import com.apollographql.apollo.gradle.ApolloCodegenTask
import com.apollographql.apollo.gradle.TaskConfigurator
import org.gradle.api.DomainObjectCollection
import org.gradle.api.Project
import org.gradle.api.Task

class AndroidTaskConfigurator extends TaskConfigurator {

  AndroidTaskConfigurator(Project project) {
    super(project)
  }

  @Override
  void configureTasks(Task apolloClassGenTask) {
    getVariants().all { BaseVariant variant ->
      addVariantTasks(variant, apolloClassGenTask)
    }
    project.android.testVariants.each { BaseVariant tv ->
      addVariantTasks(tv, apolloClassGenTask)
    }
  }

  private void addVariantTasks(BaseVariant variant, Task apolloClassGenTask) {
    ApolloCodegenTask codegenTask = createCodegenTask(variant.name, variant.sourceSets)
    variant.registerJavaGeneratingTask(codegenTask, codegenTask.outputDir.asFile.get())
    apolloClassGenTask.dependsOn(codegenTask)
  }

  private DomainObjectCollection getVariants() {
    return project.android.hasProperty('libraryVariants') ? project.android.libraryVariants : project.android.applicationVariants
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy