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

butterknife.plugin.R2Generator.kt Maven / Gradle / Ivy

There is a newer version: 10.2.3
Show newest version
package butterknife.plugin

import org.gradle.api.DefaultTask
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import java.io.File

open class R2Generator : DefaultTask() {
  @get:OutputDirectory
  var outputDir: File? = null

  @get:InputFiles
  var rFile: FileCollection? = null

  @get:Input
  var useAndroidX: Boolean? = null

  @get:Input
  var packageName: String? = null

  @get:Input
  var className: String? = null

  @Suppress("unused") // Invoked by Gradle.
  @TaskAction
  fun brewJava() {
    brewJava(rFile!!.singleFile, outputDir!!, packageName!!, className!!, !useAndroidX!!)
  }
}

fun brewJava(
  rFile: File,
  outputDir: File,
  packageName: String,
  className: String,
  useLegacyTypes: Boolean
) {
  FinalRClassBuilder(packageName, className, useLegacyTypes)
      .also { ResourceSymbolListReader(it).readSymbolTable(rFile) }
      .build()
      .writeTo(outputDir)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy