Java 类org.gradle.api.tasks.incremental.IncrementalTaskInputs 实例源码

项目:Reer    文件:RecompilationSpecProvider.java   
public RecompilationSpec provideRecompilationSpec(IncrementalTaskInputs inputs, PreviousCompilation previousCompilation, JarClasspathSnapshot jarClasspathSnapshot) {
    //creating an action that will be executed against all changes
    RecompilationSpec spec = new RecompilationSpec();
    JavaChangeProcessor javaChangeProcessor = new JavaChangeProcessor(previousCompilation, sourceToNameConverter);
    ClassChangeProcessor classChangeProcessor = new ClassChangeProcessor(previousCompilation);
    JarChangeProcessor jarChangeProcessor = new JarChangeProcessor(fileOperations, jarClasspathSnapshot, previousCompilation);
    InputChangeAction action = new InputChangeAction(spec, javaChangeProcessor, classChangeProcessor, jarChangeProcessor);

    //go!
    inputs.outOfDate(action);
    if (action.spec.getFullRebuildCause() != null) {
        //short circuit in case we already know that that full rebuild is needed
        return action.spec;
    }
    inputs.removed(action);
    return action.spec;
}
项目:Reer    文件:IncrementalCompilerDecorator.java   
private Compiler<JavaCompileSpec> getCompiler(IncrementalTaskInputs inputs, CompilationSourceDirs sourceDirs) {
    if (!inputs.isIncremental()) {
        LOG.lifecycle("{} - is not incremental (e.g. outputs have changed, no previous execution, etc.).", displayName);
        return cleaningCompiler;
    }
    if (!sourceDirs.canInferSourceRoots()) {
        LOG.lifecycle("{} - is not incremental. Unable to infer the source directories.", displayName);
        return cleaningCompiler;
    }
    ClassSetAnalysisData data = compileCaches.getLocalClassSetAnalysisStore().get();
    if (data == null) {
        LOG.lifecycle("{} - is not incremental. No class analysis data available from the previous build.", displayName);
        return cleaningCompiler;
    }
    PreviousCompilation previousCompilation = new PreviousCompilation(new ClassSetAnalysis(data), compileCaches.getLocalJarClasspathSnapshotStore(), compileCaches.getJarSnapshotCache());
    return new SelectiveCompiler(inputs, previousCompilation, cleaningCompiler, staleClassDetecter, compilationInitializer, jarClasspathSnapshotMaker);
}
项目:Reer    文件:AbstractNativeCompileTask.java   
@TaskAction
public void compile(IncrementalTaskInputs inputs) {
    BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
    NativeCompileSpec spec = createCompileSpec();
    spec.setTargetPlatform(targetPlatform);
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getObjectFileDir());
    spec.include(includes);
    spec.source(getSource());
    spec.setMacros(getMacros());
    spec.args(getCompilerArgs());
    spec.setPositionIndependentCode(isPositionIndependentCode());
    spec.setIncrementalCompile(inputs.isIncremental());
    spec.setDiscoveredInputRecorder((DiscoveredInputRecorder) inputs);
    spec.setOperationLogger(operationLogger);

    configureSpec(spec);

    PlatformToolProvider platformToolProvider = toolChain.select(targetPlatform);
    setDidWork(doCompile(spec, platformToolProvider).getDidWork());
}
项目:Reer    文件:WindowsResourceCompile.java   
@TaskAction
public void compile(IncrementalTaskInputs inputs) {
    BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());

    NativeCompileSpec spec = new DefaultWindowsResourceCompileSpec();
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getOutputDir());
    spec.include(getIncludes());
    spec.source(getSource());
    spec.setMacros(getMacros());
    spec.args(getCompilerArgs());
    spec.setIncrementalCompile(inputs.isIncremental());
    spec.setDiscoveredInputRecorder((DiscoveredInputRecorder) inputs);
    spec.setOperationLogger(operationLogger);

    PlatformToolProvider platformToolProvider = toolChain.select(targetPlatform);
    WorkResult result = doCompile(spec, platformToolProvider);
    setDidWork(result.getDidWork());
}
项目:gradle-project-config    文件:EclipseAnnotationsTask.java   
/**
 * Create the annotation JARs for the input JARs
 *
 * @param inputs Task inputs
 */
