Search in sources :

Example 1 with InputFileDetails

use of org.gradle.api.tasks.incremental.InputFileDetails in project gradle by gradle.

the class TwirlCompile method compile.

@TaskAction
void compile(IncrementalTaskInputs inputs) {
    RelativeFileCollector relativeFileCollector = new RelativeFileCollector();
    getSource().visit(relativeFileCollector);
    TwirlCompileSpec spec = new DefaultTwirlCompileSpec(relativeFileCollector.relativeFiles, getOutputDirectory(), getForkOptions(), getDefaultImports(), userTemplateFormats, additionalImports);
    if (!inputs.isIncremental()) {
        new CleaningPlayToolCompiler<TwirlCompileSpec>(getCompiler(), getOutputs()).execute(spec);
    } else {
        final Set<File> sourcesToCompile = new HashSet<File>();
        inputs.outOfDate(new Action<InputFileDetails>() {

            public void execute(InputFileDetails inputFileDetails) {
                sourcesToCompile.add(inputFileDetails.getFile());
            }
        });
        final Set<File> staleOutputFiles = new HashSet<File>();
        inputs.removed(new Action<InputFileDetails>() {

            public void execute(InputFileDetails inputFileDetails) {
                staleOutputFiles.add(inputFileDetails.getFile());
            }
        });
        if (cleaner == null) {
            cleaner = new TwirlStaleOutputCleaner(getOutputDirectory());
        }
        cleaner.execute(staleOutputFiles);
        getCompiler().execute(spec);
    }
}
Also used : DefaultTwirlCompileSpec(org.gradle.play.internal.twirl.DefaultTwirlCompileSpec) InputFileDetails(org.gradle.api.tasks.incremental.InputFileDetails) DefaultTwirlCompileSpec(org.gradle.play.internal.twirl.DefaultTwirlCompileSpec) TwirlCompileSpec(org.gradle.play.internal.twirl.TwirlCompileSpec) RelativeFile(org.gradle.api.internal.file.RelativeFile) File(java.io.File) HashSet(java.util.HashSet) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with InputFileDetails

use of org.gradle.api.tasks.incremental.InputFileDetails in project apollo-android by apollographql.

the class ApolloClassGenTask method generateClasses.

@TaskAction
void generateClasses(IncrementalTaskInputs inputs) {
    final NullableValueType nullableValueType = this.nullableValueType == null ? NullableValueType.ANNOTATED : NullableValueType.Companion.findByValue(this.nullableValueType);
    inputs.outOfDate(new Action<InputFileDetails>() {

        @Override
        public void execute(@NotNull InputFileDetails inputFileDetails) {
            GraphQLCompiler.Arguments args = new GraphQLCompiler.Arguments(inputFileDetails.getFile(), outputDir, customTypeMapping, nullableValueType, useSemanticNaming, generateModelBuilder, useJavaBeansSemanticNaming, outputPackageName);
            new GraphQLCompiler().write(args);
        }
    });
}
Also used : NullableValueType(com.apollographql.apollo.compiler.NullableValueType) InputFileDetails(org.gradle.api.tasks.incremental.InputFileDetails) GraphQLCompiler(com.apollographql.apollo.compiler.GraphQLCompiler) TaskAction(org.gradle.api.tasks.TaskAction)

Example 3 with InputFileDetails

use of org.gradle.api.tasks.incremental.InputFileDetails in project atlas by alibaba.

the class Dex method taskAction.

/**
 * Actual entry point for the action.
 * Calls out to the doTaskAction as needed.
 */
