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);
}
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);
}
});
}
}
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);
}
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()));
}
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[]
}
Aggregations