public void taskAction()

in plugins/sandbox/src/main/java/co/elastic/gradle/sandbox/SandboxExecBaseTask.java [203:254]


    public void taskAction() throws IOException {

        // Make sure to delete previous runs so we don't use infinite disk space
        getFileOperations().delete(baseDir);

        // The result of the command e.x. exit code zero is a valid task output so we store a marker file to have some
        // output to work with caching.
        Path markerFile = sandbox.resolve(rootProjectPath.relativize(marker.toPath()));
        Files.createDirectories(markerFile.getParent());
        Files.write(markerFile, new byte[]{});

        linkFilesIntoSandbox();

        ExecResult exec;
        int tryNr = 1;
        do {
            environment("GRADLE_SANDBOX_TRY_NR", String.valueOf(tryNr));
            exec = doExec();
            if (exec.getExitValue() != 0 && tryNr != maxTries) {
                getLogger().warn("\n== Command failed on try {}, but {} are allowed, going to retry ==\n", tryNr, maxTries);
            }

            if (exec.getExitValue() == 0) {
                List<Path> missing = Stream.concat(outputFiles.stream(), outputDirs.stream())
                        .map(this::getPathInSandbox)
                        .filter(path -> !Files.exists(path))
                        .collect(Collectors.toList());
                if (!missing.isEmpty()) {
                    throw new IllegalArgumentException(
                            "Command succeeded, but expected output(s) doesn't exist in sandbox: \n" +
                                    missing.stream()
                                            .map(each -> "  -" + sandbox.relativize(each))
                                            .collect(Collectors.joining("\n"))
                    );
                }
            }
            final Path outputsTry = outputsRoot.resolve("try-" + tryNr);
            Files.createDirectories(outputsTry);
            linkFilesOutOfSandbox(outputsTry);
            if (exec.getExitValue() == 0) {
                linkFilesOutOfSandbox(rootProjectPath);
                break;
            }
            tryNr++;
        } while (tryNr <= maxTries);
        if (exec.getExitValue() != 0) {
            throw new IllegalStateException(
                    "Sandbox exec " + getPath() + " failed with exit code " + exec.getExitValue() +
                            ".\nCheck the task output for details."
            );
        }
    }