Search in sources :

Example 1 with FileChange

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);
    }
}
Also used : FileChange(org.gradle.work.FileChange)

Example 2 with FileChange

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());
}
Also used : BuildOperationLoggerFactory(org.gradle.internal.operations.logging.BuildOperationLoggerFactory) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) DefaultSwiftCompileSpec(org.gradle.language.swift.tasks.internal.DefaultSwiftCompileSpec) SwiftCompileSpec(org.gradle.nativeplatform.toolchain.internal.compilespec.SwiftCompileSpec) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) FileChange(org.gradle.work.FileChange) IncrementalSwiftCompiler(org.gradle.nativeplatform.toolchain.internal.swift.IncrementalSwiftCompiler) WorkResult(org.gradle.api.tasks.WorkResult) OutputFile(org.gradle.api.tasks.OutputFile) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Example 3 with FileChange

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);
}
Also used : AntlrSpecFactory(org.gradle.api.plugins.antlr.internal.AntlrSpecFactory) AntlrResult(org.gradle.api.plugins.antlr.internal.AntlrResult) AntlrSpec(org.gradle.api.plugins.antlr.internal.AntlrSpec) AntlrWorkerManager(org.gradle.api.plugins.antlr.internal.AntlrWorkerManager) FileChange(org.gradle.work.FileChange) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) FileCollection(org.gradle.api.file.FileCollection) File(java.io.File) HashSet(java.util.HashSet) TaskAction(org.gradle.api.tasks.TaskAction)

Example 4 with FileChange

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());
            }
        }
    }
}
Also used : FileChange(org.gradle.work.FileChange) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

FileChange (org.gradle.work.FileChange)4 File (java.io.File)3 TaskAction (org.gradle.api.tasks.TaskAction)3 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 HashSet (java.util.HashSet)1 FileCollection (org.gradle.api.file.FileCollection)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 OutputFile (org.gradle.api.tasks.OutputFile)1 WorkResult (org.gradle.api.tasks.WorkResult)1 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)1 BuildOperationLoggerFactory (org.gradle.internal.operations.logging.BuildOperationLoggerFactory)1 DefaultSwiftCompileSpec (org.gradle.language.swift.tasks.internal.DefaultSwiftCompileSpec)1 NativePlatformInternal (org.gradle.nativeplatform.platform.internal.NativePlatformInternal)1 SwiftCompileSpec (org.gradle.nativeplatform.toolchain.internal.compilespec.SwiftCompileSpec)1 IncrementalSwiftCompiler (org.gradle.nativeplatform.toolchain.internal.swift.IncrementalSwiftCompiler)1