@TaskAction
public void createAnnotationJars(IncrementalTaskInputs inputs) {
    if (!inputs.isIncremental()) {
        for (File file : getAnnotationJars()) {
            file.delete();
        }
    }

    inputs.outOfDate(file -> {
        createAnnotationJar(file.getFile());
    });

    inputs.removed(file -> {
        file.getFile().delete();
    });
}
项目:Pushjet-Android    文件:RecompilationSpecProvider.java   
public RecompilationSpec provideRecompilationSpec(IncrementalTaskInputs inputs, PreviousCompilation previousCompilation, JarClasspathSnapshot jarClasspathSnapshot) {
    //creating an action that will be executed against all changes
    RecompilationSpec spec = new RecompilationSpec();
    JavaChangeProcessor javaChangeProcessor = new JavaChangeProcessor(previousCompilation, sourceToNameConverter);
    JarChangeProcessor jarChangeProcessor = new JarChangeProcessor(fileOperations, jarClasspathSnapshot, previousCompilation);
    InputChangeAction action = new InputChangeAction(spec, javaChangeProcessor, jarChangeProcessor);

    //go!
    inputs.outOfDate(action);
    if (action.spec.getFullRebuildCause() != null) {
        //short circuit in case we already know that that full rebuild is needed
        return action.spec;
    }
    inputs.removed(action);
    return action.spec;
}
项目:Pushjet-Android    文件:IncrementalCompilerDecorator.java   
private Compiler<JavaCompileSpec> getCompiler(IncrementalTaskInputs inputs, CompilationSourceDirs sourceDirs) {
    if (!inputs.isIncremental()) {
        LOG.lifecycle("{} - is not incremental (e.g. outputs have changed, no previous execution, etc.).", displayName);
        return cleaningCompiler;
    }
    if (!sourceDirs.areSourceDirsKnown()) {
        LOG.lifecycle("{} - is not incremental. Unable to infer the source directories.", displayName);
        return cleaningCompiler;
    }
    ClassSetAnalysisData data = compileCaches.getLocalClassSetAnalysisStore().get();
    if (data == null) {
        LOG.lifecycle("{} - is not incremental. No class analysis data available from the previous build.", displayName);
        return cleaningCompiler;
    }
    PreviousCompilation previousCompilation = new PreviousCompilation(new ClassSetAnalysis(data), compileCaches.getLocalJarClasspathSnapshotStore(), compileCaches.getJarSnapshotCache());
    return new SelectiveCompiler(inputs, previousCompilation, cleaningCompiler, staleClassDetecter, compilationInitializer, jarClasspathSnapshotMaker);
}
项目:Pushjet-Android    文件:AbstractNativeCompileTask.java   
@TaskAction
public void compile(IncrementalTaskInputs inputs) {

    NativeCompileSpec spec = createCompileSpec();
    spec.setTargetPlatform(targetPlatform);
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getObjectFileDir());
    spec.include(getIncludes());
    spec.source(getSource());
    spec.setMacros(getMacros());
    spec.args(getCompilerArgs());
    spec.setPositionIndependentCode(isPositionIndependentCode());
    spec.setIncrementalCompile(inputs.isIncremental());

    PlatformToolProvider platformToolProvider = toolChain.select(targetPlatform);
    WorkResult result = getIncrementalCompilerBuilder().createIncrementalCompiler(this, platformToolProvider.newCompiler(spec), toolChain).execute(spec);

    setDidWork(result.getDidWork());
}
项目:CodeColors    文件:DependenciesJavaGeneratingTask.java   
@Override
public void generate(IncrementalTaskInputs inputs) {
    File androidSdkResourcesFile =
            ResourceUtils.getResourceAsFile(AndroidSdkDependenciesTask.RESOURCES_OUTPUT_FILE_NAME);
    Resource.Pool resourcesPool = new CcResourcePool(getProject(), getVariant(), androidSdkResourcesFile);

    // Parse and get configuration resource dependencies.
    DependenciesParser dependenciesParser = new DependenciesParser(resourcesPool);
    dependenciesParser.parseDependencies(mMergeResourcesDir);

    DependenciesGenerator dependenciesGenerator = new DependenciesGenerator();
    dependenciesGenerator.generateDependencies(
            resourcesPool.getResources(),
            getVariant().getGenerateBuildConfig().getBuildConfigPackageName(),
            getVariant().getApplicationId(),
            getOutputDir());
}
项目:ormlite-android-gradle-plugin    文件:CreateOrmLiteConfigTask.java   
@TaskAction
protected void exec(IncrementalTaskInputs inputs) throws IOException, SQLException, InterruptedException {
    if (!inputs.isIncremental()) {
        getProject().delete(getOutputFile());
    }

    final Set<String> lastFilesInState = loadFileNames();
    final Set<String> newFilesInState = new HashSet<>(lastFilesInState);

    if (!hasNewState(inputs, lastFilesInState, newFilesInState)) {
        return;
    }
    saveFileNames(newFilesInState);

    final CreateOrmLiteConfigAction createOrmLiteConfigAction
            = new CreateOrmLiteConfigAction(configFileName,
                                            getProject().file(sourceDir),
                                            classpath.getAsPath(), getLogger());

    createOrmLiteConfigAction.execute();

    this.setDidWork(true);
}
项目:Reer    文件:JavaCompile.java   
@TaskAction
protected void compile(IncrementalTaskInputs inputs) {
    if (!compileOptions.isIncremental()) {
        compile();
        return;
    }

    SingleMessageLogger.incubatingFeatureUsed("Incremental java compilation");

    DefaultJavaCompileSpec spec = createSpec();
    final CacheRepository cacheRepository = getCacheRepository();
    final GeneralCompileCaches generalCompileCaches = getGeneralCompileCaches();

    CompileCaches compileCaches = new CompileCaches() {
        private final CacheRepository repository = cacheRepository;
        private final JavaCompile javaCompile = JavaCompile.this;
        private final GeneralCompileCaches generalCaches = generalCompileCaches;

        public ClassAnalysisCache getClassAnalysisCache() {
            return generalCaches.getClassAnalysisCache();
        }

        public JarSnapshotCache getJarSnapshotCache() {
            return generalCaches.getJarSnapshotCache();
        }

        public LocalJarClasspathSnapshotStore getLocalJarClasspathSnapshotStore() {
            return new LocalJarClasspathSnapshotStore(repository, javaCompile);
        }

        public LocalClassSetAnalysisStore getLocalClassSetAnalysisStore() {
            return new LocalClassSetAnalysisStore(repository, javaCompile);
        }
    };
    IncrementalCompilerFactory factory = new IncrementalCompilerFactory(
        getFileOperations(), getCachingFileHasher(), getPath(), createCompiler(spec), source, compileCaches, (IncrementalTaskInputsInternal) inputs);
    Compiler<JavaCompileSpec> compiler = factory.createCompiler();
    performCompilation(spec, compiler);
}
项目:Reer    文件:SelectiveCompiler.java   
public SelectiveCompiler(IncrementalTaskInputs inputs, PreviousCompilation previousCompilation, CleaningJavaCompiler cleaningCompiler,
                         RecompilationSpecProvider recompilationSpecProvider, IncrementalCompilationInitializer compilationInitializer, JarClasspathSnapshotProvider jarClasspathSnapshotProvider) {
    this.inputs = inputs;
    this.previousCompilation = previousCompilation;
    this.cleaningCompiler = cleaningCompiler;
    this.recompilationSpecProvider = recompilationSpecProvider;
    this.incrementalCompilationInitilizer = compilationInitializer;
    this.jarClasspathSnapshotProvider = jarClasspathSnapshotProvider;
}
项目:Reer    文件:DefaultTaskClassInfoStore.java   
private void attachTaskAction(final Method method, TaskClassInfo taskClassInfo, Collection<String> processedMethods) {
    if (method.getAnnotation(TaskAction.class) == null) {
        return;
    }
    if (Modifier.isStatic(method.getModifiers())) {
        throw new GradleException(String.format("Cannot use @TaskAction annotation on static method %s.%s().",
            method.getDeclaringClass().getSimpleName(), method.getName()));
    }
    final Class<?>[] parameterTypes = method.getParameterTypes();
    if (parameterTypes.length > 1) {
        throw new GradleException(String.format(
            "Cannot use @TaskAction annotation on method %s.%s() as this method takes multiple parameters.",
            method.getDeclaringClass().getSimpleName(), method.getName()));
    }

    if (parameterTypes.length == 1) {
        if (!parameterTypes[0].equals(IncrementalTaskInputs.class)) {
            throw new GradleException(String.format(
                "Cannot use @TaskAction annotation on method %s.%s() because %s is not a valid parameter to an action method.",
                method.getDeclaringClass().getSimpleName(), method.getName(), parameterTypes[0]));
        }
        if (taskClassInfo.isIncremental()) {
            throw new GradleException(String.format("Cannot have multiple @TaskAction methods accepting an %s parameter.", IncrementalTaskInputs.class.getSimpleName()));
        }
        taskClassInfo.setIncremental(true);
    }
    if (processedMethods.contains(method.getName())) {
        return;
    }
    taskClassInfo.getTaskActions().add(createActionFactory(method, parameterTypes));
    processedMethods.add(method.getName());
}
项目:Reer    文件:DefaultTaskArtifactStateRepository.java   
public IncrementalTaskInputs getInputChanges() {
    assert !upToDate : "Should not be here if the task is up-to-date";

    if (canPerformIncrementalBuild()) {
        taskInputs = instantiator.newInstance(ChangesOnlyIncrementalTaskInputs.class, getStates().getInputFilesChanges());
    } else {
        taskInputs = instantiator.newInstance(RebuildIncrementalTaskInputs.class, task);
    }
    return taskInputs;
}
项目:apollo-android    文件:ApolloClassGenTask.java   
@TaskAction
void generateClasses(IncrementalTaskInputs inputs) {
  inputs.outOfDate(new Action<InputFileDetails>() {
    @Override
    public void execute(InputFileDetails inputFileDetails) {
      GraphQLCompiler.Arguments args = new GraphQLCompiler.Arguments(inputFileDetails.getFile(), outputDir,
          apolloExtension.getCustomTypeMapping(), nullableValueType, apolloExtension.isUseSemanticNaming(),
          apolloExtension.isGenerateModelBuilder(), apolloExtension.isUseJavaBeansSemanticNaming(), apolloExtension
          .getOutputPackageName());
      new GraphQLCompiler().write(args);
    }
  });
}
项目:Pushjet-Android    文件:JavaCompile.java   
@TaskAction
protected void compile(IncrementalTaskInputs inputs) {
    if (!compileOptions.isIncremental()) {
        compile();
        return;
    }

    SingleMessageLogger.incubatingFeatureUsed("Incremental java compilation");

    DefaultJavaCompileSpec spec = createSpec();
    final CacheRepository repository1 = getCacheRepository();
    final JavaCompile javaCompile1 = this;
    final GeneralCompileCaches generalCaches1 = getGeneralCompileCaches();
    CompileCaches compileCaches = new CompileCaches() {
        private final CacheRepository repository = repository1;
        private final JavaCompile javaCompile = javaCompile1;
        private final GeneralCompileCaches generalCaches = generalCaches1;

        public ClassAnalysisCache getClassAnalysisCache() {
            return generalCaches.getClassAnalysisCache();
        }

        public JarSnapshotCache getJarSnapshotCache() {
            return generalCaches.getJarSnapshotCache();
        }

        public LocalJarClasspathSnapshotStore getLocalJarClasspathSnapshotStore() {
            return new LocalJarClasspathSnapshotStore(repository, javaCompile);
        }

        public LocalClassSetAnalysisStore getLocalClassSetAnalysisStore() {
            return new LocalClassSetAnalysisStore(repository, javaCompile);
        }
    };
    IncrementalCompilerFactory factory = new IncrementalCompilerFactory(
            (FileOperations) getProject(), getPath(), createCompiler(spec), source, compileCaches, (IncrementalTaskInputsInternal) inputs);
    Compiler<JavaCompileSpec> compiler = factory.createCompiler();
    performCompilation(spec, compiler);
}
项目:Pushjet-Android    文件:SelectiveCompiler.java   
public SelectiveCompiler(IncrementalTaskInputs inputs, PreviousCompilation previousCompilation, CleaningJavaCompiler cleaningCompiler,
                         RecompilationSpecProvider recompilationSpecProvider, IncrementalCompilationInitializer compilationInitializer, JarClasspathSnapshotProvider jarClasspathSnapshotProvider) {
    this.inputs = inputs;
    this.previousCompilation = previousCompilation;
    this.cleaningCompiler = cleaningCompiler;
    this.recompilationSpecProvider = recompilationSpecProvider;
    this.incrementalCompilationInitilizer = compilationInitializer;
    this.jarClasspathSnapshotProvider = jarClasspathSnapshotProvider;
}
项目:Pushjet-Android    文件:WindowsResourceCompile.java   
@TaskAction
public void compile(IncrementalTaskInputs inputs) {
    NativeCompileSpec spec = new DefaultWindowsResourceCompileSpec();
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getOutputDir());
    spec.include(getIncludes());
    spec.source(getSource());
    spec.setMacros(getMacros());
    spec.args(getCompilerArgs());
    spec.setIncrementalCompile(inputs.isIncremental());

    PlatformToolProvider platformToolProvider = toolChain.select(targetPlatform);
    WorkResult result = getIncrementalCompilerBuilder().createIncrementalCompiler(this, platformToolProvider.newCompiler(spec), toolChain).execute(spec);
    setDidWork(result.getDidWork());
}
项目:Pushjet-Android    文件:AnnotationProcessingTaskFactory.java   
private void attachTaskAction(final Method method, TaskClassInfo taskClassInfo, Collection<String> processedMethods) {
    if (method.getAnnotation(TaskAction.class) == null) {
        return;
    }
    if (Modifier.isStatic(method.getModifiers())) {
        throw new GradleException(String.format("Cannot use @TaskAction annotation on static method %s.%s().",
                method.getDeclaringClass().getSimpleName(), method.getName()));
    }
    final Class<?>[] parameterTypes = method.getParameterTypes();
    if (parameterTypes.length > 1) {
        throw new GradleException(String.format(
                "Cannot use @TaskAction annotation on method %s.%s() as this method takes multiple parameters.",
                method.getDeclaringClass().getSimpleName(), method.getName()));
    }

    if (parameterTypes.length == 1) {
        if (!parameterTypes[0].equals(IncrementalTaskInputs.class)) {
            throw new GradleException(String.format(
                    "Cannot use @TaskAction annotation on method %s.%s() because %s is not a valid parameter to an action method.",
                    method.getDeclaringClass().getSimpleName(), method.getName(), parameterTypes[0]));
        }
        if (taskClassInfo.incremental) {
            throw new GradleException(String.format("Cannot have multiple @TaskAction methods accepting an %s parameter.", IncrementalTaskInputs.class.getSimpleName()));
        }
        taskClassInfo.incremental = true;
    }
    if (processedMethods.contains(method.getName())) {
        return;
    }
    taskClassInfo.taskActions.add(createActionFactory(method, parameterTypes));
    processedMethods.add(method.getName());
}
项目:Pushjet-Android    文件:DefaultTaskArtifactStateRepository.java   
public IncrementalTaskInputs getInputChanges() {
    assert !upToDate : "Should not be here if the task is up-to-date";

    if (canPerformIncrementalBuild()) {
        return instantiator.newInstance(ChangesOnlyIncrementalTaskInputs.class, getStates().getInputFilesChanges(), getStates().getInputFilesSnapshot());
    }
    return instantiator.newInstance(RebuildIncrementalTaskInputs.class, task, getStates().getInputFilesSnapshot());
}
项目:Pushjet-Android    文件:AnnotationProcessingTaskFactory.java   
private void attachTaskAction(final Method method, TaskClassInfo taskClassInfo, Collection<String> processedMethods) {
    if (method.getAnnotation(TaskAction.class) == null) {
        return;
    }
    if (Modifier.isStatic(method.getModifiers())) {
        throw new GradleException(String.format("Cannot use @TaskAction annotation on static method %s.%s().",
                method.getDeclaringClass().getSimpleName(), method.getName()));
    }
    final Class<?>[] parameterTypes = method.getParameterTypes();
    if (parameterTypes.length > 1) {
        throw new GradleException(String.format(
                "Cannot use @TaskAction annotation on method %s.%s() as this method takes multiple parameters.",
                method.getDeclaringClass().getSimpleName(), method.getName()));
    }

    if (parameterTypes.length == 1) {
        if (!parameterTypes[0].equals(IncrementalTaskInputs.class)) {
            throw new GradleException(String.format(
                    "Cannot use @TaskAction annotation on method %s.%s() because %s is not a valid parameter to an action method.",
                    method.getDeclaringClass().getSimpleName(), method.getName(), parameterTypes[0]));
        }
        if (taskClassInfo.incremental) {
            throw new GradleException(String.format("Cannot have multiple @TaskAction methods accepting an %s parameter.", IncrementalTaskInputs.class.getSimpleName()));
        }
        taskClassInfo.incremental = true;
    }
    if (processedMethods.contains(method.getName())) {
        return;
    }
    taskClassInfo.taskActions.add(createActionFactory(method, parameterTypes));
    processedMethods.add(method.getName());
}
项目:Pushjet-Android    文件:DefaultTaskArtifactStateRepository.java   
public IncrementalTaskInputs getInputChanges() {
    assert !upToDate : "Should not be here if the task is up-to-date";

    if (canPerformIncrementalBuild()) {
        return instantiator.newInstance(ChangesOnlyIncrementalTaskInputs.class, getStates().getInputFilesChanges());
    }
    return instantiator.newInstance(RebuildIncrementalTaskInputs.class, task);
}
项目:Pushjet-Android    文件:Compile.java   
@TaskAction
protected void compile(IncrementalTaskInputs inputs) {
    if (!maybeCompileIncrementally(inputs)) {
        compile();
    }
    incrementalCompilation.compilationComplete(compileOptions,
            new ClassDependencyInfoExtractor(getDestinationDir()),
            getDependencyInfoSerializer(), Collections.<JarArchive>emptyList());
}
项目:Pushjet-Android    文件:Compile.java   
private boolean maybeCompileIncrementally(IncrementalTaskInputs inputs) {
    if (!compileOptions.isIncremental()) {
        return false;
    }
    //hack
    List<File> sourceDirs = getSourceDirs();
    if (sourceDirs.isEmpty()) {
        LOG.lifecycle("{} cannot run incrementally because Gradle cannot infer the source directories.", getPath());
        return false;
    }
    if (!inputs.isIncremental()) {
        LOG.lifecycle("{} is not incremental (e.g. outputs have changed, no previous execution, etc). Using regular compile.", getPath());
        return false;
    }
    ClassDependencyInfoSerializer dependencyInfoSerializer = getDependencyInfoSerializer();
    if (!dependencyInfoSerializer.isInfoAvailable()) {
        //TODO SF let's unit test a scenario when after regular compilation incremental compilation is scheduled
        LOG.lifecycle("{} is not incremental because there is no class dependency data left from previous incremental build.", getPath());
        return false;
    }

    SingleMessageLogger.incubatingFeatureUsed("Incremental java compilation");

    SelectiveJavaCompiler compiler = new SelectiveJavaCompiler(javaCompiler, getProject().fileTree(getDestinationDir()));
    SelectiveCompilation selectiveCompilation = new SelectiveCompilation(inputs, getSource(), getClasspath(), getDestinationDir(),
            dependencyInfoSerializer, getJarSnapshotCache(), compiler, sourceDirs, (FileOperations) getProject());

    if (!selectiveCompilation.getCompilationNeeded()) {
        LOG.lifecycle("{} does not require recompilation. Skipping the compiler.", getPath());
        return true;
    }

    Clock clock = new Clock();
    performCompilation(selectiveCompilation.getSource(), selectiveCompilation.getClasspath(), selectiveCompilation.getFullRebuildRequired()? cleaningCompiler : compiler);
    LOG.lifecycle("{} - incremental compilation took {}", getPath(), clock.getTime());

    return true;
}
项目:Pushjet-Android    文件:SelectiveCompilation.java   
public SelectiveCompilation(IncrementalTaskInputs inputs, FileTree source, FileCollection compileClasspath, final File compileDestination,
                            final ClassDependencyInfoSerializer dependencyInfoSerializer, final JarSnapshotCache jarSnapshotCache, final SelectiveJavaCompiler compiler,
                            Iterable<File> sourceDirs, final FileOperations operations) {
    this.operations = operations;
    this.jarSnapshotFeeder = new JarSnapshotFeeder(jarSnapshotCache, new JarSnapshotter(new DefaultHasher()));
    this.compiler = compiler;

    Clock clock = new Clock();
    final InputOutputMapper mapper = new InputOutputMapper(sourceDirs, compileDestination);

    //load dependency info
    final ClassDependencyInfo dependencyInfo = dependencyInfoSerializer.readInfo();

    //including only source java classes that were changed
    final PatternSet changedSourceOnly = new PatternSet();
    InputFileDetailsAction action = new InputFileDetailsAction(mapper, compiler, changedSourceOnly, dependencyInfo);
    inputs.outOfDate(action);
    inputs.removed(action);
    if (fullRebuildNeeded != null) {
        LOG.lifecycle("Stale classes detection completed in {}. Rebuild needed: {}.", clock.getTime(), fullRebuildNeeded);
        this.classpath = compileClasspath;
        this.source = source;
        return;
    }

    compiler.deleteStaleClasses();
    Set<File> filesToCompile = source.matching(changedSourceOnly).getFiles();
    if (filesToCompile.isEmpty()) {
        this.compilationNeeded = false;
        this.classpath = compileClasspath;
        this.source = source;
    } else {
        this.classpath = compileClasspath.plus(new SimpleFileCollection(compileDestination));
        this.source = source.matching(changedSourceOnly);
    }
    LOG.lifecycle("Stale classes detection completed in {}. Compile include patterns: {}.", clock.getTime(), changedSourceOnly.getIncludes());
}
项目:CodeColors    文件:ColorsJavaGeneratingTask.java   
@Override
public void generate(IncrementalTaskInputs inputs) {
    Map<String, Set<CcConfiguration>> colorConfigurations =
            ColorConfigurationsGenerator.getColorConfigurations(getProject(), getVariant());

    ColorsGenerator.generateColors(
            colorConfigurations,
            getVariant().getGenerateBuildConfig().getBuildConfigPackageName(),
            getVariant().getApplicationId(),
            getOutputDir());
}
项目:CodeColors    文件:ResourcesResGeneratingTask.java   
@Override
public void generate(IncrementalTaskInputs inputs) {
    mResFilesChanged = !inputs.isIncremental();

    if (!mResFilesChanged) {
        Action<InputFileDetails> detectChangesAction = new Action<InputFileDetails>() {
            @Override
            public void execute(InputFileDetails inputFileDetails) {
                if (!mResFilesChanged) {
                    mResFilesChanged = mResFileIdentifier.isResFile(inputFileDetails.getFile(), true);
                }
            }
        };

        inputs.outOfDate(detectChangesAction);
        if (!mResFilesChanged) {
            inputs.removed(detectChangesAction);
        }
    }

    if (mResFilesChanged) {
        // If we detect any changes, will rebuild all CodeColor resources.
        // Incremental build is too complex for its eventual gain.
        // For every build, we would have to parse the existing resources, and update or remove their
        // individual files and default values, for every configuration.
        generateResources();
    }
}
项目:spotless    文件:SelfTest.java   
@Override
public void runAllTasks(Project project) {
    project.getTasks().stream()
            .filter(task -> task instanceof SpotlessTask)
            .map(task -> (SpotlessTask) task)
            .forEach(task -> Errors.rethrow().run(() -> {
                IncrementalTaskInputs inputs = Mocks.mockIncrementalTaskInputs(task.getTarget());
                task.setCheck();
                task.performAction(inputs);
            }));
}
项目:spotless    文件:SelfTest.java   
@Override
public void runAllTasks(Project project) {
    project.getTasks().stream()
            .filter(task -> task instanceof SpotlessTask)
            .map(task -> (SpotlessTask) task)
            .forEach(task -> Errors.rethrow().run(() -> {
                IncrementalTaskInputs inputs = Mocks.mockIncrementalTaskInputs(task.getTarget());
                task.setApply();
                task.performAction(inputs);
            }));
}
项目:Reer    文件:IncrementalCompilerDecorator.java   
public Compiler<JavaCompileSpec> prepareCompiler(IncrementalTaskInputs inputs) {
    Compiler<JavaCompileSpec> compiler = getCompiler(inputs, sourceDirs);
    return new IncrementalCompilationFinalizer(compiler, jarClasspathSnapshotMaker, classSetAnalysisUpdater);
}
项目:Reer    文件:DefaultTaskClassInfoStore.java   
protected void doExecute(Task task, String methodName) {
    JavaReflectionUtil.method(task, Object.class, methodName, IncrementalTaskInputs.class).invoke(task, taskArtifactState.getInputChanges());
    taskArtifactState = null;
}
项目:Reer    文件:ShortCircuitTaskArtifactStateRepository.java   
public IncrementalTaskInputs getInputChanges() {
    return instantiator.newInstance(RebuildIncrementalTaskInputs.class, task);
}
项目:Reer    文件:NoHistoryArtifactState.java   
public IncrementalTaskInputs getInputChanges() {
    throw new UnsupportedOperationException();
}
项目:Pushjet-Android    文件:IncrementalCompilerDecorator.java   
public Compiler<JavaCompileSpec> prepareCompiler(final IncrementalTaskInputs inputs) {
    final Compiler<JavaCompileSpec> compiler = getCompiler(inputs, sourceDirs);
    return new IncrementalCompilationFinalizer(compiler, jarClasspathSnapshotMaker, classSetAnalysisUpdater);
}
项目:Pushjet-Android    文件:AnnotationProcessingTaskFactory.java   
protected void doExecute(Task task, String methodName) {
    JavaReflectionUtil.method(task, Object.class, methodName, IncrementalTaskInputs.class).invoke(task, taskArtifactState.getInputChanges());
    taskArtifactState = null;
}
项目:Pushjet-Android    文件:ShortCircuitTaskArtifactStateRepository.java   
public IncrementalTaskInputs getInputChanges() {
    return instantiator.newInstance(RebuildIncrementalTaskInputs.class, task, FilesSnapshotSet.EMPTY);
}
项目:Pushjet-Android    文件:NoHistoryArtifactState.java   
public IncrementalTaskInputs getInputChanges() {
    throw new UnsupportedOperationException();
}
项目:Pushjet-Android    文件:AnnotationProcessingTaskFactory.java   
protected void doExecute(Task task, String methodName) {
    JavaReflectionUtil.method(task, Object.class, methodName, IncrementalTaskInputs.class).invoke(task, taskArtifactState.getInputChanges());
    taskArtifactState = null;
}
项目:Pushjet-Android    文件:ShortCircuitTaskArtifactStateRepository.java   
public IncrementalTaskInputs getInputChanges() {
    return instantiator.newInstance(RebuildIncrementalTaskInputs.class, task);
}
项目:Pushjet-Android    文件:NoHistoryArtifactState.java   
public IncrementalTaskInputs getInputChanges() {
    throw new UnsupportedOperationException();
}