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

com.jakewharton.wormhole.gradle.GroovyVoodoo.groovy Maven / Gradle / Ivy

There is a newer version: 0.3.1
Show newest version
package com.jakewharton.wormhole.gradle

import com.android.build.gradle.BaseExtension
import org.gradle.api.tasks.StopExecutionException

import java.util.function.Function

class GroovyVoodoo {
  private Function integerHandler
  private Function stringHandler

  GroovyVoodoo(
      Function integerHandler,
      Function stringHandler
  ) {
    this.integerHandler = integerHandler
    this.stringHandler = stringHandler
  }

  void applyTo(BaseExtension extension) {
    extension.metaClass.wormhole {
      if (it instanceof Integer) {
        return integerHandler.apply(it)
      } else if (it instanceof String) {
        return stringHandler.apply(it)
      } else {
        throw new StopExecutionException("Compilation platform must be specified as integer or string")
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy