Search in sources :

Example 6 with PncBuild

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;
}
Also used : HashMap(java.util.HashMap) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)

Example 7 with PncBuild

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);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) PrintWriter(java.io.PrintWriter)

Example 8 with PncBuild

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();
}
Also used : JavadocManager(org.jboss.pnc.bacon.pig.impl.javadoc.JavadocManager) PigConfiguration(org.jboss.pnc.bacon.pig.impl.config.PigConfiguration) PigContext(org.jboss.pnc.bacon.pig.impl.PigContext) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)

Example 9 with PncBuild

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();
}
Also used : PigConfiguration(org.jboss.pnc.bacon.pig.impl.config.PigConfiguration) LicenseManager(org.jboss.pnc.bacon.pig.impl.license.LicenseManager) PigContext(org.jboss.pnc.bacon.pig.impl.PigContext) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) RepositoryData(org.jboss.pnc.bacon.pig.impl.repo.RepositoryData)

Example 10 with PncBuild

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);
}
Also used : SourcesGenerator(org.jboss.pnc.bacon.pig.impl.sources.SourcesGenerator) PigConfiguration(org.jboss.pnc.bacon.pig.impl.config.PigConfiguration) PigContext(org.jboss.pnc.bacon.pig.impl.PigContext) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) RepositoryData(org.jboss.pnc.bacon.pig.impl.repo.RepositoryData)

Aggregations

PncBuild (org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)29 File (java.io.File)10 PigConfiguration (org.jboss.pnc.bacon.pig.impl.config.PigConfiguration)8 ArtifactWrapper (org.jboss.pnc.bacon.pig.impl.pnc.ArtifactWrapper)8 GAV (org.jboss.pnc.bacon.pig.impl.utils.GAV)8 Map (java.util.Map)7 Path (java.nio.file.Path)5 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 FileNotFoundException (java.io.FileNotFoundException)4 PrintWriter (java.io.PrintWriter)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 List (java.util.List)4 FatalException (org.jboss.pnc.bacon.common.exception.FatalException)4 RepoGenerationData (org.jboss.pnc.bacon.pig.impl.config.RepoGenerationData)4 BuildInfoCollector (org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector)4