use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class NugetRun method singleProjectHandler.
private void singleProjectHandler(String projectName, String csprojPath, String globalCachePath) throws Exception {
String dependenciesSource = getDependenciesSource(projectName, csprojPath);
if (StringUtils.isEmpty(dependenciesSource)) {
logger.debug("Project dependencies was not found for project: " + projectName);
return;
}
// Collect dependencies according to the correct method:
// Check if project uses packages.config or project.assets.json
List<Dependency> dependencies = new ArrayList<>();
if (dependenciesSource.endsWith(PACKAGES_CONFIG)) {
dependencies = collectDependenciesFromPackagesConfig(dependenciesSource, globalCachePath);
} else if (dependenciesSource.endsWith(PROJECT_ASSETS)) {
dependencies = collectDependenciesFromProjectAssets(dependenciesSource);
}
Module projectModule = new ModuleBuilder().type(ModuleType.NUGET).id(projectName).dependencies(dependencies).build();
if (StringUtils.isBlank(module)) {
modulesList.add(projectModule);
} else {
// If a custom module name was provided, we will aggregate all projects under the same module.
modulesList.get(0).append(projectModule);
}
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class NpmPublish method createBuild.
private BuildInfo createBuild() {
String moduleID = StringUtils.isNotBlank(module) ? module : npmPackageInfo.toString();
List<Artifact> artifactList = Collections.singletonList(deployedArtifact);
Module module = new ModuleBuilder().type(ModuleType.NPM).id(moduleID).repository(repo).artifacts(artifactList).build();
List<Module> modules = Collections.singletonList(module);
BuildInfo buildInfo = new BuildInfo();
buildInfo.setModules(modules);
return buildInfo;
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class NpmExtractorTest method npmPublishTest.
@SuppressWarnings("unused")
@Test(dataProvider = "npmPublishProvider")
public void npmPublishTest(Project project, ArrayListMultimap<String, String> props, String targetPath, String packageName) {
Path projectDir = null;
try {
// Run npm publish
projectDir = createProjectDir(project);
Path path = StringUtils.isNotBlank(packageName) ? projectDir.resolve(packageName) : projectDir;
NpmPublish npmPublish = new NpmPublish(artifactoryManagerBuilder, props, path, localRepo1, log, null, null);
BuildInfo buildInfo = npmPublish.execute();
assertEquals(buildInfo.getModules().size(), 1);
Module module = buildInfo.getModules().get(0);
// Check correctness of the module and the artifact
assertEquals(module.getType(), "npm");
assertEquals(module.getId(), project.getModuleId());
assertEquals(module.getRepository(), localRepo1);
assertEquals(module.getArtifacts().size(), 1);
assertEquals(module.getArtifacts().get(0).getName(), project.getModuleId());
assertEquals(module.getArtifacts().get(0).getRemotePath(), project.getRemotePath());
// DownloadBase the artifact and check for its properties
StringJoiner propertiesBuilder = new StringJoiner(";");
props.entries().forEach(property -> propertiesBuilder.add(property.getKey() + "=" + property.getValue()));
FilesGroup fileSpec = new FilesGroup();
fileSpec.setProps(propertiesBuilder.toString());
fileSpec.setPattern(localRepo1 + "/" + targetPath);
fileSpec.setTarget(projectDir.toString());
FileSpec spec = new FileSpec();
spec.addFilesGroup(fileSpec);
assertEquals(downloaderHelper.downloadDependencies(spec).size(), 1);
} catch (Exception e) {
fail(ExceptionUtils.getStackTrace(e));
} finally {
if (projectDir != null) {
FileUtils.deleteQuietly(projectDir.toFile());
}
}
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class NugetExtractorTest method executeAndAssertBuildInfo.
private void executeAndAssertBuildInfo(NugetRun nugetRun, String[] expectedModules, int... expectedDependencies) {
BuildInfo buildInfo = nugetRun.execute();
assertNotNull(buildInfo);
assertEquals(buildInfo.getModules().size(), expectedModules.length);
for (int i = 0; i < expectedModules.length; i++) {
Module module = buildInfo.getModules().get(i);
// Check correctness of the module and dependencies
assertEquals(module.getType(), "nuget");
assertEquals(module.getId(), expectedModules[i]);
assertTrue(module.getDependencies().size() > 0);
}
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class GoExtractorTest method goRunTest.
@Test(dataProvider = "goRunProvider")
public void goRunTest(Project project, String args, ArtifactoryManagerBuilder artifactoryManagerBuilder, String repo) {
Path projectDir = null;
try {
// Run Go build
projectDir = createProjectDir(project.targetDir, project.projectOrigin);
GoRun goRun = new GoRun(args, projectDir, null, artifactoryManagerBuilder, repo, getUsername(), getAdminToken(), getLog(), env);
BuildInfo buildInfo = goRun.execute();
// Check successful execution and correctness of the module and dependencies
assertNotNull(buildInfo);
assertEquals(buildInfo.getModules().size(), 1);
Module module = buildInfo.getModules().get(0);
assertEquals(module.getType(), "go");
assertEquals(module.getId(), project.getModuleId());
Set<String> moduleDependencies = module.getDependencies().stream().map(Dependency::getId).collect(Collectors.toSet());
assertEquals(moduleDependencies, project.dependencies);
} catch (Exception e) {
fail(ExceptionUtils.getStackTrace(e));
} finally {
if (projectDir != null) {
FileUtils.deleteQuietly(projectDir.toFile());
}
}
}
Aggregations