use of org.gradle.process.ExecSpec in project gradle by gradle.
the class NotifySend method send.
@Override
public void send(final String title, final String message) {
final File exe = OperatingSystem.current().findInPath("notify-send");
if (exe == null) {
throw new AnnouncerUnavailableException("Could not find 'notify-send' in the path.");
}
processOperations.exec(new Action<ExecSpec>() {
@Override
public void execute(ExecSpec execSpec) {
execSpec.executable(exe);
File icon = iconProvider.getIcon(32, 32);
if (icon != null) {
execSpec.args("-i", icon.getAbsolutePath());
}
execSpec.args("--hint=int:transient:1");
execSpec.args(title, message);
}
});
}
use of org.gradle.process.ExecSpec in project gradle by gradle.
the class InstallXCTestBundle method installToDir.
private void installToDir(final File bundleDir, final File bundleFile) throws IOException {
getFileOperations().sync(new Action<CopySpec>() {
@Override
public void execute(CopySpec copySpec) {
copySpec.from(bundleFile, new Action<CopySpec>() {
@Override
public void execute(CopySpec copySpec) {
copySpec.into("Contents/MacOS");
}
});
copySpec.into(bundleDir);
}
});
File outputFile = new File(bundleDir, "Contents/Info.plist");
Files.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + "<plist version=\"1.0\">\n" + "<dict/>\n" + "</plist>", outputFile, Charset.forName("UTF-8"));
getProject().exec(new Action<ExecSpec>() {
@Override
public void execute(ExecSpec execSpec) {
execSpec.setWorkingDir(bundleDir);
execSpec.executable(getSwiftStdlibToolLocator().find());
execSpec.args("--copy", "--scan-executable", bundleFile.getAbsolutePath(), "--destination", new File(bundleDir, "Contents/Frameworks").getAbsolutePath(), "--platform", "macosx", "--resource-destination", new File(bundleDir, "Contents/Resources").getAbsolutePath(), "--scan-folder", new File(bundleDir, "Contents/Frameworks").getAbsolutePath());
}
}).assertNormalExitValue();
}
use of org.gradle.process.ExecSpec in project gradle by gradle.
the class IdePlugin method addWorkspace.
protected void addWorkspace(final IdeWorkspace workspace) {
lifecycleTask.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
System.out.println(String.format("Generated %s at %s", workspace.getDisplayName(), new ConsoleRenderer().asClickableFileUrl(workspace.getLocation().get().getAsFile())));
}
});
Task openTask = project.getTasks().create("open" + StringUtils.capitalize(getLifecycleTaskName()));
openTask.dependsOn(lifecycleTask);
openTask.setGroup("IDE");
openTask.setDescription("Opens the " + workspace.getDisplayName());
openTask.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
if (OperatingSystem.current().isMacOsX()) {
project.exec(new Action<ExecSpec>() {
@Override
public void execute(ExecSpec execSpec) {
execSpec.commandLine("open", workspace.getLocation().get());
}
});
} else {
try {
Desktop.getDesktop().open(workspace.getLocation().get().getAsFile());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
});
}
use of org.gradle.process.ExecSpec in project gradle by gradle.
the class UnexportMainSymbol method unexport.
@TaskAction
public void unexport() {
final File mainObjectFile = getMainObject();
if (mainObjectFile != null) {
final File relocatedMainObject = outputDirectory.file(mainObjectFile.getName()).get().getAsFile();
getProject().exec(new Action<ExecSpec>() {
@Override
public void execute(ExecSpec execSpec) {
if (OperatingSystem.current().isMacOsX()) {
// TODO: Locate this tool from a tool provider
execSpec.executable("ld");
execSpec.args(mainObjectFile);
execSpec.args("-o", relocatedMainObject);
// relink, produce another object file
execSpec.args("-r");
// hide _main symbol
execSpec.args("-unexported_symbol", "_main");
} else if (OperatingSystem.current().isLinux()) {
// TODO: Locate this tool from a tool provider
execSpec.executable("objcopy");
// hide main symbol
execSpec.args("-L", "main");
execSpec.args(mainObjectFile);
execSpec.args(relocatedMainObject);
} else {
throw new IllegalStateException("Do not know how to hide a main symbol on " + OperatingSystem.current());
}
}
});
setDidWork(true);
} else {
setDidWork(getProject().delete(outputDirectory));
}
}
use of org.gradle.process.ExecSpec in project gradle by gradle.
the class GrowlNotifyBackedAnnouncer method send.
@Override
public void send(final String title, final String message) {
final File exe = OperatingSystem.current().findInPath("growlnotify");
if (exe == null) {
throw new AnnouncerUnavailableException("Could not find 'growlnotify' in path.");
}
processOperations.exec(new Action<ExecSpec>() {
@Override
public void execute(ExecSpec execSpec) {
execSpec.executable(exe);
execSpec.args("-m", message);
File icon = iconProvider.getIcon(48, 48);
if (icon != null) {
execSpec.args("--image", icon.getAbsolutePath());
}
execSpec.args("-t", title);
}
});
}
Aggregations