use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class NpmBuildInfoExtractor method getDependenciesMapFromBuild.
static Map<String, Dependency> getDependenciesMapFromBuild(BuildInfo buildInfo) {
Map<String, Dependency> previousBuildDependencies = new ConcurrentHashMap<>();
// Iterate over all modules and extract dependencies.
List<Module> modules = buildInfo.getModules();
for (Module module : modules) {
List<Dependency> dependencies = module.getDependencies();
if (dependencies != null) {
for (Dependency dependency : dependencies) {
previousBuildDependencies.put(dependency.getId(), dependency);
}
}
}
return previousBuildDependencies;
}
use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class NpmBuildInfoExtractor method extract.
@Override
public BuildInfo extract(NpmProject npmProject) throws Exception {
String resolutionRepository = npmProject.getResolutionRepository();
List<String> commandArgs = npmProject.getCommandArgs();
Path workingDir = npmProject.getWorkingDir();
preparePrerequisites(resolutionRepository, workingDir);
createTempNpmrc(workingDir, commandArgs);
try {
if (npmProject.isCiCommand()) {
runCi(workingDir, commandArgs);
} else {
runInstall(workingDir, commandArgs);
}
} finally {
restoreNpmrc(workingDir);
}
List<Dependency> dependencies = collectDependencies(workingDir);
String moduleId = StringUtils.isNotBlank(module) ? module : npmPackageInfo.toString();
return createBuild(dependencies, moduleId);
}
use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class NugetRun method createDependency.
private Dependency createDependency(NugetPackgesConfig.ConfigPackage pkg, String globalCachePath) throws IOException, NoSuchAlgorithmException {
boolean found = true;
File nupkg = createNupkgFile(pkg.getId(), pkg.getVersion(), globalCachePath);
if (!nupkg.exists()) {
// If the original version can not be found in cache, we will check if one of the alternative version forms do exist.
found = false;
for (String v : createAlternativeVersionForms(pkg.getVersion())) {
nupkg = createNupkgFile(pkg.getId(), v, globalCachePath);
if (nupkg.exists()) {
found = true;
break;
}
}
}
if (found) {
Map<String, String> checksums = FileChecksumCalculator.calculateChecksums(nupkg, MD5_ALGORITHM, SHA1_ALGORITHM, SHA256_ALGORITHM);
Dependency dependency = new DependencyBuilder().id(pkg.getId() + ':' + pkg.getVersion()).md5(checksums.get(MD5_ALGORITHM)).sha1(checksums.get(SHA1_ALGORITHM)).sha256(checksums.get(SHA256_ALGORITHM)).build();
return dependency;
}
return null;
}
use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class NugetRun method collectDependenciesFromPackagesConfig.
private List<Dependency> collectDependenciesFromPackagesConfig(String packagesConfigPath, String globalCachePath) throws Exception {
File packagesConfig = new File(packagesConfigPath);
NugetPackgesConfig config = new NugetPackgesConfig();
config.readPackageConfig(packagesConfig);
List<Dependency> dependenciesList = new ArrayList<>();
for (NugetPackgesConfig.ConfigPackage pkg : config.getPackages()) {
Dependency pkgDependency = createDependency(pkg, globalCachePath);
if (pkgDependency == null) {
logger.warn(String.format("The following NuGet package %s with version %s was not found in the NuGet cache %s.%s", pkg.getId(), pkg.getVersion(), globalCachePath, ABSENT_NUPKG_WARN_MSG));
continue;
}
dependenciesList.add(pkgDependency);
}
return dependenciesList;
}
use of org.jfrog.build.extractor.ci.Dependency in project build-info by JFrogDev.
the class NpmExtractorConsumer method appendDependency.
/**
* If package is included in the dependencies map, add the current scope for the dependency.
* Otherwise, retrieve sha1 and md5 from Artifactory and add the dependency to the dependencies map.
*
* @param npmPackageInfo - The npm package information.
* @return True if the package is legal. False in case of an error such as an absence in Artifactory's cache.
*/
private boolean appendDependency(NpmPackageInfo npmPackageInfo) {
String id = npmPackageInfo.getName() + ":" + npmPackageInfo.getVersion();
Dependency dependency = dependencies.get(id);
if (dependency == null) {
dependency = createDependency(npmPackageInfo, id);
if (dependency == null) {
return false;
}
dependencies.put(id, dependency);
} else {
dependency.getScopes().add(npmPackageInfo.getScope());
}
dependency.addRequestedBy(npmPackageInfo.getPathToRoot());
return true;
}
Aggregations