Search in sources :

Example 1 with ExecSpec

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);
        }
    });
}
Also used : ExecSpec(org.gradle.process.ExecSpec) File(java.io.File)

Example 2 with ExecSpec

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();
}
Also used : CopySpec(org.gradle.api.file.CopySpec) TaskAction(org.gradle.api.tasks.TaskAction) Action(org.gradle.api.Action) ExecSpec(org.gradle.process.ExecSpec) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile) InputFile(org.gradle.api.tasks.InputFile)

Example 3 with ExecSpec

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);
                }
            }
        }
    });
}
Also used : Task(org.gradle.api.Task) Action(org.gradle.api.Action) UncheckedIOException(org.gradle.api.UncheckedIOException) ConsoleRenderer(org.gradle.internal.logging.ConsoleRenderer) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) ExecSpec(org.gradle.process.ExecSpec)

Example 4 with ExecSpec

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));
    }
}
Also used : ExecSpec(org.gradle.process.ExecSpec) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) TaskAction(org.gradle.api.tasks.TaskAction)

Example 5 with ExecSpec

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);
        }
    });
}
Also used : ExecSpec(org.gradle.process.ExecSpec) File(java.io.File)

Aggregations

ExecSpec (org.gradle.process.ExecSpec)7 File (java.io.File)6 Action (org.gradle.api.Action)2 InputFile (org.gradle.api.tasks.InputFile)2 TaskAction (org.gradle.api.tasks.TaskAction)2 IOException (java.io.IOException)1 Task (org.gradle.api.Task)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 CopySpec (org.gradle.api.file.CopySpec)1 RegularFile (org.gradle.api.file.RegularFile)1 ConsoleRenderer (org.gradle.internal.logging.ConsoleRenderer)1