类org.gradle.api.tasks.WorkResult源码实例Demo

下面列出了怎么用org.gradle.api.tasks.WorkResult的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pushfish-android   文件: GroovyCompile.java
@TaskAction
protected void compile() {
    checkGroovyClasspathIsNonEmpty();
    DefaultGroovyJavaJointCompileSpec spec = new DefaultGroovyJavaJointCompileSpec();
    spec.setSource(getSource());
    spec.setDestinationDir(getDestinationDir());
    spec.setClasspath(getClasspath());
    spec.setSourceCompatibility(getSourceCompatibility());
    spec.setTargetCompatibility(getTargetCompatibility());
    spec.setGroovyClasspath(getGroovyClasspath());
    spec.setCompileOptions(compileOptions);
    spec.setGroovyCompileOptions(groovyCompileOptions);
    if (spec.getGroovyCompileOptions().getStubDir() == null) {
        File dir = tempFileProvider.newTemporaryFile("groovy-java-stubs");
        GFileUtils.mkdirs(dir);
        spec.getGroovyCompileOptions().setStubDir(dir);
    }
    WorkResult result = compiler.execute(spec);
    setDidWork(result.getDidWork());
}
 
public WorkResult execute(ScalaJavaJointCompileSpec spec) {
    scalaCompiler.execute(spec);

    PatternFilterable patternSet = new PatternSet();
    patternSet.include("**/*.java");
    FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet);
    if (!javaSource.isEmpty()) {
        spec.setSource(javaSource);
        javaCompiler.execute(spec);
    }

    return new WorkResult() {
        public boolean getDidWork() {
            return true;
        }
    };
}
 
源代码3 项目: pushfish-android   文件: NativeCompiler.java
public WorkResult execute(T spec) {
    boolean windowsPathLimitation = OperatingSystem.current().isWindows();

    MutableCommandLineToolInvocation invocation = baseInvocation.copy();
    invocation.setWorkDirectory(spec.getObjectFileDir());
    if (useCommandFile) {
        invocation.addPostArgsAction(new GccOptionsFileArgTransformer(spec.getTempDir()));
    }

    Transformer<List<String>, File> outputFileArgTransformer = new Transformer<List<String>, File>() {
        public List<String> transform(File outputFile) {
            return Arrays.asList("-o", outputFile.getAbsolutePath());
        }
    };

    for (File sourceFile : spec.getSourceFiles()) {
        SingleSourceCompileArgTransformer<T> argTransformer = new SingleSourceCompileArgTransformer<T>(sourceFile,
                objectFileSuffix,
                new ShortCircuitArgsTransformer<T>(argsTransfomer),
                windowsPathLimitation,
                outputFileArgTransformer);
        invocation.setArgs(argTransformer.transform(spec));
        commandLineTool.execute(invocation);
    }
    return new SimpleWorkResult(!spec.getSourceFiles().isEmpty());
}
 
源代码4 项目: pushfish-android   文件: NativeCompiler.java
public WorkResult execute(T spec) {
    MutableCommandLineToolInvocation invocation = baseInvocation.copy();
    invocation.addPostArgsAction(new VisualCppOptionsFileArgTransformer(spec.getTempDir()));

    Transformer<List<String>, File> outputFileArgTransformer = new Transformer<List<String>, File>(){
        public List<String> transform(File outputFile) {
            return Arrays.asList("/Fo"+ outputFile.getAbsolutePath());
        }
    };
    for (File sourceFile : spec.getSourceFiles()) {
        String objectFileNameSuffix = ".obj";
        SingleSourceCompileArgTransformer<T> argTransformer = new SingleSourceCompileArgTransformer<T>(sourceFile,
                objectFileNameSuffix,
                new ShortCircuitArgsTransformer<T>(argsTransFormer),
                true,
                outputFileArgTransformer);
        invocation.setArgs(argTransformer.transform(specTransformer.transform(spec)));
        invocation.setWorkDirectory(spec.getObjectFileDir());
        commandLineTool.execute(invocation);
    }
    return new SimpleWorkResult(!spec.getSourceFiles().isEmpty());
}
 
源代码5 项目: Pushjet-Android   文件: GroovyCompile.java
@TaskAction
protected void compile() {
    checkGroovyClasspathIsNonEmpty();
    DefaultGroovyJavaJointCompileSpec spec = new DefaultGroovyJavaJointCompileSpec();
    spec.setSource(getSource());
    spec.setDestinationDir(getDestinationDir());
    spec.setClasspath(getClasspath());
    spec.setSourceCompatibility(getSourceCompatibility());
    spec.setTargetCompatibility(getTargetCompatibility());
    spec.setGroovyClasspath(getGroovyClasspath());
    spec.setCompileOptions(compileOptions);
    spec.setGroovyCompileOptions(groovyCompileOptions);
    if (spec.getGroovyCompileOptions().getStubDir() == null) {
        File dir = tempFileProvider.newTemporaryFile("groovy-java-stubs");
        GFileUtils.mkdirs(dir);
        spec.getGroovyCompileOptions().setStubDir(dir);
    }
    WorkResult result = compiler.execute(spec);
    setDidWork(result.getDidWork());
}
 
源代码6 项目: Pushjet-Android   文件: SyncCopyActionDecorator.java
public WorkResult execute(final CopyActionProcessingStream stream) {
    final Set<RelativePath> visited = new HashSet<RelativePath>();

    WorkResult didWork = delegate.execute(new CopyActionProcessingStream() {
        public void process(final CopyActionProcessingStreamAction action) {
            stream.process(new CopyActionProcessingStreamAction() {
                public void processFile(FileCopyDetailsInternal details) {
                    visited.add(details.getRelativePath());
                    action.processFile(details);
                }
            });
        }
    });

    SyncCopyActionDecoratorFileVisitor fileVisitor = new SyncCopyActionDecoratorFileVisitor(visited);

    MinimalFileTree walker = new DirectoryFileTree(baseDestDir).postfix();
    walker.visit(fileVisitor);
    visited.clear();

    return new SimpleWorkResult(didWork.getDidWork() || fileVisitor.didWork);
}
 
public WorkResult execute(ScalaJavaJointCompileSpec spec) {
    scalaCompiler.execute(spec);

    PatternFilterable patternSet = new PatternSet();
    patternSet.include("**/*.java");
    FileTree javaSource = spec.getSource().getAsFileTree().matching(patternSet);
    if (!javaSource.isEmpty()) {
        spec.setSource(javaSource);
        javaCompiler.execute(spec);
    }

    return new WorkResult() {
        public boolean getDidWork() {
            return true;
        }
    };
}
 
源代码8 项目: Pushjet-Android   文件: CommandLineTool.java
public WorkResult execute(T spec) {
    ExecAction compiler = execActionFactory.newExecAction();
    compiler.executable(executable);
    if (workDir != null) {
        compiler.workingDir(workDir);
    }

    List<String> args = specToArgs.transform(specTransformer.transform(spec));
    compiler.args(args);

    if (!path.isEmpty()) {
        String pathVar = OperatingSystem.current().getPathVar();
        String compilerPath = Joiner.on(File.pathSeparator).join(path);
        compilerPath = compilerPath + File.pathSeparator + System.getenv(pathVar);
        compiler.environment(pathVar, compilerPath);
    }

    compiler.environment(environment);

    try {
        compiler.execute();
    } catch (ExecException e) {
        throw new GradleException(String.format("%s failed; see the error output for details.", action), e);
    }
    return new SimpleWorkResult(true);
}
 
源代码9 项目: Pushjet-Android   文件: SyncCopyActionDecorator.java
public WorkResult execute(final CopyActionProcessingStream stream) {
    final Set<RelativePath> visited = new HashSet<RelativePath>();

    WorkResult didWork = delegate.execute(new CopyActionProcessingStream() {
        public void process(final CopyActionProcessingStreamAction action) {
            stream.process(new CopyActionProcessingStreamAction() {
                public void processFile(FileCopyDetailsInternal details) {
                    visited.add(details.getRelativePath());
                    action.processFile(details);
                }
            });
        }
    });

    SyncCopyActionDecoratorFileVisitor fileVisitor = new SyncCopyActionDecoratorFileVisitor(visited);

    MinimalFileTree walker = new DirectoryFileTree(baseDestDir).postfix();
    walker.visit(fileVisitor);
    visited.clear();

    return new SimpleWorkResult(didWork.getDidWork() || fileVisitor.didWork);
}
 
源代码10 项目: Pushjet-Android   文件: NativeCompiler.java
public WorkResult execute(T spec) {
    boolean didWork = false;
    boolean windowsPathLimitation = OperatingSystem.current().isWindows();

    String objectFileExtension = OperatingSystem.current().isWindows() ? ".obj" : ".o";
    for (File sourceFile : spec.getSourceFiles()) {
        String objectFileName = FilenameUtils.removeExtension(sourceFile.getName()) + objectFileExtension;
        WorkResult result = commandLineTool.inWorkDirectory(spec.getObjectFileDir())
                .withArguments(new SingleSourceCompileArgTransformer<T>(sourceFile,
                                        objectFileName,
                                        new ShortCircuitArgsTransformer(argsTransfomer),
                                        windowsPathLimitation,
                                        false))
                .execute(spec);
        didWork = didWork || result.getDidWork();
    }
    return new SimpleWorkResult(didWork);
}
 
public WorkResult compile(CoffeeScriptCompileSpec spec) {
    RhinoWorkerHandle<Boolean, SerializableCoffeeScriptCompileSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() {
        public void execute(JavaExecSpec javaExecSpec) {
            javaExecSpec.setWorkingDir(workingDir);
        }
    });

    final Boolean result = handle.process(new SerializableCoffeeScriptCompileSpec(spec));

    return new WorkResult() {
        public boolean getDidWork() {
            return result;
        }
    };
}
 
源代码12 项目: pushfish-android   文件: SunJavaCompiler.java
public WorkResult execute(JavaCompileSpec spec) {
    LOGGER.info("Compiling with Sun Java compiler API.");

    String[] options = createCommandLineOptions(spec);
    int exitCode = Main.compile(options);
    if (exitCode != 0) {
        throw new CompilationFailedException();
    }

    return new SimpleWorkResult(true);
}
 
源代码13 项目: Pushjet-Android   文件: DaemonJavaCompiler.java
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());
}
 
源代码14 项目: gradle-plugins   文件: SevenZip.java
@SneakyThrows
private WorkResult execute(CopyActionProcessingStream stream) {
    try (SevenZOutputFile outputFile = new SevenZOutputFile(getArchiveFile().get().getAsFile())) {

        if (contentCompression.isPresent()) {
            outputFile.setContentCompression(contentCompression.get());
        }

        stream.process(new StreamAction(outputFile));

        outputFile.finish();

        return WorkResults.didWork(true);
    }
}
 
private WorkResult delegateAndHandleErrors(GroovyJavaJointCompileSpec spec) {
    try {
        return delegate.execute(spec);
    } catch (CompilationFailedException e) {
        if (spec.getCompileOptions().isFailOnError()) {
            throw e;
        }
        LOGGER.debug("Ignoring compilation failure.");
        return new SimpleWorkResult(false);
    }
}
 
源代码16 项目: pushfish-android   文件: GccLinker.java
public WorkResult execute(LinkerSpec spec) {
    MutableCommandLineToolInvocation invocation = baseInvocation.copy();
    if (useCommandFile) {
        invocation.addPostArgsAction(new GccOptionsFileArgTransformer(spec.getTempDir()));
    }
    invocation.setArgs(argsTransformer.transform(spec));
    commandLineTool.execute(invocation);
    return new SimpleWorkResult(true);
}
 
源代码17 项目: pushfish-android   文件: ArStaticLibraryArchiver.java
public WorkResult execute(StaticLibraryArchiverSpec spec) {
    deletePreviousOutput(spec);

    MutableCommandLineToolInvocation invocation = baseInvocation.copy();
    invocation.setArgs(arguments.transform(spec));
    commandLineTool.execute(invocation);
    return new SimpleWorkResult(true);
}
 
源代码18 项目: gradle-plugins   文件: Cpio.java
@SneakyThrows
private WorkResult execute(CopyActionProcessingStream copyActionProcessingStream) {
    try (CpioArchiveOutputStream archiveOutputStream = new CpioArchiveOutputStream(
            new FileOutputStream(getArchiveFile().get().getAsFile()),
            format.get(),
            blockSize.get(),
            encoding.get()
    )) {
        copyActionProcessingStream.process(new StreamAction(archiveOutputStream, getFormat().get()));

        return WorkResults.didWork(true);
    }
}
 
源代码19 项目: Pushjet-Android   文件: WindowsResourceCompiler.java
public WorkResult execute(WindowsResourceCompileSpec spec) {
    boolean windowsPathLimitation = OperatingSystem.current().isWindows();
    MutableCommandLineToolInvocation invocation = baseInvocation.copy();
    spec = specTransformer.transform(spec);
    for (File sourceFile : spec.getSourceFiles()) {
        RcCompilerArgsTransformer argsTransformer = new RcCompilerArgsTransformer(sourceFile, windowsPathLimitation);
        invocation.setArgs(argsTransformer.transform(spec));
        invocation.setWorkDirectory(spec.getObjectFileDir());
        commandLineTool.execute(invocation);
    }
    return new SimpleWorkResult(!spec.getSourceFiles().isEmpty());
}
 
public WorkResult execute(final NativeCompileSpec spec) {
    return cacheAccess.useCache("incremental compile", new Factory<WorkResult>() {
        public WorkResult create() {
            IncrementalCompileProcessor processor = createProcessor(includes);
            return doIncrementalCompile(processor, spec);
        }
    });
}
 
