Search in sources :

Example 1 with SimpleWorkResult

use of org.gradle.api.internal.tasks.SimpleWorkResult in project gradle by gradle.

the class GoogleClosureCompiler method execute.

@Override
public WorkResult execute(JavaScriptCompileSpec spec) {
    JavaScriptCompileDestinationCalculator destinationCalculator = new JavaScriptCompileDestinationCalculator(spec.getDestinationDir());
    List<String> allErrors = Lists.newArrayList();
    for (RelativeFile sourceFile : spec.getSources()) {
        allErrors.addAll(compile(sourceFile, spec, destinationCalculator));
    }
    if (allErrors.isEmpty()) {
        return new SimpleWorkResult(true);
    } else {
        throw new SourceTransformationException(String.format("Minification failed with the following errors:\n\t%s", StringUtils.join(allErrors, "\n\t")), null);
    }
}
Also used : RelativeFile(org.gradle.api.internal.file.RelativeFile) SourceTransformationException(org.gradle.plugins.javascript.base.SourceTransformationException) SimpleWorkResult(org.gradle.api.internal.tasks.SimpleWorkResult)

Example 2 with SimpleWorkResult

use of org.gradle.api.internal.tasks.SimpleWorkResult in project gradle by gradle.

the class ArStaticLibraryArchiver method execute.

@Override
public WorkResult execute(final StaticLibraryArchiverSpec spec) {
    deletePreviousOutput(spec);
    List<String> args = argsTransformer.transform(spec);
    invocationContext.getArgAction().execute(args);
    final CommandLineToolInvocation invocation = invocationContext.createInvocation("archiving " + spec.getOutputFile().getName(), args, spec.getOperationLogger());
    buildOperationProcessor.run(commandLineToolInvocationWorker, new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            buildQueue.add(invocation);
        }
    });
    return new SimpleWorkResult(true);
}
Also used : CommandLineToolInvocation(org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) SimpleWorkResult(org.gradle.api.internal.tasks.SimpleWorkResult)

Example 3 with SimpleWorkResult

use of org.gradle.api.internal.tasks.SimpleWorkResult in project gradle by gradle.

the class LinkExeLinker method execute.

@Override
public WorkResult execute(final LinkerSpec spec) {
    LinkerSpec transformedSpec = specTransformer.transform(spec);
    List<String> args = argsTransformer.transform(transformedSpec);
    invocationContext.getArgAction().execute(args);
    new VisualCppOptionsFileArgsWriter(spec.getTempDir()).execute(args);
    final CommandLineToolInvocation invocation = invocationContext.createInvocation("linking " + spec.getOutputFile().getName(), args, spec.getOperationLogger());
    buildOperationProcessor.run(commandLineToolInvocationWorker, new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            buildQueue.add(invocation);
        }
    });
    return new SimpleWorkResult(true);
}
Also used : SharedLibraryLinkerSpec(org.gradle.nativeplatform.internal.SharedLibraryLinkerSpec) LinkerSpec(org.gradle.nativeplatform.internal.LinkerSpec) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) SimpleWorkResult(org.gradle.api.internal.tasks.SimpleWorkResult)

Example 4 with SimpleWorkResult

use of org.gradle.api.internal.tasks.SimpleWorkResult in project gradle by gradle.

the class GccLinker method execute.

@Override
public WorkResult execute(final LinkerSpec spec) {
    List<String> args = argsTransformer.transform(spec);
    invocationContext.getArgAction().execute(args);
    if (useCommandFile) {
        new GccOptionsFileArgsWriter(spec.getTempDir()).execute(args);
    }
    final CommandLineToolInvocation invocation = invocationContext.createInvocation("linking " + spec.getOutputFile().getName(), args, spec.getOperationLogger());
    buildOperationProcessor.run(commandLineToolInvocationWorker, new Action<BuildOperationQueue<CommandLineToolInvocation>>() {

        @Override
        public void execute(BuildOperationQueue<CommandLineToolInvocation> buildQueue) {
            buildQueue.setLogLocation(spec.getOperationLogger().getLogLocation());
            buildQueue.add(invocation);
        }
    });
    return new SimpleWorkResult(true);
}
Also used : CommandLineToolInvocation(org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation) BuildOperationQueue(org.gradle.internal.operations.BuildOperationQueue) SimpleWorkResult(org.gradle.api.internal.tasks.SimpleWorkResult)

Example 5 with SimpleWorkResult

use of org.gradle.api.internal.tasks.SimpleWorkResult in project gradle by gradle.

the class TarCopyAction method execute.

public WorkResult execute(final CopyActionProcessingStream stream) {
    final OutputStream outStr;
    try {
        outStr = compressor.createArchiveOutputStream(tarFile);
    } catch (Exception e) {
        throw new GradleException(String.format("Could not create TAR '%s'.", tarFile), e);
    }
    IoActions.withResource(outStr, new ErroringAction<OutputStream>() {

        @Override
        protected void doExecute(final OutputStream outStr) throws Exception {
            TarOutputStream tarOutStr;
            try {
                tarOutStr = new TarOutputStream(outStr);
            } catch (Exception e) {
                throw new GradleException(String.format("Could not create TAR '%s'.", tarFile), e);
            }
            tarOutStr.setLongFileMode(TarOutputStream.LONGFILE_GNU);
            stream.process(new StreamAction(tarOutStr));
            tarOutStr.close();
        }
    });
    return new SimpleWorkResult(true);
}
Also used : TarOutputStream(org.apache.tools.tar.TarOutputStream) OutputStream(java.io.OutputStream) TarOutputStream(org.apache.tools.tar.TarOutputStream) GradleException(org.gradle.api.GradleException) SimpleWorkResult(org.gradle.api.internal.tasks.SimpleWorkResult) CopyActionProcessingStreamAction(org.gradle.api.internal.file.CopyActionProcessingStreamAction) GradleException(org.gradle.api.GradleException)

Aggregations

SimpleWorkResult (org.gradle.api.internal.tasks.SimpleWorkResult)15 File (java.io.File)5 BuildOperationQueue (org.gradle.internal.operations.BuildOperationQueue)5 CommandLineToolInvocation (org.gradle.nativeplatform.toolchain.internal.CommandLineToolInvocation)3 GradleException (org.gradle.api.GradleException)2 CopyActionProcessingStreamAction (org.gradle.api.internal.file.CopyActionProcessingStreamAction)2 RelativeFile (org.gradle.api.internal.file.RelativeFile)2 WorkResult (org.gradle.api.tasks.WorkResult)2 GroovyClassLoader (groovy.lang.GroovyClassLoader)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TarOutputStream (org.apache.tools.tar.TarOutputStream)1 CompilationUnit (org.codehaus.groovy.control.CompilationUnit)1 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)1 SimpleMessage (org.codehaus.groovy.control.messages.SimpleMessage)1 JavaAwareCompilationUnit (org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit)1 JavaCompiler (org.codehaus.groovy.tools.javac.JavaCompiler)1 JavaCompilerFactory (org.codehaus.groovy.tools.javac.JavaCompilerFactory)1 FileCollection (org.gradle.api.file.FileCollection)1