Skip to content

Commit

Permalink
Port tooling from JBS
Browse files Browse the repository at this point in the history
  • Loading branch information
rnc committed Dec 18, 2024
1 parent aa60424 commit e0e020e
Show file tree
Hide file tree
Showing 13 changed files with 1,537 additions and 0 deletions.
283 changes: 283 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>47</version>
</parent>

<groupId>org.jboss.pnc</groupId>
<artifactId>konflux-tooling</artifactId>
<version>1.0.0-SNAPSHOT</version>

<name>Konflux Java Tooling</name>
<description>PNC Java Tooling for Konflux</description>
<url>https://github.com/project-ncl/konflux-tooling</url>
<scm>
<connection>scm:git:https://github.com/project-ncl/konflux-tooling.git</connection>
<developerConnection>scm:git:[email protected]:project-ncl/konflux-tooling.git</developerConnection>
<url>https://github.com/project-ncl/konflux-tooling</url>
<tag>HEAD</tag>
</scm>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>rnc</id>
<name>Nick Cross</name>
<email>[email protected]</email>
</developer>
</developers>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.target>${maven.compiler.release}</maven.compiler.target>
<maven.compiler.source>${maven.compiler.release}</maven.compiler.source>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<jboss.releases.repo.id>sonatype-nexus-staging</jboss.releases.repo.id>
<jboss.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2</jboss.releases.repo.url>
<jboss.snapshots.repo.id>sonatype-nexus-snapshots</jboss.snapshots.repo.id>
<jboss.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</jboss.snapshots.repo.url>

<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.17.3</quarkus.platform.version>

<lombok.version>1.18.32</lombok.version>
<formatter-maven-plugin.version>2.24.1</formatter-maven-plugin.version>
<impsort-maven-plugin.version>1.12.0</impsort-maven-plugin.version>

<format.skip>false</format.skip>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-picocli</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
</dependency>

<dependency>
<groupId>io.quarkiverse.mavenresolver</groupId>
<artifactId>quarkus-maven-resolver</artifactId>
<version>0.0.5</version>
</dependency>

<dependency>
<groupId>org.apache.maven.indexer</groupId>
<artifactId>indexer-core</artifactId>
<version>7.1.5</version>
</dependency>
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>pnc-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>3.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>${formatter-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-ide-config</artifactId>
<version>${quarkus.platform.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- store outside of target to speed up formatting when mvn clean is used -->
<cachedir>.cache/formatter-maven-plugin-${formatter-maven-plugin.version}</cachedir>
<configFile>eclipse-format.xml</configFile>
<lineEnding>LF</lineEnding>
<skip>${format.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>${impsort-maven-plugin.version}</version>
<configuration>
<!-- store outside of target to speed up formatting when mvn clean is used -->
<cachedir>.cache/impsort-maven-plugin-${impsort-maven-plugin.version}</cachedir>
<groups>java.,javax.,jakarta.,org.,com.</groups>
<staticGroups>*</staticGroups>
<lineEnding>LF</lineEnding>
<skip>${format.skip}</skip>
<removeUnused>true</removeUnused>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
</profile>
<profile>
<id>format</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!validate-format</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<executions>
<execution>
<id>sort-imports</id>
<goals>
<goal>sort</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>validate</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>validate-format</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<executions>
<execution>
<id>check-imports</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
25 changes: 25 additions & 0 deletions src/main/docker/Dockerfile.all-in-one
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM registry.access.redhat.com/ubi8/openjdk-21@sha256:5ab904e6262629fca79d6f65fa859bfa376405522d2f660bdbfaaae2742586f1 AS builder

USER root
RUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y git

USER 185
WORKDIR /work
COPY ./ .

RUN mvn -V -B package -DskipTests

FROM registry.access.redhat.com/ubi8/openjdk-21-runtime@sha256:0a8cf41082f11f5bc56bd9438851e54593e17051df49592e953fb59376c7d539
WORKDIR /work/

COPY --from=builder /work/target/quarkus-app/lib/ /deployments/lib/
COPY --from=builder /work/target/quarkus-app/*.jar /deployments/
COPY --from=builder /work/target/quarkus-app/app/ /deployments/app/
COPY --from=builder /work/target/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080
USER 185

ENV AB_JOLOKIA_OFF=""
ENV JAVA_OPTS="-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
19 changes: 19 additions & 0 deletions src/main/java/org/jboss/pnc/konfluxtooling/EntryPoint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.jboss.pnc.konfluxtooling;

import org.jboss.pnc.konfluxtooling.deploy.CopyArtifactsCommand;
import org.jboss.pnc.konfluxtooling.deploy.DeployCommand;
import org.jboss.pnc.konfluxtooling.notification.NotifyCommand;
import org.jboss.pnc.konfluxtooling.prebuild.Preprocessor;

import io.quarkus.picocli.runtime.annotations.TopCommand;
import picocli.CommandLine;

@TopCommand
@CommandLine.Command(mixinStandardHelpOptions = true, subcommands = {
CopyArtifactsCommand.class,
DeployCommand.class,
NotifyCommand.class,
Preprocessor.class
})
public class EntryPoint {
}
30 changes: 30 additions & 0 deletions src/main/java/org/jboss/pnc/konfluxtooling/ResultsUpdater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.jboss.pnc.konfluxtooling;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;

import jakarta.enterprise.context.ApplicationScoped;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.quarkus.logging.Log;

@ApplicationScoped
public class ResultsUpdater {

public static ObjectMapper MAPPER = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);

public void updateResults(Map<String, String> results) {

for (var e : results.entrySet()) {
try {
Files.writeString(Paths.get("/tekton/results", e.getKey()), e.getValue());
} catch (IOException ex) {
Log.errorf(ex, "Failed to write result %s", e.getKey());
}
}
}
}
Loading

0 comments on commit e0e020e

Please sign in to comment.