Skip to content

Commit

Permalink
Add support for Windows artifacts from Brew
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalluck committed Dec 17, 2024
1 parent fa199b4 commit 497463f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
22 changes: 17 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@
<version.org.codehaus.mojo.buildnumber-maven-plugin>3.2.1</version.org.codehaus.mojo.buildnumber-maven-plugin>
<version.org.codehaus.mojo.versions-maven-plugin>2.18.0</version.org.codehaus.mojo.versions-maven-plugin>
<version.org.ec4j.maven.editorconfig-maven-plugin>0.1.0</version.org.ec4j.maven.editorconfig-maven-plugin>
<version.org.jboss.pnc>3.1.2</version.org.jboss.pnc>
<version.org.jboss.pnc.build.finder>2.6.0</version.org.jboss.pnc.build.finder>
<version.org.jboss.pnc.build.finder>2.6.1-SNAPSHOT</version.org.jboss.pnc.build.finder>
<version.org.jboss.pnc.logging>1.0.6</version.org.jboss.pnc.logging>
<version.org.jboss.pnc.pnc>3.0.4</version.org.jboss.pnc.pnc>
<version.org.jboss.pnc.pnc-api>3.0.6-SNAPSHOT</version.org.jboss.pnc.pnc-api>
<version.org.junit-pioneer>2.3.0</version.org.junit-pioneer>
<version.org.sonatype.plugins.nexus-staging-maven-plugin>1.7.0</version.org.sonatype.plugins.nexus-staging-maven-plugin>
<version.org.wiremock>3.10.0</version.org.wiremock>
Expand Down Expand Up @@ -130,19 +131,30 @@
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>dto</artifactId>
<version>${version.org.jboss.pnc}</version>
<version>${version.org.jboss.pnc.pnc}</version>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>dto</artifactId>
<version>${version.org.jboss.pnc}</version>
<version>${version.org.jboss.pnc.pnc}</version>
<classifier>patch-builders-jakarta</classifier>
</dependency>
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>pnc-api</artifactId>
<version>${version.org.jboss.pnc.pnc-api}</version>
</dependency>
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>pnc-api</artifactId>
<version>${version.org.jboss.pnc.pnc-api}</version>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>rest-client-jakarta</artifactId>
<version>${version.org.jboss.pnc}</version>
<version>${version.org.jboss.pnc.pnc}</version>
</dependency>
<dependency>
<groupId>org.jboss.pnc.build.finder</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

import static org.jboss.pnc.api.deliverablesanalyzer.dto.Artifact.ArtifactBuilder;
import static org.jboss.pnc.build.finder.core.BuildFinderUtils.isBuildIdZero;
import static org.jboss.pnc.build.finder.pnc.client.PncUtils.GRADLE;
import static org.jboss.pnc.build.finder.pnc.client.PncUtils.MAVEN;
import static org.jboss.pnc.build.finder.pnc.client.PncUtils.NPM;
import static org.jboss.pnc.build.finder.pnc.client.PncUtils.SBT;

import java.net.URL;
import java.util.ArrayList;
Expand All @@ -44,6 +40,8 @@
import org.jboss.pnc.api.deliverablesanalyzer.dto.MavenArtifact.MavenArtifactBuilder;
import org.jboss.pnc.api.deliverablesanalyzer.dto.NPMArtifact;
import org.jboss.pnc.api.deliverablesanalyzer.dto.NPMArtifact.NPMArtifactBuilder;
import org.jboss.pnc.api.deliverablesanalyzer.dto.WindowsArtifact;
import org.jboss.pnc.api.deliverablesanalyzer.dto.WindowsArtifact.WindowsArtifactBuilder;
import org.jboss.pnc.api.enums.LicenseSource;
import org.jboss.pnc.build.finder.core.BuildSystem;
import org.jboss.pnc.build.finder.core.BuildSystemInteger;
Expand All @@ -54,6 +52,7 @@
import org.slf4j.LoggerFactory;

import com.redhat.red.build.koji.model.xmlrpc.KojiArchiveInfo;
import com.redhat.red.build.koji.model.xmlrpc.KojiBtype;

import jakarta.ws.rs.BadRequestException;

Expand Down Expand Up @@ -154,6 +153,14 @@ private static void setCommonArtifactFields(ArtifactBuilder<?, ?> builder, KojiL
return NPMArtifact.builder().name(archiveInfo.getArtifactId()).version(archiveInfo.getVersion());
}

private static WindowsArtifactBuilder<?, ?> createWindowsArtifact(KojiArchiveInfo archiveInfo) {
return WindowsArtifact.builder()
.name(archiveInfo.getArtifactId())
.version(archiveInfo.getVersion())
.platforms(archiveInfo.getPlatforms())
.flags(archiveInfo.getFlags());
}

private static Collection<Artifact> createNotFoundArtifacts(KojiLocalArchive localArchive) {
Collection<Artifact> artifacts = new ArrayList<>();

Expand Down Expand Up @@ -233,14 +240,22 @@ private static Build createBuild(

private static Artifact createArtifact(KojiLocalArchive localArchive, BuildSystem buildSystem, boolean imported) {
KojiArchiveInfo archiveInfo = localArchive.getArchive();
String buildType = archiveInfo.getBuildType();
KojiBtype buildType = archiveInfo.getBuildType();
ArtifactBuilder<?, ?> builder;

switch (buildType) {
case GRADLE, MAVEN, SBT -> builder = createMavenArtifact(archiveInfo);
case NPM -> builder = createNpmArtifact(archiveInfo);
default -> throw new BadRequestException(
"Archive " + archiveInfo.getArtifactId() + " had unhandled artifact type: " + buildType);
case maven:
builder = createMavenArtifact(archiveInfo);
break;
case npm:
builder = createNpmArtifact(archiveInfo);
break;
case win:
builder = createWindowsArtifact(archiveInfo);
break;
default:
throw new BadRequestException(
"Unhandled build type " + buildType + " for local archive " + localArchive);
}

switch (buildSystem) {
Expand Down

0 comments on commit 497463f

Please sign in to comment.