use of org.jboss.pnc.bacon.pig.impl.pnc.PncBuild in project bacon by project-ncl.
the class ResolveOnlyRepositoryTest method mockBuildsAndMethods.
private Map<String, PncBuild> mockBuildsAndMethods(RepoGenerationData generationData) {
Map<String, PncBuild> builds = new HashMap<>();
Map<String, PncBuild> buildsSpy = Mockito.spy(builds);
PncBuild pncBuild = Mockito.mock(PncBuild.class);
buildsSpy.put(generationData.getSourceBuild(), pncBuild);
return buildsSpy;
}
use of org.jboss.pnc.bacon.pig.impl.pnc.PncBuild in project bacon by project-ncl.
the class RuntimeDependenciesToAlignTree method trigger.
@Override
public void trigger() {
String filename = extrasPath + "DependenciesToAlignTree.txt";
String buildFromSourceStatsFileName = extrasPath + "BuildFromSourceStats.txt";
log.info("Running DependenciesToAlignTree - report is {}", filename);
try (PrintWriter file = new PrintWriter(filename, StandardCharsets.UTF_8.name());
PrintWriter buildFromSourceStatsFile = new PrintWriter(buildFromSourceStatsFileName, StandardCharsets.UTF_8.name())) {
for (PncBuild build : builds.values()) {
// Make a unique list so we don't get multiples from
// sub-module's dependency tree list
List<String> bcLog = build.getBuildLog().stream().distinct().collect(Collectors.toList());
file.print("-------- [" + build.getId() + "] " + build.getName() + " --------\n");
buildFromSourceStatsFile.print("-------- [" + build.getId() + "] " + build.getName() + " --------\n");
List<String> runtimeDeps = new ArrayList<String>();
// Do build-from-source counts
int allDependencyCount = 0;
int allRuntimeCount = 0;
int allCompileCount = 0;
for (String line : bcLog) {
line.trim();
if ((line.endsWith(":compile")) || (line.endsWith(":runtime"))) {
if (line.endsWith(":runtime")) {
allRuntimeCount++;
} else if (line.endsWith(":compile")) {
allCompileCount++;
}
allDependencyCount++;
runtimeDeps.add(parseDependency(line));
}
}
// Get a distinct list of deps
List<String> distinctDeps = runtimeDeps.stream().distinct().collect(Collectors.toList());
// Get the productized dependency count
int productizedCount = 0;
int runtimeProductizedCount = 0;
int compileProductizedCount = 0;
for (String line : bcLog) {
line.trim();
if (line.contains("redhat-")) {
if (line.endsWith(":runtime")) {
runtimeProductizedCount++;
productizedCount++;
} else if (line.endsWith(":compile")) {
compileProductizedCount++;
productizedCount++;
}
}
}
// Print out the productization stats
buildFromSourceStatsFile.print("Found " + productizedCount + " unique productized dependencies, " + allDependencyCount + " total dependencies\n");
float pct = (float) productizedCount / allDependencyCount;
buildFromSourceStatsFile.print("Build from source percentage : " + String.format("%.2f", pct * 100) + "%\n");
buildFromSourceStatsFile.print("Found " + runtimeProductizedCount + " unique productized runtime dependencies, " + allRuntimeCount + " total unique runtime dependencies\n");
pct = (float) runtimeProductizedCount / allRuntimeCount;
buildFromSourceStatsFile.print("Build from source percentage (runtime) : " + String.format("%.2f", pct * 100) + "%\n");
buildFromSourceStatsFile.print("Found " + compileProductizedCount + " unique productized compile-scope dependencies, " + allCompileCount + " total unique compile-scope dependencies\n");
pct = (float) compileProductizedCount / allCompileCount;
buildFromSourceStatsFile.print("Build from source percentage (compile) : " + String.format("%.2f", pct * 100) + "%\n");
// Build a list of parentage
String currentParent = null;
HashMap<String, String> parentage = new HashMap<String, String>();
List<String> parentLog = build.getBuildLog().stream().collect(Collectors.toList());
for (String parentLine : parentLog) {
if ((parentLine.startsWith("[INFO] --- maven-dependency-plugin:") && (parentLine.contains(":tree")))) {
// We have a parent line
int startIndex = parentLine.indexOf("@");
currentParent = parentLine.substring(startIndex + 2, (parentLine.length() - 4));
}
if ((currentParent != null) && ((parentLine.endsWith(":compile")) || (parentLine.endsWith(":runtime")))) {
String dep = parseDependency(parentLine);
if (parentage.containsKey(dep)) {
String curValue = parentage.get(dep);
parentage.replace(dep, curValue + "," + currentParent);
} else {
parentage.put(dep, currentParent);
}
}
if (parentLine.stripTrailing().equals("[INFO] ")) {
currentParent = null;
}
}
for (String bcLine : distinctDeps) {
if (!bcLine.contains("org.apache.camel") && !bcLine.contains("redhat-")) {
file.print(bcLine + ", parent=" + parentage.get(bcLine) + "\n");
}
}
file.print("\n");
}
file.flush();
buildFromSourceStatsFile.flush();
} catch (FileNotFoundException | UnsupportedEncodingException e) {
log.error("Error while creating RuntimeDependenciesToAlignTree report", e);
}
}
use of org.jboss.pnc.bacon.pig.impl.pnc.PncBuild in project bacon by project-ncl.
the class PigFacade method generateJavadoc.
public static void generateJavadoc() {
abortIfContextDataAbsent();
PigContext context = context();
context.getDeliverables().setJavadocZipName(context.getPrefix() + "-javadoc.zip");
PigConfiguration pigConfiguration = context.getPigConfiguration();
Map<String, PncBuild> builds = context.getBuilds();
new JavadocManager(pigConfiguration, context.getReleasePath(), context.getDeliverables(), builds).prepare();
}
use of org.jboss.pnc.bacon.pig.impl.pnc.PncBuild in project bacon by project-ncl.
the class PigFacade method generateLicenses.
public static void generateLicenses(boolean strict) {
abortIfContextDataAbsent();
PigContext context = context();
context.getDeliverables().setLicenseZipName(context.getPrefix() + "-license.zip");
PigConfiguration pigConfiguration = context.getPigConfiguration();
RepositoryData repo = context.getRepositoryData();
Map<String, PncBuild> builds = context.getBuilds();
new LicenseManager(pigConfiguration, context.getReleasePath(), strict, context.getDeliverables(), builds, repo).prepare();
}
use of org.jboss.pnc.bacon.pig.impl.pnc.PncBuild in project bacon by project-ncl.
the class PigFacade method generateSources.
public static void generateSources() {
abortIfContextDataAbsent();
PigContext context = context();
context.getDeliverables().setSourceZipName(context.getPrefix() + "-src.zip");
PigConfiguration pigConfiguration = context.getPigConfiguration();
Map<String, PncBuild> builds = context.getBuilds();
RepositoryData repo = context.getRepositoryData();
SourcesGenerator sourcesGenerator = new SourcesGenerator(pigConfiguration.getFlow().getSourcesGeneration(), pigConfiguration.getTopLevelDirectoryPrefix() + "src", context.getReleasePath() + context.getDeliverables().getSourceZipName());
sourcesGenerator.generateSources(builds, repo);
}
Aggregations