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