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;
}
}
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);
}
}
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);
});
}
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();
}
Aggregations