use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class PearCliExtractor method extract.
public Extraction extract(final File directory, final File pearExe, final ExtractionId extractionId) {
try {
File workingDirectory = directoryManager.getExtractionOutputDirectory(extractionId);
final ExecutableOutput pearListing = executableRunner.execute(workingDirectory, pearExe, "list");
final ExecutableOutput pearDependencies = executableRunner.execute(workingDirectory, pearExe, "package-dependencies", PACKAGE_XML_FILENAME);
// TODO: Why is this done here?
final File packageFile = detectFileFinder.findFile(directory, PACKAGE_XML_FILENAME);
final PearParseResult result = pearParser.parse(packageFile, pearListing, pearDependencies);
final ExternalId id = externalIdFactory.createNameVersionExternalId(Forge.PEAR, result.name, result.version);
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.PEAR, directory.toString(), id, result.dependencyGraph).build();
return new Extraction.Builder().success(detectCodeLocation).projectName(result.name).projectVersion(result.version).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class ExeNugetInspector method execute.
@Override
public ExecutableOutput execute(File workingDirectory, List<String> arguments) throws ExecutableRunnerException {
final Executable hubNugetInspectorExecutable = new Executable(workingDirectory, inspectorExe, arguments);
final ExecutableOutput executableOutput = executableRunner.execute(hubNugetInspectorExecutable);
return executableOutput;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class PipenvExtractor method extract.
public Extraction extract(final File directory, final String pythonExe, final String pipenvExe, final File setupFile) {
Extraction extraction;
try {
final String projectName = getProjectName(directory, pythonExe, setupFile);
final String projectVersionName = getProjectVersionName(directory, pythonExe, setupFile);
final PipParseResult result;
final Executable pipenvRunPipFreeze = new Executable(directory, pipenvExe, Arrays.asList("run", "pip", "freeze"));
final ExecutableOutput pipFreezeOutput = executableRunner.execute(pipenvRunPipFreeze);
final Executable pipenvGraph = new Executable(directory, pipenvExe, Arrays.asList("graph", "--bare"));
final ExecutableOutput graphOutput = executableRunner.execute(pipenvGraph);
result = pipenvTreeParser.parse(projectName, projectVersionName, pipFreezeOutput.getStandardOutputAsList(), graphOutput.getStandardOutputAsList(), directory.toString());
if (result != null) {
extraction = new Extraction.Builder().success(result.getCodeLocation()).projectName(result.getProjectName()).projectVersion(result.getProjectVersion()).build();
} else {
extraction = new Extraction.Builder().failure("Pipenv graph could not successfully be parsed").build();
}
} catch (final Exception e) {
extraction = new Extraction.Builder().exception(e).build();
}
return extraction;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class NpmCliExtractor method extract.
public Extraction extract(final File directory, final String npmExe, final ExtractionId extractionId) {
final boolean includeDevDeps = detectConfiguration.getBooleanProperty(DetectProperty.DETECT_NPM_INCLUDE_DEV_DEPENDENCIES, PropertyAuthority.None);
final List<String> exeArgs = new ArrayList<>();
exeArgs.add("ls");
exeArgs.add("-json");
if (!includeDevDeps) {
exeArgs.add("-prod");
}
final String additionalArguments = detectConfiguration.getProperty(DetectProperty.DETECT_NPM_ARGUMENTS, PropertyAuthority.None);
if (StringUtils.isNotBlank(additionalArguments)) {
exeArgs.addAll(Arrays.asList(additionalArguments.split(" ")));
}
final Executable npmLsExe = new Executable(directory, npmExe, exeArgs);
ExecutableOutput executableOutput;
try {
executableOutput = executableRunner.execute(npmLsExe);
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
final String standardOutput = executableOutput.getStandardOutput();
final String errorOutput = executableOutput.getErrorOutput();
if (StringUtils.isNotBlank(errorOutput)) {
logger.error("Error when running npm ls -json command");
logger.error(errorOutput);
return new Extraction.Builder().failure("Npm wrote to stderr while running npm ls.").build();
} else if (StringUtils.isNotBlank(standardOutput)) {
logger.debug("Parsing npm ls file.");
logger.debug(standardOutput);
try {
final NpmParseResult result = npmCliParser.generateCodeLocation(directory.getCanonicalPath(), standardOutput);
return new Extraction.Builder().success(result.codeLocation).projectName(result.projectName).projectVersion(result.projectVersion).build();
} catch (final IOException e) {
return new Extraction.Builder().exception(e).build();
}
} else {
logger.error("Nothing returned from npm ls -json command");
return new Extraction.Builder().failure("Npm returned error after running npm ls.").build();
}
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class BazelExecutableFinder method findBazel.
public String findBazel(final DetectorEnvironment environment) {
final boolean resolvedPreviously = isAlreadyFound(CacheableExecutableType.BAZEL);
String resolvedBazel = null;
try {
final File bazelExeFile = getExecutable(CacheableExecutableType.BAZEL);
if (bazelExeFile == null) {
logger.debug("Unable to locate Bazel executable");
return null;
}
resolvedBazel = bazelExeFile.getAbsolutePath();
} catch (DetectorException e) {
logger.debug(String.format("Unable to locate Bazel executable: %s", e.getMessage()));
return null;
}
if (!resolvedPreviously) {
final ExecutableOutput bazelQueryDepsRecursiveOutput;
try {
bazelQueryDepsRecursiveOutput = executableRunner.executeQuietly(environment.getDirectory(), resolvedBazel, BAZEL_VERSION_SUBCOMMAND);
int returnCode = bazelQueryDepsRecursiveOutput.getReturnCode();
logger.trace(String.format("Bazel version returned %d; output: %s", returnCode, bazelQueryDepsRecursiveOutput.getStandardOutput()));
} catch (ExecutableRunnerException e) {
logger.debug(String.format("Bazel version threw exception: %s", e.getMessage()));
resolvedBazel = null;
}
}
return resolvedBazel;
}
Aggregations