use of org.gradle.work.FileChange in project gradle by gradle.
the class AbstractRecompilationSpecProvider method processOtherChanges.
private void processOtherChanges(CurrentCompilation current, PreviousCompilation previous, RecompilationSpec spec, SourceFileClassNameConverter sourceFileClassNameConverter) {
if (spec.isFullRebuildNeeded()) {
return;
}
SourceFileChangeProcessor sourceFileChangeProcessor = new SourceFileChangeProcessor(previous);
for (FileChange fileChange : sourceChanges) {
if (spec.isFullRebuildNeeded()) {
return;
}
if (fileChange.getFileType() != FileType.FILE) {
continue;
}
String relativeFilePath = fileChange.getNormalizedPath();
Set<String> changedClasses = sourceFileClassNameConverter.getClassNames(relativeFilePath);
if (changedClasses.isEmpty() && !isIncrementalOnResourceChanges(current)) {
spec.setFullRebuildCause(rebuildClauseForChangedNonSourceFile(fileChange));
}
sourceFileChangeProcessor.processChange(changedClasses, spec);
}
}
use of org.gradle.work.FileChange in project gradle by gradle.
the class SwiftCompile method compile.
@TaskAction
protected void compile(InputChanges inputs) {
final List<File> removedFiles = Lists.newArrayList();
final Set<File> changedFiles = Sets.newHashSet();
boolean isIncremental = inputs.isIncremental();
// which files changed .
if (isIncremental) {
for (FileChange fileChange : inputs.getFileChanges(getSource())) {
if (fileChange.getChangeType() == ChangeType.REMOVED) {
removedFiles.add(fileChange.getFile());
} else {
changedFiles.add(fileChange.getFile());
}
}
}
BuildOperationLogger operationLogger = getServices().get(BuildOperationLoggerFactory.class).newOperationLogger(getName(), getTemporaryDir());
NativePlatformInternal targetPlatform = Cast.cast(NativePlatformInternal.class, this.targetPlatform.get());
SwiftCompileSpec spec = createSpec(operationLogger, isIncremental, changedFiles, removedFiles, targetPlatform);
Compiler<SwiftCompileSpec> baseCompiler = new IncrementalSwiftCompiler(createCompiler(), getOutputs(), compilerOutputFileNamingSchemeFactory, deleter);
Compiler<SwiftCompileSpec> loggingCompiler = BuildOperationLoggingCompilerDecorator.wrap(baseCompiler);
WorkResult result = loggingCompiler.execute(spec);
setDidWork(result.getDidWork());
}
use of org.gradle.work.FileChange 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.work.FileChange in project gradle by gradle.
the class UnexportMainSymbol method unexport.
@TaskAction
protected void unexport(InputChanges inputChanges) {
for (FileChange change : inputChanges.getFileChanges(getObjects())) {
if (change.getChangeType() == ChangeType.REMOVED) {
File relocatedFileLocation = relocatedObject(change.getFile());
relocatedFileLocation.delete();
} else {
if (change.getFile().isFile()) {
unexportMainSymbol(change.getFile());
}
}
}
}
Aggregations