当前位置: 首页>>代码示例>>Java>>正文


Java JavaCompileSpec类代码示例

本文整理汇总了Java中org.gradle.api.internal.tasks.compile.JavaCompileSpec的典型用法代码示例。如果您正苦于以下问题:Java JavaCompileSpec类的具体用法?Java JavaCompileSpec怎么用?Java JavaCompileSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaCompileSpec类属于org.gradle.api.internal.tasks.compile包,在下文中一共展示了JavaCompileSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
@Override
public WorkResult execute(JavaCompileSpec spec) {
    Timer clock = Timers.startTimer();
    JarClasspathSnapshot jarClasspathSnapshot = jarClasspathSnapshotProvider.getJarClasspathSnapshot(spec.getClasspath());
    RecompilationSpec recompilationSpec = recompilationSpecProvider.provideRecompilationSpec(inputs, previousCompilation, jarClasspathSnapshot);

    if (recompilationSpec.isFullRebuildNeeded()) {
        LOG.lifecycle("Full recompilation is required because {}. Analysis took {}.", recompilationSpec.getFullRebuildCause(), clock.getElapsed());
        return cleaningCompiler.execute(spec);
    }

    incrementalCompilationInitilizer.initializeCompilation(spec, recompilationSpec.getClassNames());
    if (spec.getSource().isEmpty()) {
        LOG.lifecycle("None of the classes needs to be compiled! Analysis took {}. ", clock.getElapsed());
        return new RecompilationNotNecessary();
    }

    try {
        //use the original compiler to avoid cleaning up all the files
        return cleaningCompiler.getCompiler().execute(spec);
    } finally {
        LOG.lifecycle("Incremental compilation of {} classes completed in {}.", recompilationSpec.getClassNames().size(), clock.getElapsed());
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:SelectiveCompiler.java

示例2: getCompiler

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
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);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:IncrementalCompilerDecorator.java

示例3: initializeCompilation

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public void initializeCompilation(JavaCompileSpec spec, Collection<String> staleClasses) {
    if (staleClasses.isEmpty()) {
        spec.setSource(new SimpleFileCollection());
        return; //do nothing. No classes need recompilation.
    }

    Factory<PatternSet> patternSetFactory = fileOperations.getFileResolver().getPatternSetFactory();
    PatternSet classesToDelete = patternSetFactory.create();
    PatternSet sourceToCompile = patternSetFactory.create();

    preparePatterns(staleClasses, classesToDelete, sourceToCompile);

    //selectively configure the source
    spec.setSource(spec.getSource().getAsFileTree().matching(sourceToCompile));
    //since we're compiling selectively we need to include the classes compiled previously
    spec.setClasspath(Iterables.concat(spec.getClasspath(), asList(spec.getDestinationDir())));
    //get rid of stale files
    FileTree deleteMe = fileOperations.fileTree(spec.getDestinationDir()).matching(classesToDelete);
    fileOperations.delete(deleteMe);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:IncrementalCompilationInitializer.java

示例4: execute

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public WorkResult execute(JavaCompileSpec spec) {
    Clock clock = new Clock();
    JarClasspathSnapshot jarClasspathSnapshot = jarClasspathSnapshotProvider.getJarClasspathSnapshot(spec.getClasspath());
    RecompilationSpec recompilationSpec = recompilationSpecProvider.provideRecompilationSpec(inputs, previousCompilation, jarClasspathSnapshot);

    if (recompilationSpec.isFullRebuildNeeded()) {
        LOG.lifecycle("Full recompilation is required because {}. Analysis took {}.", recompilationSpec.getFullRebuildCause(), clock.getTime());
        return cleaningCompiler.execute(spec);
    }

    incrementalCompilationInitilizer.initializeCompilation(spec, recompilationSpec.getClassNames());
    if (spec.getSource().isEmpty()) {
        LOG.lifecycle("None of the classes needs to compiled! Analysis took {}. ", clock.getTime());
        return new RecompilationNotNecessary();
    }

    try {
        //use the original compiler to avoid cleaning up all the files
        return cleaningCompiler.getCompiler().execute(spec);
    } finally {
        LOG.lifecycle("Incremental compilation of {} classes completed in {}.", recompilationSpec.getClassNames().size(), clock.getTime());
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:24,代码来源:SelectiveCompiler.java

示例5: getCompiler

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
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);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:18,代码来源:IncrementalCompilerDecorator.java

示例6: initializeCompilation

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public void initializeCompilation(JavaCompileSpec spec, Collection<String> staleClasses) {
    if (staleClasses.isEmpty()) {
        spec.setSource(new SimpleFileCollection());
        return; //do nothing. No classes need recompilation.
    }

    PatternSet classesToDelete = new PatternSet();
    PatternSet sourceToCompile = new PatternSet();

    preparePatterns(staleClasses, classesToDelete, sourceToCompile);

    //selectively configure the source
    spec.setSource(spec.getSource().getAsFileTree().matching(sourceToCompile));
    //since we're compiling selectively we need to include the classes compiled previously
    spec.setClasspath(Iterables.concat(spec.getClasspath(), asList(spec.getDestinationDir())));
    //get rid of stale files
    FileTree deleteMe = fileOperations.fileTree(spec.getDestinationDir()).matching(classesToDelete);
    fileOperations.delete(deleteMe);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:20,代码来源:IncrementalCompilationInitializer.java

示例7: compile

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
@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);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:40,代码来源:JavaCompile.java

示例8: execute

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
@Override
public WorkResult execute(JavaCompileSpec spec) {
    WorkResult out = delegate.execute(spec);

    if (!(out instanceof RecompilationNotNecessary)) {
        //if recompilation was skipped
        //there's no point in updating because we have exactly the same output classes)
        updater.updateAnalysis(spec);
    }

    writer.storeJarSnapshots(spec.getClasspath());

    return out;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:15,代码来源:IncrementalCompilationFinalizer.java

示例9: updateAnalysis

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public void updateAnalysis(JavaCompileSpec spec) {
    Timer clock = Timers.startTimer();
    FileTree tree = fileOperations.fileTree(spec.getDestinationDir());
    ClassFilesAnalyzer analyzer = new ClassFilesAnalyzer(this.analyzer);
    tree.visit(analyzer);
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getElapsed());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:ClassSetAnalysisUpdater.java

示例10: compile

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
@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);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:40,代码来源:JavaCompile.java

示例11: execute

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public WorkResult execute(JavaCompileSpec spec) {
    WorkResult out = delegate.execute(spec);

    if (!(out instanceof RecompilationNotNecessary)) {
        //if recompilation was skipped
        //there's no point in updating because we have exactly the same output classes)
        updater.updateAnalysis(spec);
    }

    writer.storeJarSnapshots(spec.getClasspath());

    return out;
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:14,代码来源:IncrementalCompilationFinalizer.java

示例12: updateAnalysis

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public void updateAnalysis(JavaCompileSpec spec) {
    Clock clock = new Clock();
    FileTree tree = fileOperations.fileTree(spec.getDestinationDir());
    ClassFilesAnalyzer analyzer = new ClassFilesAnalyzer(this.analyzer);
    tree.visit(analyzer);
    ClassSetAnalysisData data = analyzer.getAnalysis();
    stash.put(data);
    LOG.info("Class dependency analysis for incremental compilation took {}.", clock.getTime());
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:10,代码来源:ClassSetAnalysisUpdater.java

示例13: execute

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public WorkResult execute(JavaCompileSpec spec) {
    ForkOptions forkOptions = spec.getCompileOptions().getForkOptions();
    DaemonForkOptions daemonForkOptions = new DaemonForkOptions(
            forkOptions.getMemoryInitialSize(), forkOptions.getMemoryMaximumSize(), forkOptions.getJvmArgs(),
            Collections.<File>emptyList(), Collections.singleton("com.sun.tools.javac"));
    CompilerDaemon daemon = compilerDaemonManager.getDaemon(project.getRootProject().getProjectDir(), daemonForkOptions);
    CompileResult result = daemon.execute(delegate, spec);
    if (result.isSuccess()) {
        return result;
    }
    throw UncheckedException.throwAsUncheckedException(result.getException());
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:13,代码来源:DaemonJavaCompiler.java

示例14: execute

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
public WorkResult execute(JavaCompileSpec spec) {
    LOGGER.info("Compiling with JDK Java compiler API.");

    JavaCompiler.CompilationTask task = createCompileTask(spec);
    boolean success = task.call();
    if (!success) {
        throw new CompilationFailedException();
    }

    return new SimpleWorkResult(true);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:12,代码来源:Jdk6JavaCompiler.java

示例15: createCompileTask

import org.gradle.api.internal.tasks.compile.JavaCompileSpec; //导入依赖的package包/类
private JavaCompiler.CompilationTask createCompileTask(JavaCompileSpec spec) {
    List<String> options = new JavaCompilerArgumentsBuilder(spec).build();
    JavaCompiler compiler = findCompiler();
    if(compiler==null){
        throw new RuntimeException("Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.");
    }
    CompileOptions compileOptions = spec.getCompileOptions();
    StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, compileOptions.getEncoding() != null ? Charset.forName(compileOptions.getEncoding()) : null);
    Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(spec.getSource());
    return compiler.getTask(null, null, null, options, null, compilationUnits);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:12,代码来源:Jdk6JavaCompiler.java


注:本文中的org.gradle.api.internal.tasks.compile.JavaCompileSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。