Search in sources :

Example 1 with AntlrSpec

use of org.gradle.api.plugins.antlr.internal.AntlrSpec in project gradle by gradle.

the class AntlrTask method execute.

@TaskAction
public void execute(IncrementalTaskInputs inputs) {
    final Set<File> grammarFiles = new HashSet<File>();
    final Set<File> sourceFiles = getSource().getFiles();
    final AtomicBoolean cleanRebuild = new AtomicBoolean();
    inputs.outOfDate(new Action<InputFileDetails>() {

        public void execute(InputFileDetails details) {
            File input = details.getFile();
            if (sourceFiles.contains(input)) {
                grammarFiles.add(input);
            } else {
                // classpath change?
                cleanRebuild.set(true);
            }
        }
    });
    inputs.removed(new Action<InputFileDetails>() {

        @Override
        public void execute(InputFileDetails details) {
            if (details.isRemoved()) {
                cleanRebuild.set(true);
            }
        }
    });
    if (cleanRebuild.get()) {
        GFileUtils.cleanDirectory(outputDirectory);
        grammarFiles.addAll(sourceFiles);
    }
    AntlrWorkerManager manager = new AntlrWorkerManager();
    AntlrSpec spec = new AntlrSpecFactory().create(this, grammarFiles, sourceDirectorySet);
    AntlrResult result = manager.runWorker(getProject().getProjectDir(), getWorkerProcessBuilderFactory(), getAntlrClasspath(), spec);
    evaluate(result);
}
Also used : AntlrSpecFactory(org.gradle.api.plugins.antlr.internal.AntlrSpecFactory) AntlrResult(org.gradle.api.plugins.antlr.internal.AntlrResult) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) InputFileDetails(org.gradle.api.tasks.incremental.InputFileDetails) AntlrSpec(org.gradle.api.plugins.antlr.internal.AntlrSpec) AntlrWorkerManager(org.gradle.api.plugins.antlr.internal.AntlrWorkerManager) File(java.io.File) HashSet(java.util.HashSet) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

File (java.io.File)1 HashSet (java.util.HashSet)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AntlrResult (org.gradle.api.plugins.antlr.internal.AntlrResult)1 AntlrSpec (org.gradle.api.plugins.antlr.internal.AntlrSpec)1 AntlrSpecFactory (org.gradle.api.plugins.antlr.internal.AntlrSpecFactory)1 AntlrWorkerManager (org.gradle.api.plugins.antlr.internal.AntlrWorkerManager)1 TaskAction (org.gradle.api.tasks.TaskAction)1 InputFileDetails (org.gradle.api.tasks.incremental.InputFileDetails)1