Search in sources :

Example 1 with BuildInfoCollector

use of org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector in project bacon by project-ncl.

the class PigFacade method build.

public static GroupBuildInfo build(boolean tempBuild, boolean tempBuildTS, RebuildMode rebuildMode, boolean wait, boolean dryRun) {
    ImportResult importResult = context().getPncImportResult();
    if (importResult == null) {
        importResult = readPncEntities();
    }
    if (tempBuild) {
        log.info("Temporary build");
    }
    try (PncBuilder pncBuilder = new PncBuilder()) {
        GroupBuild groupBuild = pncBuilder.build(importResult.getBuildGroup(), tempBuild, tempBuildTS, rebuildMode, wait, dryRun);
        if (wait) {
            try (BuildInfoCollector buildInfoCollector = new BuildInfoCollector()) {
                return buildInfoCollector.getBuildsFromGroupBuild(groupBuild);
            }
        }
        log.info("Not waiting for build to finish.");
        return null;
    }
}
Also used : ImportResult(org.jboss.pnc.bacon.pig.impl.pnc.ImportResult) BuildInfoCollector(org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector) GroupBuild(org.jboss.pnc.dto.GroupBuild) PncBuilder(org.jboss.pnc.bacon.pig.impl.pnc.PncBuilder)

Example 2 with BuildInfoCollector

use of org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector in project bacon by project-ncl.

the class OfflineManifestGenerator method trigger.

public void trigger() {
    log.info("Generating the Offliner manifest");
    if (buildInfoCollector == null) {
        buildInfoCollector = new BuildInfoCollector();
    }
    HashSet<String> artifacts = new HashSet<>();
    for (PncBuild build : sourceBuilds()) {
        Collection<String> builtArtifacts = filterExcludedArtifactsAndFormat(build.getBuiltArtifacts());
        log.debug("Collected {} built artifacts for build {}", builtArtifacts.size(), build.getName());
        artifacts.addAll(builtArtifacts);
        buildInfoCollector.addDependencies(build, "targetRepository.repositoryType==" + RepositoryType.MAVEN);
        if (build.getDependencyArtifacts() != null) {
            Collection<String> dependencies = filterExcludedArtifactsAndFormat(build.getDependencyArtifacts());
            log.debug("Collected {} dependencies for build {}", dependencies.size(), build.getName());
            artifacts.addAll(dependencies);
        }
    }
    try (PrintWriter file = new PrintWriter(releasePath + offlinerManifestFileName(), StandardCharsets.UTF_8.name())) {
        artifacts.forEach(file::println);
        pigConfiguration.getFlow().getRepositoryGeneration().getExternalAdditionalArtifacts().stream().map(GAV::fromColonSeparatedGAPV).map(extraGav -> String.format("%s/%s", extraGav.toVersionPath(), extraGav.toFileName())).forEach(file::println);
    } catch (FileNotFoundException | UnsupportedEncodingException e) {
        throw new FatalException("Failed to generate the Offliner manifest", e);
    }
}
Also used : AddOn(org.jboss.pnc.bacon.pig.impl.addons.AddOn) GAV(org.jboss.pnc.bacon.pig.impl.utils.GAV) Arrays(java.util.Arrays) RepoGenerationStrategy(org.jboss.pnc.bacon.pig.impl.config.RepoGenerationStrategy) BuildInfoCollector(org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector) LoggerFactory(org.slf4j.LoggerFactory) PigConfiguration(org.jboss.pnc.bacon.pig.impl.config.PigConfiguration) HashSet(java.util.HashSet) RepositoryType(org.jboss.pnc.enums.RepositoryType) Map(java.util.Map) IGNORE(org.jboss.pnc.bacon.pig.impl.config.RepoGenerationStrategy.IGNORE) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) PrintWriter(java.io.PrintWriter) Logger(org.slf4j.Logger) FatalException(org.jboss.pnc.bacon.common.exception.FatalException) Collection(java.util.Collection) RepoGenerationData(org.jboss.pnc.bacon.pig.impl.config.RepoGenerationData) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) BUILD_GROUP(org.jboss.pnc.bacon.pig.impl.config.RepoGenerationStrategy.BUILD_GROUP) Pattern(java.util.regex.Pattern) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ArtifactWrapper(org.jboss.pnc.bacon.pig.impl.pnc.ArtifactWrapper) FatalException(org.jboss.pnc.bacon.common.exception.FatalException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BuildInfoCollector(org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) GAV(org.jboss.pnc.bacon.pig.impl.utils.GAV) HashSet(java.util.HashSet) PrintWriter(java.io.PrintWriter)

Example 3 with BuildInfoCollector

use of org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector in project bacon by project-ncl.

the class ResolveOnlyRepositoryTest method resolveAndRepackageShouldGenerateRepository.

@Test
void resolveAndRepackageShouldGenerateRepository() {
    mockPigContextAndMethods();
    mockIndySettingsFile();
    PigConfiguration pigConfiguration = mockPigConfigurationAndMethods();
    RepoGenerationData generationDataSpy = mockRepoGenerationDataAndMethods();
    mockParamsAndMethods(generationDataSpy);
    mockFlowAndMethods(pigConfiguration, generationDataSpy);
    Map<String, PncBuild> buildsSpy = mockBuildsAndMethods(generationDataSpy);
    Path configurationDirectory = Mockito.mock(Path.class);
    mockResourceUtilsMethods(configurationDirectory);
    Deliverables deliverables = mockDeliverables(pigConfiguration);
    String releasePath = createReleasePath();
    BuildInfoCollector buildInfoCollectorMock = Mockito.mock(BuildInfoCollector.class);
    RepoManager repoManager = new RepoManager(pigConfiguration, releasePath, deliverables, buildsSpy, configurationDirectory, false, false, false, buildInfoCollectorMock, true);
    RepoManager repoManagerSpy = Mockito.spy(repoManager);
    prepareFakeExtensionArtifactList(repoManagerSpy);
    RepositoryData repoData = repoManagerSpy.prepare();
    assert repoData.getRepositoryPath().toString().equals("/tmp/resolveRepoTest/rh-sample-maven-repository.zip");
    Set<String> repoZipContents = repoZipContentList();
    repoData.getFiles().forEach((file) -> {
        String filePath = file.getAbsolutePath().replaceAll(".+/deliverable-generation\\d+/", "");
        if (!repoZipContents.contains(filePath)) {
            System.out.println("File not included " + filePath);
        }
        assert repoZipContents.contains(filePath);
    });
}
Also used : Path(java.nio.file.Path) Deliverables(org.jboss.pnc.bacon.pig.impl.documents.Deliverables) BuildInfoCollector(org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector) PigConfiguration(org.jboss.pnc.bacon.pig.impl.config.PigConfiguration) RepoGenerationData(org.jboss.pnc.bacon.pig.impl.config.RepoGenerationData) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) Test(org.junit.jupiter.api.Test)

