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

org.jastadd.JastAddTask.groovy Maven / Gradle / Ivy

There is a newer version: 1.13.3
Show newest version
package org.jastadd

import java.io.File

import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.file.FileCollection

/**
 * A task that generates Java code from JastAdd specifications.
 * This task type is useful for simple and non-modular JastAdd builds.
 */
class JastAddTask extends JavaExec {
  @InputFiles
  FileCollection sources

  @OutputDirectory
  File outputDir

  @Input
  def options = []

  JastAddTask() {
    setMain('org.jastadd.JastAdd')
    setClasspath(project.configurations.jastadd2)
    outputDir = project.file('src/gen')
  }

  @Override
  @TaskAction
  public void exec() {
    // First, clean the destination directory so old generated files are removed.
    outputDir.eachFile { it.delete() }
    main = 'org.jastadd.JastAdd'
    args = [ "--o=$outputDir" ] + options + sources.files
    super.exec();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy