use of org.jfrog.build.extractor.builder.ModuleBuilder 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.builder.ModuleBuilder in project build-info by JFrogDev.
the class NugetRun method execute.
@Override
public BuildInfo execute() {
BuildInfo buildInfo = null;
try {
prepareAndRunCmd();
if (!StringUtils.isBlank(module)) {
ModuleBuilder builder = new ModuleBuilder().type(ModuleType.NUGET).id(module);
modulesList.add(builder.build());
}
collectDependencies();
buildInfo = new BuildInfo();
buildInfo.setModules(modulesList);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
return buildInfo;
}
use of org.jfrog.build.extractor.builder.ModuleBuilder 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.builder.ModuleBuilder in project build-info by JFrogDev.
the class GradleModuleExtractor method extractModule.
@Override
public Module extractModule(Project project) {
Set<GradleDeployDetails> gradleDeployDetails = Sets.newHashSet();
String artifactName = project.getName();
ArtifactoryTask artifactoryTask = ProjectUtils.getBuildInfoTask(project);
if (artifactoryTask != null) {
artifactName = project.getName();
try {
artifactoryTask.collectDescriptorsAndArtifactsForUpload();
} catch (IOException e) {
throw new RuntimeException("Cannot collect deploy details for " + artifactoryTask.getPath(), e);
}
gradleDeployDetails = artifactoryTask.deployDetails;
}
String repo = gradleDeployDetails.stream().map(GradleDeployDetails::getDeployDetails).map(DeployDetails::getTargetRepository).findAny().orElse("");
String moduleId = getModuleIdString(project.getGroup().toString(), artifactName, project.getVersion().toString());
ModuleBuilder builder = new ModuleBuilder().type(ModuleType.GRADLE).id(moduleId).repository(repo);
try {
// Extract the module's artifacts information if a publisher exists.
ArtifactoryClientConfiguration.PublisherHandler publisher = ArtifactoryPluginUtil.getPublisherHandler(project);
if (publisher != null) {
boolean excludeArtifactsFromBuild = publisher.isFilterExcludedArtifactsFromBuild();
IncludeExcludePatterns patterns = new IncludeExcludePatterns(publisher.getIncludePatterns(), publisher.getExcludePatterns());
Iterable<GradleDeployDetails> deployExcludeDetails;
Iterable<GradleDeployDetails> deployIncludeDetails;
if (excludeArtifactsFromBuild) {
deployIncludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, true));
deployExcludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, false));
} else {
deployIncludeDetails = Iterables.filter(gradleDeployDetails, new ProjectPredicate(project));
deployExcludeDetails = new ArrayList<>();
}
builder.artifacts(calculateArtifacts(deployIncludeDetails)).excludedArtifacts(calculateArtifacts(deployExcludeDetails));
} else {
log.warn("No publisher config found for project: " + project.getName());
}
builder.dependencies(calculateDependencies(project, moduleId));
} catch (Exception e) {
log.error("Error during extraction: ", e);
}
return builder.build();
}
use of org.jfrog.build.extractor.builder.ModuleBuilder in project build-info by JFrogDev.
the class BuildInfoRecorder method initModule.
private void initModule(MavenProject project) {
if (project == null) {
logger.warn("Skipping Artifactory Build-Info module initialization: Null project.");
return;
}
ModuleBuilder module = new ModuleBuilder().type(ModuleType.MAVEN);
module.id(getModuleIdString(project.getGroupId(), project.getArtifactId(), project.getVersion()));
module.properties(project.getProperties());
currentModule.set(module);
currentModuleArtifacts.set(Collections.synchronizedSet(new HashSet<>()));
currentModuleDependencies.set(Collections.synchronizedSet(new HashSet<>()));
}
Aggregations