Search in sources :

Example 21 with PncBuild

use of org.jboss.pnc.bacon.pig.impl.pnc.PncBuild 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 22 with PncBuild

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

the class SourcesGenerator method generateSources.

public void generateSources(Map<String, PncBuild> builds, RepositoryData repo) {
    if (sourcesGenerationData.getStrategy() == SourcesGenerationStrategy.IGNORE) {
        log.info("Ignoring source zip generation");
        return;
    }
    File workDir = FileUtils.mkTempDir("sources");
    File contentsDir = new File(workDir, topLevelDirectoryName);
    contentsDir.mkdirs();
    if (sourcesGenerationData.getStrategy() == SourcesGenerationStrategy.GENERATE_SELECTED) {
        PncBuild sourceBuild = builds.get(sourcesGenerationData.getSourceBuild());
        builds = Maps.filterEntries(builds, entry -> entry.getKey().equals(sourceBuild.getName()));
    }
    downloadSourcesFromBuilds(builds, workDir, contentsDir);
    if (sourcesGenerationData.getStrategy() == SourcesGenerationStrategy.GENERATE_EXTENDED) {
        addSourcesOfUnreleasedDependencies(repo, workDir, contentsDir);
    }
    File zipFile = new File(targetZipFileName);
    FileUtils.zip(zipFile, workDir, contentsDir);
}
Also used : GAV(org.jboss.pnc.bacon.pig.impl.utils.GAV) MRRCSearcher(org.jboss.pnc.bacon.pig.impl.documents.sharedcontent.MRRCSearcher) BuildClient(org.jboss.pnc.client.BuildClient) LoggerFactory(org.slf4j.LoggerFactory) GerritUtils.gerritSnapshotDownloadUrl(org.jboss.pnc.bacon.pig.impl.utils.GerritUtils.gerritSnapshotDownloadUrl) ClientCreator(org.jboss.pnc.bacon.pnc.common.ClientCreator) Map(java.util.Map) FileDownloadUtils(org.jboss.pnc.bacon.pig.impl.utils.FileDownloadUtils) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) RepositoryData(org.jboss.pnc.bacon.pig.impl.repo.RepositoryData) URI(java.net.URI) KojiArchiveInfo(com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo) FileUtils(org.jboss.pnc.bacon.pig.impl.utils.FileUtils) Logger(org.slf4j.Logger) Files(java.nio.file.Files) Predicate(java.util.function.Predicate) Collection(java.util.Collection) IOException(java.io.IOException) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) KojiBuildInfo(com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo) KojiBuild(org.jboss.pnc.build.finder.koji.KojiBuild) RemoteResourceException(org.jboss.pnc.client.RemoteResourceException) Optional(java.util.Optional) FilenameUtils(org.apache.commons.io.FilenameUtils) BrewSearcher(org.jboss.pnc.bacon.pig.impl.documents.sharedcontent.BrewSearcher) InputStream(java.io.InputStream) File(java.io.File) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)

Example 23 with PncBuild

use of org.jboss.pnc.bacon.pig.impl.pnc.PncBuild 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 24 with PncBuild

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

the class RepoManager method buildConfigs.

private RepositoryData buildConfigs() {
    log.info("Generating maven repo for named build configs");
    List<ArtifactWrapper> artifactsToPack = new ArrayList<>();
    if (generationData.getSourceBuilds().isEmpty()) {
        throw new RuntimeException("There are no build configs defined for maven repository generation. Aborting!");
    }
    for (String buildConfigName : generationData.getSourceBuilds()) {
        PncBuild build = getBuild(buildConfigName);
        getRedhatArtifacts(artifactsToPack, build);
    }
    File sourceDir = createMavenGenerationDir();
    filterAndDownload(artifactsToPack, sourceDir);
    return repackage(sourceDir);
}
Also used : ArtifactWrapper(org.jboss.pnc.bacon.pig.impl.pnc.ArtifactWrapper) ArrayList(java.util.ArrayList) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) File(java.io.File)

Example 25 with PncBuild

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

the class RepoManager method packAllBuiltAndDependencies.

@Deprecated
private RepositoryData packAllBuiltAndDependencies() {
    log.warn("Repo generation strategy 'PACK_ALL' is deprecated please use BUILD_CONFIGS");
    PncBuild build = getBuild(generationData.getSourceBuild());
    List<ArtifactWrapper> artifactsToPack = new ArrayList<>();
    getRedhatArtifacts(artifactsToPack, build);
    File sourceDir = createMavenGenerationDir();
    filterAndDownload(artifactsToPack, sourceDir);
    return repackage(sourceDir);
}
Also used : ArtifactWrapper(org.jboss.pnc.bacon.pig.impl.pnc.ArtifactWrapper) ArrayList(java.util.ArrayList) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) File(java.io.File)

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