use of org.gradle.api.plugins.antlr.internal.AntlrSpecFactory in project gradle by gradle.
the class AntlrTask method execute.
/**
* Generate the parsers.
*
* @since 6.0
*/
@TaskAction
public void execute(InputChanges inputChanges) {
Set<File> grammarFiles = new HashSet<>();
FileCollection stableSources = getStableSources();
if (inputChanges.isIncremental()) {
boolean rebuildRequired = false;
for (FileChange fileChange : inputChanges.getFileChanges(stableSources)) {
if (fileChange.getFileType() == FileType.FILE) {
if (fileChange.getChangeType() == ChangeType.REMOVED) {
rebuildRequired = true;
break;
}
grammarFiles.add(fileChange.getFile());
}
}
if (rebuildRequired) {
try {
getDeleter().ensureEmptyDirectory(outputDirectory);
} catch (IOException ex) {
throw new UncheckedIOException(ex);
}
grammarFiles.addAll(stableSources.getFiles());
}
} else {
grammarFiles.addAll(stableSources.getFiles());
}
AntlrWorkerManager manager = new AntlrWorkerManager();
AntlrSpec spec = new AntlrSpecFactory().create(this, grammarFiles, sourceSetDirectories);
AntlrResult result = manager.runWorker(projectDir(), getWorkerProcessBuilderFactory(), getAntlrClasspath(), spec);
evaluate(result);
}
use of org.gradle.api.plugins.antlr.internal.AntlrSpecFactory 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);
}
Aggregations