Java Code Examples for org.gradle.api.project#exec()
The following examples show how to use
org.gradle.api.project#exec() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuildHelper.java From atlas with Apache License 2.0 | 6 votes |
public static synchronized File doZipAlign(final AndroidBuilder androidBuilder, Project project, final File apkFile) { final File zipalignedFile = new File(apkFile.getParent(), apkFile.getName().replace(".apk", "-zipaligned.apk")); project.exec(new Action<ExecSpec>() { @Override public void execute(ExecSpec execSpec) { String path = androidBuilder.getTargetInfo() .getBuildTools().getPath(ZIP_ALIGN); execSpec.executable(new File(path)); execSpec.args("-f", "4"); execSpec.args(apkFile); execSpec.args(zipalignedFile); } }); return zipalignedFile; }
Example 2
Source File: ZipAlignUtils.java From atlas with Apache License 2.0 | 6 votes |
public static synchronized File doZipAlign(final AndroidBuilder androidBuilder, Project project, final File apkFile) { final File zipalignedFile = new File(apkFile.getParent(), apkFile.getName().replace(".apk", "-zipaligned.apk")); project.exec(new Action<ExecSpec>() { @Override public void execute(ExecSpec execSpec) { String path = androidBuilder.getTargetInfo() .getBuildTools().getPath(ZIP_ALIGN); execSpec.executable(new File(path)); execSpec.args("-f", "4"); execSpec.args(apkFile); execSpec.args(zipalignedFile); } }); return zipalignedFile; }
Example 3
Source File: ExternalExecUtil.java From curiostack with MIT License | 6 votes |
/** * Executes an external program by customizing a {@link ExecSpec} with the supplied {@link * Action}. If the customized {@link ExecSpec} is serializable, the execution will happen in * parallel with others by running in {@link WorkerExecutor}, otherwise it will be invoked * serially. */ public static void exec( Project project, WorkerExecutor workerExecutor, Action<? super ExecSpec> action) { var customizer = new ExecCustomizer(project); action.execute(customizer); if (customizer.isSerializable()) { project.getLogger().info("Executing command in worker executor."); workerExecutor .noIsolation() .submit( ExecWorkAction.class, parameters -> parameters.getExecCustomizer().set(customizer)); } else { project.getLogger().info("Executing command serially."); project.exec(customizer::copyTo); } }
Example 4
Source File: GitUtils.java From gradle-plugins with MIT License | 6 votes |
@Nullable public String findTravisSlug(Project project) { String travisSlugEnv = System.getenv("TRAVIS_REPO_SLUG"); if (travisSlugEnv != null) { return travisSlugEnv.trim(); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult travisSlugResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "config", "travis.slug"); execSpec.setStandardOutput(outputStream); execSpec.setIgnoreExitValue(true); }); if (travisSlugResult.getExitValue() == 0) { return outputStream.toString().trim(); } return null; }
Example 5
Source File: GitUtils.java From gradle-plugins with MIT License | 6 votes |
public File findWorkingDirectory(Project project) { String travisBuildDirEnv = System.getenv("TRAVIS_BUILD_DIR"); if (travisBuildDirEnv != null) { return new File(travisBuildDirEnv); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "rev-parse", "--show-toplevel"); execSpec.setStandardOutput(outputStream); execSpec.setIgnoreExitValue(true); }); if (execResult.getExitValue() == 0) { return new File(outputStream.toString().trim()); } else { return null; } }
Example 6
Source File: GitUtils.java From gradle-plugins with MIT License | 6 votes |
public String getTag(Project project) { String travisTagEnv = System.getenv("TRAVIS_TAG"); if (travisTagEnv != null) { return travisTagEnv.trim(); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "tag", "--points-at", "HEAD"); execSpec.setStandardOutput(outputStream); }); if (execResult.getExitValue() == 0) { String gitTag = outputStream.toString().trim(); if (!gitTag.isEmpty()) { return gitTag; } } return "HEAD"; }
Example 7
Source File: PythonVersionParser.java From pygradle with Apache License 2.0 | 6 votes |
public static PythonVersion parsePythonVersion(final Project project, final File pythonInterpreter) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.setExecutable(pythonInterpreter.getAbsolutePath()); execSpec.setArgs(Collections.singletonList("--version")); execSpec.setStandardOutput(outputStream); execSpec.setErrorOutput(outputStream); execSpec.setIgnoreExitValue(true); }); String output = outputStream.toString(); if (execResult.getExitValue() != 0) { throw new GradleException(output); } String versionString = output.trim().split(" ")[1]; return new PythonVersion(versionString); }
Example 8
Source File: GitUtils.java From gradle-plugins with MIT License | 6 votes |
@Nullable public String findTravisSlug(Project project) { String travisSlugEnv = System.getenv("TRAVIS_REPO_SLUG"); if (travisSlugEnv != null) { return travisSlugEnv.trim(); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult travisSlugResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "config", "travis.slug"); execSpec.setStandardOutput(outputStream); execSpec.setIgnoreExitValue(true); }); if (travisSlugResult.getExitValue() == 0) { return outputStream.toString().trim(); } return null; }
Example 9
Source File: GitUtils.java From gradle-plugins with MIT License | 6 votes |
public File findWorkingDirectory(Project project) { String travisBuildDirEnv = System.getenv("TRAVIS_BUILD_DIR"); if (travisBuildDirEnv != null) { return new File(travisBuildDirEnv); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "rev-parse", "--show-toplevel"); execSpec.setStandardOutput(outputStream); execSpec.setIgnoreExitValue(true); }); if (execResult.getExitValue() == 0) { return new File(outputStream.toString().trim()); } else { return null; } }
Example 10
Source File: GitUtils.java From gradle-plugins with MIT License | 6 votes |
public String getTag(Project project) { String travisTagEnv = System.getenv("TRAVIS_TAG"); if (travisTagEnv != null) { return travisTagEnv.trim(); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "tag", "--points-at", "HEAD"); execSpec.setStandardOutput(outputStream); }); if (execResult.getExitValue() == 0) { String gitTag = outputStream.toString().trim(); if (!gitTag.isEmpty()) { return gitTag; } } return "HEAD"; }
Example 11
Source File: GitUtils.java From gradle-plugins with MIT License | 5 votes |
public String getRemoteUrl(Project project, String remote) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "ls-remote", "--get-url", remote); execSpec.setStandardOutput(outputStream); }); execResult.rethrowFailure().assertNormalExitValue(); return outputStream.toString().trim(); }
Example 12
Source File: ProbeVenvInfoAction.java From pygradle with Apache License 2.0 | 5 votes |
private static void doProbe(Project project, PythonDetails pythonDetails, EditablePythonAbiContainer editablePythonAbiContainer) throws IOException { InputStream wheelApiResource = ProbeVenvInfoAction.class.getClassLoader() .getResourceAsStream("templates/wheel-api.py"); byte[] buffer = new byte[wheelApiResource.available()]; wheelApiResource.read(buffer); File probeDir = new File(project.getBuildDir(), PROBE_DIR_NAME); probeDir.mkdirs(); OutputStream outStream = new FileOutputStream(getPythonFileForSupportedWheels(probeDir)); outStream.write(buffer); File supportedAbiFormatsFile = getSupportedAbiFormatsFile(probeDir, pythonDetails); project.exec(execSpec -> { execSpec.commandLine(pythonDetails.getVirtualEnvInterpreter()); execSpec.args(getPythonFileForSupportedWheels(probeDir)); execSpec.args(supportedAbiFormatsFile.getAbsolutePath()); }); /* * The code for this function was originally here. * Still making this call to benefit AbstractPythonInfrastructureDefaultTask, * although it's not necessary for InstallVirtualEnvironmentTask because * GetProbedTagsTask will get the tags. */ getSavedTags(pythonDetails, editablePythonAbiContainer, supportedAbiFormatsFile); }
Example 13
Source File: GitUtils.java From gradle-plugins with MIT License | 5 votes |
public String getRemoteUrl(Project project, String remote) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "ls-remote", "--get-url", remote); execSpec.setStandardOutput(outputStream); }); execResult.rethrowFailure().assertNormalExitValue(); return outputStream.toString().trim(); }