@TaskAction
public void taskAction(IncrementalTaskInputs inputs) throws IOException, InterruptedException, ProcessException {
    Collection<File> _inputFiles = getInputFiles();
    File _inputDir = getInputDir();
    if (_inputFiles == null && _inputDir == null) {
        throw new RuntimeException("Dex task \'" + getName() + ": inputDir and inputFiles cannot both be null");
    }
    if (!dexOptions.getIncremental() || !enableIncremental) {
        doTaskAction(_inputFiles, _inputDir, false);
        return;
    }
    if (!inputs.isIncremental()) {
        getProject().getLogger().info("Unable to do incremental execution: full task run.");
        doTaskAction(_inputFiles, _inputDir, false);
        return;
    }
    final AtomicBoolean forceFullRun = new AtomicBoolean();
    // noinspection GroovyAssignabilityCheck
    inputs.outOfDate(new Action<InputFileDetails>() {

        @Override
        public void execute(InputFileDetails change) {
            // New jar files are fine.
            if (((InputFileDetails) change).isModified() && ((InputFileDetails) change).getFile().getPath().endsWith(SdkConstants.DOT_JAR)) {
                getProject().getLogger().info("Force full dx run: Found updated " + String.valueOf(((InputFileDetails) change).getFile()));
                forceFullRun.set(true);
            }
        }
    });
    // noinspection GroovyAssignabilityCheck
    inputs.removed(change -> {
        // force full dx run if existing jar file is removed
        if (((InputFileDetails) change).getFile().getPath().endsWith(SdkConstants.DOT_JAR)) {
            getProject().getLogger().info("Force full dx run: Found removed " + String.valueOf(((InputFileDetails) change).getFile()));
            forceFullRun.set(true);
        }
    });
    doTaskAction(_inputFiles, _inputDir, !forceFullRun.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) InputFileDetails(org.gradle.api.tasks.incremental.InputFileDetails) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 4 with InputFileDetails

use of org.gradle.api.tasks.incremental.InputFileDetails 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)

Example 5 with InputFileDetails

use of org.gradle.api.tasks.incremental.InputFileDetails in project gradle by gradle.

the class SwiftCompile method compile.

@TaskAction
void compile(IncrementalTaskInputs inputs) {
    final List<File> removedFiles = Lists.newArrayList();
    final Set<File> changedFiles = Sets.newHashSet();
    boolean isIncremental = inputs.isIncremental();
    // which files changed and marking the compilation incremental or not.
    if (isIncremental) {
        inputs.outOfDate(new Action<InputFileDetails>() {

            @Override
            public void execute(InputFileDetails inputFileDetails) {
                if (inputFileDetails.isModified()) {
                    changedFiles.add(inputFileDetails.getFile());
                }
            }
        });
        inputs.removed(new Action<InputFileDetails>() {

            @Override
            public void execute(InputFileDetails removed) {
                removedFiles.add(removed.getFile());
            }
        });
        Set<File> allSourceFiles = getSource().getFiles();
        if (!allSourceFiles.containsAll(changedFiles)) {
            // If a non-source file changed, the compilation cannot be incremental
            // due to the way the Swift compiler detects changes from other modules
            isIncremental = false;
        }
    }
    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);
    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) InputFileDetails(org.gradle.api.tasks.incremental.InputFileDetails) DefaultSwiftCompileSpec(org.gradle.language.swift.tasks.internal.DefaultSwiftCompileSpec) SwiftCompileSpec(org.gradle.nativeplatform.toolchain.internal.compilespec.SwiftCompileSpec) IncrementalSwiftCompiler(org.gradle.nativeplatform.toolchain.internal.swift.IncrementalSwiftCompiler) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) WorkResult(org.gradle.api.tasks.WorkResult) OutputFile(org.gradle.api.tasks.OutputFile) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

InputFileDetails (org.gradle.api.tasks.incremental.InputFileDetails)6 File (java.io.File)4 TaskAction (org.gradle.api.tasks.TaskAction)4 HashSet (java.util.HashSet)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 GraphQLCompiler (com.apollographql.apollo.compiler.GraphQLCompiler)1 NullableValueType (com.apollographql.apollo.compiler.NullableValueType)1 ZipFile (java.util.zip.ZipFile)1 ChangesOnlyIncrementalTaskInputs (org.gradle.api.internal.changedetection.changes.ChangesOnlyIncrementalTaskInputs)1 RebuildIncrementalTaskInputs (org.gradle.api.internal.changedetection.changes.RebuildIncrementalTaskInputs)1 RelativeFile (org.gradle.api.internal.file.RelativeFile)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 InputChangesInternal (org.gradle.internal.execution.history.changes.InputChangesInternal)1 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)1 BuildOperationLoggerFactory (org.gradle.internal.operations.logging.BuildOperationLoggerFactory)1