源代码21 项目: pushfish-android   文件: LinkExeLinker.java
public WorkResult execute(LinkerSpec spec) {
    MutableCommandLineToolInvocation invocation = baseInvocation.copy();
    invocation.addPostArgsAction(new VisualCppOptionsFileArgTransformer(spec.getTempDir()));
    invocation.setArgs(argsTransformer.transform(specTransformer.transform(spec)));
    commandLineTool.execute(invocation);
    return new SimpleWorkResult(true);
}
 
public WorkResult execute(final CopyActionProcessingStream stream) {
    final Set<RelativePath> visitedFiles = new HashSet<RelativePath>();

    return delegate.execute(new CopyActionProcessingStream() {
        public void process(final CopyActionProcessingStreamAction action) {
            stream.process(new CopyActionProcessingStreamAction() {
                public void processFile(FileCopyDetailsInternal details) {
                    if (!details.isDirectory()) {
                        DuplicatesStrategy strategy = details.getDuplicatesStrategy();

                        if (!visitedFiles.add(details.getRelativePath())) {
                            if (strategy == DuplicatesStrategy.EXCLUDE) {
                                return;
                            } else if (strategy == DuplicatesStrategy.FAIL) {
                                throw new DuplicateFileCopyingException(String.format("Encountered duplicate path \"%s\" during copy operation configured with DuplicatesStrategy.FAIL", details.getRelativePath()));
                            } else if (strategy == DuplicatesStrategy.WARN) {
                                LOGGER.warn("Encountered duplicate path \"{}\" during copy operation configured with DuplicatesStrategy.WARN", details.getRelativePath());
                            }
                        }
                    }

                    action.processFile(details);
                }
            });
        }
    });
}
 
源代码23 项目: Pushjet-Android   文件: CopyActionExecuter.java
public WorkResult execute(final CopySpecInternal spec, CopyAction action) {
    final CopyAction effectiveVisitor = new DuplicateHandlingCopyActionDecorator(
            new NormalizingCopyActionDecorator(action, fileSystem)
    );

    CopyActionProcessingStream processingStream = new CopySpecBackedCopyActionProcessingStream(spec, instantiator, fileSystem);
    return effectiveVisitor.execute(processingStream);
}
 
源代码24 项目: pushfish-android   文件: Jdk6JavaCompiler.java
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);
}
 
源代码25 项目: pushfish-android   文件: NormalizingJavaCompiler.java
public WorkResult execute(JavaCompileSpec spec) {
    resolveAndFilterSourceFiles(spec);
    resolveClasspath(spec);
    resolveNonStringsInCompilerArgs(spec);
    logSourceFiles(spec);
    logCompilerArguments(spec);
    return delegateAndHandleErrors(spec);
}
 
源代码26 项目: pushfish-android   文件: NormalizingJavaCompiler.java
private WorkResult delegateAndHandleErrors(JavaCompileSpec spec) {
    try {
        return delegate.execute(spec);
    } catch (CompilationFailedException e) {
        if (spec.getCompileOptions().isFailOnError()) {
            throw e;
        }
        LOGGER.debug("Ignoring compilation failure.");
        return new SimpleWorkResult(false);
    }
}
 
源代码27 项目: pushfish-android   文件: CommandLineJavaCompiler.java
public WorkResult execute(JavaCompileSpec spec) {
    String executable = spec.getCompileOptions().getForkOptions().getExecutable();
    LOGGER.info("Compiling with Java command line compiler '{}'.", executable);

    ExecHandle handle = createCompilerHandle(executable, spec);
    executeCompiler(handle);

    return new SimpleWorkResult(true);
}
 
public WorkResult copy(final Closure closure) {
    return fileCopier.copy(new Action<CopySpec>() {
        public void execute(CopySpec copySpec) {
            copySpec.from(DefaultConfigurableFileTree.this);
            ConfigureUtil.configure(closure, copySpec);
        }
    });
}
 
public WorkResult execute(GroovyJavaJointCompileSpec spec) {
    resolveAndFilterSourceFiles(spec);
    resolveClasspath(spec);
    resolveNonStringsInCompilerArgs(spec);
    logSourceFiles(spec);
    logCompilerArguments(spec);
    return delegateAndHandleErrors(spec);
}
 
源代码30 项目: pushfish-android   文件: NormalizingJavaCompiler.java
private WorkResult delegateAndHandleErrors(JavaCompileSpec spec) {
    try {
        return delegate.execute(spec);
    } catch (CompilationFailedException e) {
        if (spec.getCompileOptions().isFailOnError()) {
            throw e;
        }
        LOGGER.debug("Ignoring compilation failure.");
        return new SimpleWorkResult(false);
    }
}
 
 类所在包
 类方法
 同包方法