Example 4 with BuildInfoCollector

use of org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector in project bacon by project-ncl.

the class OfflineManifestGeneratorTest method testSetUp.

@BeforeEach
public void testSetUp() {
    buildInfoCollector = Mockito.mock(BuildInfoCollector.class);
    EasyRandom easyRandom = new EasyRandom();
    pigConfiguration = easyRandom.nextObject(PigConfiguration.class);
    pigConfiguration.getFlow().getRepositoryGeneration().setStrategy(BUILD_GROUP);
    mockBuildsAndArtifacts();
}
Also used : BuildInfoCollector(org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector) PigConfiguration(org.jboss.pnc.bacon.pig.impl.config.PigConfiguration) EasyRandom(org.jeasy.random.EasyRandom) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BuildInfoCollector (org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector)4 PigConfiguration (org.jboss.pnc.bacon.pig.impl.config.PigConfiguration)3 RepoGenerationData (org.jboss.pnc.bacon.pig.impl.config.RepoGenerationData)2 PncBuild (org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)2 FileNotFoundException (java.io.FileNotFoundException)1 PrintWriter (java.io.PrintWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Path (java.nio.file.Path)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 FatalException (org.jboss.pnc.bacon.common.exception.FatalException)1 AddOn (org.jboss.pnc.bacon.pig.impl.addons.AddOn)1 RepoGenerationStrategy (org.jboss.pnc.bacon.pig.impl.config.RepoGenerationStrategy)1 BUILD_GROUP (org.jboss.pnc.bacon.pig.impl.config.RepoGenerationStrategy.BUILD_GROUP)1