Search in sources :

Example 96 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class Assemble method assemble.

@TaskAction
public void assemble() {
    BuildOperationLogger operationLogger = getOperationLoggerFactory().newOperationLogger(getName(), getTemporaryDir());
    boolean cleanedOutputs = StaleOutputCleaner.cleanOutputs(getDeleter(), getOutputs().getPreviousOutputFiles(), getObjectFileDir());
    DefaultAssembleSpec spec = new DefaultAssembleSpec();
    spec.setTempDir(getTemporaryDir());
    spec.setObjectFileDir(getObjectFileDir());
    spec.source(getSource());
    spec.include(getIncludes());
    spec.args(getAssemblerArgs());
    spec.setOperationLogger(operationLogger);
    NativeToolChainInternal nativeToolChain = (NativeToolChainInternal) toolChain.get();
    NativePlatformInternal nativePlatform = (NativePlatformInternal) targetPlatform.get();
    Compiler<AssembleSpec> compiler = nativeToolChain.select(nativePlatform).newCompiler(AssembleSpec.class);
    WorkResult result = BuildOperationLoggingCompilerDecorator.wrap(compiler).execute(spec);
    setDidWork(result.getDidWork() || cleanedOutputs);
}
Also used : NativeToolChainInternal(org.gradle.nativeplatform.toolchain.internal.NativeToolChainInternal) BuildOperationLogger(org.gradle.internal.operations.logging.BuildOperationLogger) AssembleSpec(org.gradle.nativeplatform.toolchain.internal.compilespec.AssembleSpec) DefaultAssembleSpec(org.gradle.language.assembler.internal.DefaultAssembleSpec) NativePlatformInternal(org.gradle.nativeplatform.platform.internal.NativePlatformInternal) DefaultAssembleSpec(org.gradle.language.assembler.internal.DefaultAssembleSpec) WorkResult(org.gradle.api.tasks.WorkResult) TaskAction(org.gradle.api.tasks.TaskAction)

Example 97 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class WorkerTask method executeTask.

@TaskAction
public void executeTask() {
    for (int i = 0; i < outputSize; i++) {
        final int index = i;
        getWorkerExecutor().submit(UnitOfWork.class, new Action<WorkerConfiguration>() {

            @Override
            public void execute(WorkerConfiguration workerConfiguration) {
                workerConfiguration.setDisplayName(getName() + " work for " + index);
                workerConfiguration.setIsolationMode(isolationMode);
                File outputFile = new File(outputDir, "out-" + index + ".txt");
                workerConfiguration.setParams(index, outputFile);
            }
        });
    }
}
Also used : WorkerConfiguration(org.gradle.workers.WorkerConfiguration) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Example 98 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class InstallXCTestBundle method install.

@TaskAction
protected void install() throws IOException {
    File bundleFile = bundleBinaryFile.get().getAsFile();
    File bundleDir = installDirectory.get().file(bundleFile.getName() + ".xctest").getAsFile();
    installToDir(bundleDir, bundleFile);
    File runScript = getRunScriptFile().get().getAsFile();
    String runScriptText = "#!/bin/sh" + "\nAPP_BASE_NAME=`dirname \"$0\"`" + "\nXCTEST_LOCATION=`xcrun --find xctest`" + "\nexec \"$XCTEST_LOCATION\" \"$@\" \"$APP_BASE_NAME/" + bundleDir.getName() + "\"" + "\n";
    GFileUtils.writeFile(runScriptText, runScript);
    getFileSystem().chmod(runScript, 0755);
}
Also used : File(java.io.File) RegularFile(org.gradle.api.file.RegularFile) InputFile(org.gradle.api.tasks.InputFile) TaskAction(org.gradle.api.tasks.TaskAction)

Example 99 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class HtmlDependencyReportTask method generate.

@TaskAction
public void generate() {
    if (!reports.getHtml().getRequired().get()) {
        setDidWork(false);
        return;
    }
    HtmlDependencyReporter reporter = new HtmlDependencyReporter(getVersionSelectorScheme(), getVersionComparator(), getVersionParser());
    reporter.render(getProjects(), reports.getHtml().getOutputLocation().getAsFile().get());
    getProject().getLogger().lifecycle("See the report at: {}", new ConsoleRenderer().asClickableFileUrl(reports.getHtml().getEntryPoint()));
}
Also used : HtmlDependencyReporter(org.gradle.api.reporting.dependencies.internal.HtmlDependencyReporter) ConsoleRenderer(org.gradle.internal.logging.ConsoleRenderer) TaskAction(org.gradle.api.tasks.TaskAction)

Example 100 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class GitClone method gitClone.

// tag::git-clone[]
@TaskAction
public void gitClone() throws IOException {
    // <2>
    File destinationDir = getDestinationDir().get().getAsFile().getAbsoluteFile();
    String remoteUri = getRemoteUri().get();
    // end::git-clone[]
    if (isCorrectCheckout(destinationDir, remoteUri)) {
        getExecOperations().exec(spec -> {
            spec.commandLine("git", "fetch", "origin");
            spec.setWorkingDir(destinationDir);
        });
    } else {
        getFileSystemOperations().delete(spec -> {
            spec.delete(destinationDir);
        });
        if (!destinationDir.mkdirs()) {
            throw new IOException("Could not create directory " + destinationDir);
        }
        getExecOperations().exec(spec -> spec.commandLine("git", "clone", "--no-checkout", remoteUri, destinationDir.getAbsolutePath()));
    }
    getExecOperations().exec(spec -> {
        spec.commandLine("git", "checkout", getCommitId().get());
        spec.setWorkingDir(destinationDir);
    });
    getExecOperations().exec(spec -> {
        spec.commandLine("git", "clean", "-fdx");
        spec.setWorkingDir(destinationDir);
    });
// tag::git-clone[]
}
Also used : IOException(java.io.IOException) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TaskAction (org.gradle.api.tasks.TaskAction)234 File (java.io.File)97 IOException (java.io.IOException)54 GradleException (org.gradle.api.GradleException)48 ArrayList (java.util.ArrayList)34 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)32 Path (java.nio.file.Path)25 OutputFile (org.gradle.api.tasks.OutputFile)25 DefaultTask (org.gradle.api.DefaultTask)22 InputFile (org.gradle.api.tasks.InputFile)21 Map (java.util.Map)19 Project (org.gradle.api.Project)18 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)16 List (java.util.List)15 FileCollection (org.gradle.api.file.FileCollection)15 HashMap (java.util.HashMap)14 FileWriter (java.io.FileWriter)13 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)12 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)12 WorkResult (org.gradle.api.tasks.WorkResult)11