@Override public void execute(ExecSpec execSpec) { if (_environment != null) { execSpec.environment(_environment); } execSpec.setCommandLine(_commandLine); execSpec.setStandardOutput(byteArrayOutputStream); }
@Override public void execute(final ExecSpec it) { it.setExecutable(info.getShellExecutable()); if (isWindows()) { it.environment("MSYSTEM", mSystem); it.environment("CHERE_INVOKING", "1"); } it.args(getAllArgs()); if (!workingDir.isDirectory()) { workingDir.mkdirs(); } it.setWorkingDir(workingDir); it.setStandardInput(standardInput); it.setStandardOutput(standardOutput); it.setErrorOutput(errorOutput); } });
@Override public void execute(ExecSpec execSpec) { /* * Gradle doesn't work correctly when there are empty args. */ List<String> args = processInfo.getArgs().stream() .map(a -> a.isEmpty()? "\"\"" : a) .collect(Collectors.toList()); execSpec.setExecutable(processInfo.getExecutable()); execSpec.args(args); execSpec.environment(processInfo.getEnvironment()); execSpec.setStandardOutput(processOutput.getStandardOutput()); execSpec.setErrorOutput(processOutput.getErrorOutput()); // we want the caller to be able to do its own thing. execSpec.setIgnoreExitValue(true); } }
ExecResult execCommand(Map<String, String> mergedEnv, List<String> commandLine, OutputStream stream) { return externalExec.exec(execSpec -> { execSpec.environment(mergedEnv); execSpec.commandLine(commandLine); execSpec.setStandardOutput(stream); execSpec.setErrorOutput(stream); execSpec.setIgnoreExitValue(true); }); }
@Override public void applyTo(final Project project) { // XXX: This needs to be adjusted to work with a build matrix one day. Until // that is ready, we always assume pure Python 2.7 on Linux. String version = project.getVersion().toString().replace("-", "_"); String name = project.getName().replace("-", "_"); final File wheelArtifact = new File(project.getProjectDir(), "/dist/" + name + "-" + version + "-py2-none-any.whl"); /* * Create a Python wheel distribution. */ project.getTasks().create(TASK_PACKAGE_WHEEL, task -> { task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue())); task.getOutputs().file(wheelArtifact); task.doLast(it -> project.exec(execSpec -> { execSpec.environment(settings.pythonEnvironmentDistgradle); execSpec.commandLine(settings.getDetails().getVirtualEnvInterpreter(), "setup.py", "bdist_wheel"); })); }); LinkedHashMap<String, Object> wheelArtifactInfo = new LinkedHashMap<>(5); wheelArtifactInfo.put("name", name); wheelArtifactInfo.put("classifier", "py2-none-any"); wheelArtifactInfo.put("type", "whl"); wheelArtifactInfo.put("file", wheelArtifact); wheelArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_WHEEL)); if (!version.contains("SNAPSHOT")) { project.getArtifacts().add(StandardTextValues.CONFIGURATION_WHEEL.getValue(), wheelArtifactInfo); } }
@Override public void applyTo(final Project project) { // XXX: This needs to be adjusted to work with a build matrix one day. Until // that is ready, we always assume pure Python 2.7 on Linux. String version = project.getVersion().toString().replace("-", "_"); String name = project.getName().replace("-", "_"); final File wheelArtifact = new File(project.getProjectDir(), "/dist/" + name + "-" + version + "-py2-none-any.whl"); /* * Create a Python wheel distribution. */ project.getTasks().create(TASK_PACKAGE_WHEEL, task -> { task.dependsOn(project.getTasks().getByName(StandardTextValues.TASK_INSTALL_PROJECT.getValue())); task.getOutputs().file(wheelArtifact); task.doLast(it -> project.exec(execSpec -> { execSpec.environment(settings.pythonEnvironmentDistgradle); execSpec.commandLine(settings.getDetails().getVirtualEnvInterpreter(), "setup.py", "bdist_wheel"); })); }); LinkedHashMap<String, Object> wheelArtifactInfo = new LinkedHashMap<>(5); wheelArtifactInfo.put("name", name); wheelArtifactInfo.put("classifier", "py2-none-any"); wheelArtifactInfo.put("type", "whl"); wheelArtifactInfo.put("file", wheelArtifact); wheelArtifactInfo.put("builtBy", project.getTasks().getByName(TASK_PACKAGE_WHEEL)); if (!version.contains("SNAPSHOT")) { project.getArtifacts().add(StandardTextValues.CONFIGURATION_WHEEL.getValue(), wheelArtifactInfo); } }
ExecResult execCommand(Map<String, String> mergedEnv, List<String> commandLine, OutputStream stream) { return externalExec.exec(execSpec -> { execSpec.environment(mergedEnv); execSpec.commandLine(commandLine); execSpec.setStandardOutput(stream); execSpec.setErrorOutput(stream); execSpec.setIgnoreExitValue(true); }); }
public Map<String, String> getDependencies() { final PythonExtension settings = ExtensionUtils.getPythonExtension(project); // Setup requirements, build, and test dependencies Set<String> developmentDependencies = configurationToSet(project, StandardTextValues.CONFIGURATION_SETUP_REQS.getValue()); developmentDependencies.addAll(configurationToSet(project, StandardTextValues.CONFIGURATION_BUILD_REQS.getValue())); developmentDependencies.addAll(configurationToSet(project, StandardTextValues.CONFIGURATION_TEST.getValue())); developmentDependencies.removeAll(configurationToSet(project, StandardTextValues.CONFIGURATION_PYTHON.getValue())); final ByteArrayOutputStream requirements = new ByteArrayOutputStream(); /* * NOTE: It is very important to provide "--all" in the list of arguments * to "pip freeze". Otherwise, setuptools, wheel, or pip would not be included * even if required by runtime configuration "python". */ project.exec(execSpec -> { execSpec.environment(settings.getEnvironment()); execSpec.commandLine( settings.getDetails().getVirtualEnvInterpreter(), settings.getDetails().getVirtualEnvironment().getPip(), "freeze", "--all", "--disable-pip-version-check" ); execSpec.setStandardOutput(requirements); }); Map<String, String> dependencies = PipFreezeOutputParser.getDependencies(developmentDependencies, requirements); // Always add project unconditionally. dependencies.put(project.getName(), project.getVersion().toString()); return dependencies; }
@TaskAction public void executePythonProcess() { preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = externalExec.exec(execSpec -> { execSpec.environment(getComponent().pythonEnvironment); execSpec.environment(getComponent().pythonEnvironmentDistgradle); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); // subArguments are arguments for previous arguments. eg: arguments to py.test like -k execSpec.args(subArguments); // additionalArguments are same as subArguments, but are expected from user's build script execSpec.args(additionalArguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); output = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }
public Map<String, String> getDependencies() { final PythonExtension settings = ExtensionUtils.getPythonExtension(project); // Setup requirements, build, and test dependencies Set<String> developmentDependencies = configurationToSet(project, StandardTextValues.CONFIGURATION_SETUP_REQS.getValue()); developmentDependencies.addAll(configurationToSet(project, StandardTextValues.CONFIGURATION_BUILD_REQS.getValue())); developmentDependencies.addAll(configurationToSet(project, StandardTextValues.CONFIGURATION_TEST.getValue())); developmentDependencies.removeAll(configurationToSet(project, StandardTextValues.CONFIGURATION_PYTHON.getValue())); final ByteArrayOutputStream requirements = new ByteArrayOutputStream(); /* * NOTE: It is very important to provide "--all" in the list of arguments * to "pip freeze". Otherwise, setuptools, wheel, or pip would not be included * even if required by runtime configuration "python". */ project.exec(execSpec -> { execSpec.environment(settings.getEnvironment()); execSpec.commandLine( settings.getDetails().getVirtualEnvInterpreter(), settings.getDetails().getVirtualEnvironment().getPip(), "freeze", "--all", "--disable-pip-version-check" ); execSpec.setStandardOutput(requirements); }); Map<String, String> dependencies = PipFreezeOutputParser.getDependencies(developmentDependencies, requirements); // Always add project unconditionally. dependencies.put(project.getName(), project.getVersion().toString()); return dependencies; }
@TaskAction public void executePythonProcess() { preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = externalExec.exec(execSpec -> { execSpec.environment(getComponent().pythonEnvironment); execSpec.environment(getComponent().pythonEnvironmentDistgradle); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); // subArguments are arguments for previous arguments. eg: arguments to py.test like -k execSpec.args(subArguments); // additionalArguments are same as subArguments, but are expected from user's build script execSpec.args(additionalArguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); output = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }
@TaskAction public void executePythonProcess() { if (!isVenvReady()) { prepairVenv(); } preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = getProject().exec(execSpec -> { execSpec.environment(getPythonExtension().pythonEnvironment); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); lastMessage = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }
@TaskAction public void executePythonProcess() { if (!isVenvReady()) { prepairVenv(); } preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = getProject().exec(execSpec -> { execSpec.environment(getPythonExtension().pythonEnvironment); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); lastMessage = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }