Search in sources :

Example 26 with PncBuild

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

the class RepoManager method download.

private File download() {
    PncBuild build = getBuild(generationData.getSourceBuild());
    File downloadedZip = new File(workDir, "downloaded.zip");
    build.downloadArtifact(generationData.getSourceArtifact(), downloadedZip);
    File extractedZip = unzip(downloadedZip);
    return getTopLevelDirectory(extractedZip);
}
Also used : PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) File(java.io.File)

Example 27 with PncBuild

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

the class RepoManager method addAdditionalArtifacts.

private void addAdditionalArtifacts() {
    List<AdditionalArtifactsFromBuild> artifactList = generationData.getAdditionalArtifacts();
    artifactList.forEach(artifacts -> {
        PncBuild build = getBuild(artifacts.getFrom());
        artifacts.getDownload().forEach(regex -> downloadArtifact(build.findArtifact(regex)));
    });
    generationData.getExternalAdditionalArtifacts().stream().map(GAV::fromColonSeparatedGAPV).forEach(this::downloadExternalArtifact);
}
Also used : AdditionalArtifactsFromBuild(org.jboss.pnc.bacon.pig.impl.config.AdditionalArtifactsFromBuild) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild)

Example 28 with PncBuild

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

the class RepoManager method collectRedhatVersions.

public Map<Artifact, String> collectRedhatVersions(List<Artifact> extensionArtifacts) {
    Map<Artifact, String> result = new HashMap<>();
    builds.forEach((key, pncBuild) -> {
        if (pncBuild.getBuiltArtifacts() != null) {
            pncBuild.getBuiltArtifacts().forEach((artifactWrapper -> {
                extensionArtifacts.forEach((extensionArtifact -> {
                    GAV gav = artifactWrapper.toGAV();
                    if (extensionArtifact.getGroupId().equals(gav.getGroupId()) && extensionArtifact.getArtifactId().equals(gav.getArtifactId())) {
                        result.put(extensionArtifact, gav.getVersion());
                    }
                }));
            }));
        }
        if (pncBuild.getDependencyArtifacts() != null) {
            pncBuild.getDependencyArtifacts().forEach((artifactWrapper -> {
                extensionArtifacts.forEach((extensionArtifact -> {
                    GAV gav = artifactWrapper.toGAV();
                    if (extensionArtifact.getGroupId().equals(gav.getGroupId()) && extensionArtifact.getArtifactId().equals(gav.getArtifactId())) {
                        result.put(extensionArtifact, gav.getVersion());
                    }
                }));
            }));
        }
    });
    return result;
}
Also used : HttpURLConnection(java.net.HttpURLConnection) GAV(org.jboss.pnc.bacon.pig.impl.utils.GAV) Getter(lombok.Getter) RepoGenerationStrategy(org.jboss.pnc.bacon.pig.impl.config.RepoGenerationStrategy) BuildInfoCollector(org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector) URL(java.net.URL) Dependency(org.eclipse.aether.graph.Dependency) LoggerFactory(org.slf4j.LoggerFactory) PigConfiguration(org.jboss.pnc.bacon.pig.impl.config.PigConfiguration) MavenArtifactResolver(io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver) HashMap(java.util.HashMap) Indy(org.jboss.pnc.bacon.pig.impl.utils.indy.Indy) AdditionalArtifactsFromBuild(org.jboss.pnc.bacon.pig.impl.config.AdditionalArtifactsFromBuild) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) PigContext(org.jboss.pnc.bacon.pig.impl.PigContext) Deliverables(org.jboss.pnc.bacon.pig.impl.documents.Deliverables) Map(java.util.Map) PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) ResourceUtils(org.jboss.pnc.bacon.pig.impl.utils.ResourceUtils) Path(java.nio.file.Path) FileUtils(org.jboss.pnc.bacon.pig.impl.utils.FileUtils) Logger(org.slf4j.Logger) Properties(java.util.Properties) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) FatalException(org.jboss.pnc.bacon.common.exception.FatalException) MalformedURLException(java.net.MalformedURLException) Predicate(java.util.function.Predicate) Collection(java.util.Collection) DeliverableManager(org.jboss.pnc.bacon.pig.impl.common.DeliverableManager) LicenseGenerator(org.jboss.pnc.bacon.pig.impl.license.LicenseGenerator) Artifact(org.eclipse.aether.artifact.Artifact) RepoGenerationData(org.jboss.pnc.bacon.pig.impl.config.RepoGenerationData) Set(java.util.Set) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) Paths(java.nio.file.Paths) Closeable(java.io.Closeable) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) ArtifactWrapper(org.jboss.pnc.bacon.pig.impl.pnc.ArtifactWrapper) HashMap(java.util.HashMap) GAV(org.jboss.pnc.bacon.pig.impl.utils.GAV) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact)

Example 29 with PncBuild

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

the class RepoManager method generate.

public RepositoryData generate() {
    log.info("Generating maven repository");
    PncBuild build = getBuild(generationData.getSourceBuild());
    File bomDirectory = FileUtils.mkTempDir("repo-from-bom-generation");
    RepoBuilder repoBuilder = new RepoBuilder(pigConfiguration, generationData.getAdditionalRepo(), configurationDirectory, builds, removeGeneratedM2Dups);
    File bomFile = new File(bomDirectory, "bom.pom");
    build.downloadArtifact(generationData.getSourceArtifact(), bomFile);
    String topLevelDirectoryName = pigConfiguration.getTopLevelDirectoryPrefix() + "maven-repository";
    File repoWorkDir = FileUtils.mkTempDir("repository");
    File repoParentDir = new File(repoWorkDir, topLevelDirectoryName);
    List<Map<String, String>> stages = generationData.getStages();
    if (stages != null) {
        stages.forEach(stage -> repoBuilder.build(bomFile, repoParentDir, predicate(stage)));
    } else {
        repoBuilder.build(bomFile, repoParentDir, gav -> true);
    }
    return repackage(new File(repoParentDir, "maven-repository"));
}
Also used : PncBuild(org.jboss.pnc.bacon.pig.impl.pnc.PncBuild) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map)

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