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

org.iamsteveholmes.gradle.ScroogeCompileTask.scala Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
package org.iamsteveholmes.gradle

import org.gradle.api.tasks._
import java.io.File
import com.twitter.scrooge.{Main, Compiler}
import _root_.scala.collection.JavaConverters._
import org.gradle.api.DefaultTask
import java.util

class ScroogeCompileTask extends DefaultTask {

    private var _dest: File = _
    private var _files: java.lang.Iterable[File] = _
    private var _opts: java.lang.Iterable[String] = new util.ArrayList()

    @OutputDirectory
    def getDest = _dest

    def setDest(destinationDirectory: File) {
        _dest = destinationDirectory
    }

    @InputFiles
    def getThriftFiles = _files

    def setThriftFiles(files: java.lang.Iterable[File]) {
        _files = files
    }


    @Input
    @Optional
    def getOpts = _opts

    def setOpts(options: java.lang.Iterable[String]) {
        this._opts = options
    }

    @TaskAction
    def compile() {
        val destination = getDest.getAbsolutePath
        val thriftFiles = _files.asScala.map{_.getAbsolutePath}
        thriftFiles.foreach(println)
        val compiler = new Compiler()
        compiler.destFolder = destination

        val args: Seq[String] = _opts.asScala.toSeq ++ thriftFiles.toSeq
        Main.parseOptions(compiler, args)
        compiler.run()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy