diff --git a/pom.xml b/pom.xml index 42bd229..075f5c8 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,10 @@ + + io.quarkus + quarkus-config-yaml + io.quarkus quarkus-picocli diff --git a/src/main/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommand.java b/src/main/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommand.java index b437b41..9781d48 100644 --- a/src/main/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommand.java +++ b/src/main/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommand.java @@ -80,6 +80,8 @@ public void run() { Log.infof("Found %d POMs and %d JARs in %s", pomFiles.size(), jarFiles.size(), sourcePath); + Files.createDirectories(deployPath); + for (var entry : pomFiles.entrySet()) { var gav = entry.getKey(); Log.debugf("POM has GAV %s", gavToCoords(gav)); diff --git a/src/main/java/org/jboss/pnc/konfluxtooling/prebuild/Preprocessor.java b/src/main/java/org/jboss/pnc/konfluxtooling/prebuild/Preprocessor.java index 6347f08..b28f1ee 100644 --- a/src/main/java/org/jboss/pnc/konfluxtooling/prebuild/Preprocessor.java +++ b/src/main/java/org/jboss/pnc/konfluxtooling/prebuild/Preprocessor.java @@ -177,7 +177,7 @@ public void run() { } } - private String getContainerFile() { + String getContainerFile() { String containerFile = """ FROM %s USER 0 @@ -196,7 +196,7 @@ private String getContainerFile() { USER 0 WORKDIR /var/workdir COPY --from=0 /var/workdir/ /var/workdir/ - RUN /opt/jboss/container/java/run/run-java.sh -Dquarkus.http.port=8084 copy-artifacts --source-path=/var/workdir/workspace/source --deploy-path=/var/workdir/workspace/artifacts + RUN /opt/jboss/container/java/run/run-java.sh copy-artifacts --source-path=/var/workdir/workspace/source --deploy-path=/var/workdir/workspace/artifacts FROM scratch COPY --from=1 /var/workdir/workspace/artifacts /deployment/ COPY --from=1 /var/workdir/build.log /log/ diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..e541324 --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,9 @@ +quarkus: + application: + name: konflux-tooling + log: + category: + "org.jboss.pnc.konfluxtooling": + level: INFO + http: + port: 8084 diff --git a/src/test/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommandTest.java b/src/test/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommandTest.java index 101a2fc..a2e7eca 100644 --- a/src/test/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommandTest.java +++ b/src/test/java/org/jboss/pnc/konfluxtooling/deploy/CopyArtifactsCommandTest.java @@ -1,17 +1,18 @@ package org.jboss.pnc.konfluxtooling.deploy; -import io.quarkus.test.LogCollectingTestResource; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.common.ResourceArg; -import io.quarkus.test.junit.QuarkusTest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.LogCollectingTestResource; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; +import io.quarkus.test.junit.QuarkusTest; @QuarkusTest @QuarkusTestResource(value = LogCollectingTestResource.class, restrictToAnnotatedClass = true, initArgs = @ResourceArg(name = LogCollectingTestResource.LEVEL, value = "FINE")) @@ -21,7 +22,7 @@ void clearLogs() { LogCollectingTestResource.current().clear(); } - void testDeployArtifacts(String dir, String logMessage, String ... artifacts) throws IOException { + void testDeployArtifacts(String dir, String logMessage, String... artifacts) throws IOException { var command = new CopyArtifactsCommand(); command.sourcePath = Path.of("src/test/resources/copy-artifacts", dir).toAbsolutePath(); assertThat(command.sourcePath).isDirectory(); @@ -32,20 +33,23 @@ void testDeployArtifacts(String dir, String logMessage, String ... artifacts) th command.run(); if (!logMessage.isEmpty()) { - assertThat(LogCollectingTestResource.current().getRecords()).map(LogCollectingTestResource::format).contains(logMessage); + assertThat(LogCollectingTestResource.current().getRecords()).map(LogCollectingTestResource::format) + .contains(logMessage); } try (var stream = Files.walk(command.deployPath)) { - assertThat(stream).filteredOn(Files::isRegularFile).map(path -> path.getFileName().toString()).containsExactlyInAnyOrder(artifacts); + assertThat(stream).filteredOn(Files::isRegularFile).map(path -> path.getFileName().toString()) + .containsExactlyInAnyOrder(artifacts); } } @Test void testAsm() throws IOException { - testDeployArtifacts("asm", "Skipping POM asm-all.pom with invalid version @product.artifact@", "asm-5.0.3.jar", "asm-5.0.3.pom", "asm-all-5.0.3.jar", "asm-all-5.0.3.pom", - "asm-analysis-5.0.3.jar", "asm-analysis-5.0.3.pom", "asm-commons-5.0.3.jar", "asm-commons-5.0.3.pom", - "asm-debug-all-5.0.3.jar", "asm-debug-all-5.0.3.pom", "asm-parent-5.0.3.pom", "asm-tree-5.0.3.jar", - "asm-tree-5.0.3.pom", "asm-util-5.0.3.jar", "asm-util-5.0.3.pom", "asm-xml-5.0.3.jar", "asm-xml-5.0.3.pom"); + testDeployArtifacts("asm", "Skipping POM asm-all.pom with invalid version @product.artifact@", "asm-5.0.3.jar", + "asm-5.0.3.pom", "asm-all-5.0.3.jar", "asm-all-5.0.3.pom", + "asm-analysis-5.0.3.jar", "asm-analysis-5.0.3.pom", "asm-commons-5.0.3.jar", "asm-commons-5.0.3.pom", + "asm-debug-all-5.0.3.jar", "asm-debug-all-5.0.3.pom", "asm-parent-5.0.3.pom", "asm-tree-5.0.3.jar", + "asm-tree-5.0.3.pom", "asm-util-5.0.3.jar", "asm-util-5.0.3.pom", "asm-xml-5.0.3.jar", "asm-xml-5.0.3.pom"); } @Test @@ -55,26 +59,49 @@ void testBeanshell() throws IOException { @Test void testIcu4J() throws IOException { - testDeployArtifacts("icu4j", "", "icu4j-71.1.jar", "icu4j-71.1.pom", "icu4j-charset-71.1.jar", "icu4j-charset-71.1.pom", "icu4j-localespi-71.1.jar", "icu4j-localespi-71.1.pom"); + testDeployArtifacts("icu4j", "", "icu4j-71.1.jar", "icu4j-71.1.pom", "icu4j-charset-71.1.jar", "icu4j-charset-71.1.pom", + "icu4j-localespi-71.1.jar", "icu4j-localespi-71.1.pom"); } @Test void testJdom() throws IOException { - testDeployArtifacts("jdom", "Skipping POM maven.pom with invalid version @version@", "jdom2-2.x-2024.03.01.10.00.jar", "jdom2-2.x-2024.03.01.10.00.pom"); + testDeployArtifacts("jdom", "Skipping POM maven.pom with invalid version @version@", "jdom2-2.x-2024.03.01.10.00.jar", + "jdom2-2.x-2024.03.01.10.00.pom"); } @Test void testLombok() throws IOException { - testDeployArtifacts("lombok", "Skipping POM pom.xml with invalid version 1.0-SNAPSHOT", "lombok-1.18.24.jar", "lombok-1.18.24.pom"); + testDeployArtifacts("lombok", "Skipping POM pom.xml with invalid version 1.0-SNAPSHOT", "lombok-1.18.24.jar", + "lombok-1.18.24.pom"); } @Test void testLz4Java() throws IOException { - testDeployArtifacts("lz4-java", "", "lz4-java-1.8.0.jar", "lz4-java-1.8.0.pom", "lz4-pure-java-1.8.0.jar", "lz4-pure-java-1.8.0.pom"); + testDeployArtifacts("lz4-java", "", "lz4-java-1.8.0.jar", "lz4-java-1.8.0.pom", "lz4-pure-java-1.8.0.jar", + "lz4-pure-java-1.8.0.pom"); } @Test void testTomcat() throws IOException { - testDeployArtifacts("tomcat", "Skipping POM tomcat-annotations-api.pom with invalid version @MAVEN.DEPLOY.VERSION@", "tomcat-annotations-api-10.1.19.jar", "tomcat-annotations-api-10.1.19.pom", "tomcat-api-10.1.19.jar", "tomcat-api-10.1.19.pom", "tomcat-catalina-10.1.19.jar", "tomcat-catalina-10.1.19.pom", "tomcat-catalina-ant-10.1.19.jar", "tomcat-catalina-ant-10.1.19.pom", "tomcat-catalina-ha-10.1.19.jar", "tomcat-catalina-ha-10.1.19.pom", "tomcat-coyote-10.1.19.jar", "tomcat-coyote-10.1.19.pom", "tomcat-dbcp-10.1.19.jar", "tomcat-dbcp-10.1.19.pom", "tomcat-el-api-10.1.19.jar", "tomcat-el-api-10.1.19.pom", "tomcat-embed-core-10.1.19.jar", "tomcat-embed-core-10.1.19.pom", "tomcat-embed-el-10.1.19.jar", "tomcat-embed-el-10.1.19.pom", "tomcat-embed-jasper-10.1.19.jar", "tomcat-embed-jasper-10.1.19.pom", "tomcat-embed-programmatic-10.1.19.jar", "tomcat-embed-programmatic-10.1.19.pom", "tomcat-embed-websocket-10.1.19.jar", "tomcat-embed-websocket-10.1.19.pom", "tomcat-jasper-10.1.19.jar", "tomcat-jasper-10.1.19.pom", "tomcat-jasper-el-10.1.19.jar", "tomcat-jasper-el-10.1.19.pom", "tomcat-jaspic-api-10.1.19.jar", "tomcat-jaspic-api-10.1.19.pom", "tomcat-jdbc-10.1.19.jar", "tomcat-jdbc-10.1.19.pom", "tomcat-jni-10.1.19.jar", "tomcat-jni-10.1.19.pom", "tomcat-jsp-api-10.1.19.jar", "tomcat-jsp-api-10.1.19.pom", "tomcat-juli-10.1.19.jar", "tomcat-juli-10.1.19.pom", "tomcat-servlet-api-10.1.19.jar", "tomcat-servlet-api-10.1.19.pom", "tomcat-ssi-10.1.19.jar", "tomcat-ssi-10.1.19.pom", "tomcat-storeconfig-10.1.19.jar", "tomcat-storeconfig-10.1.19.pom", "tomcat-tribes-10.1.19.jar", "tomcat-tribes-10.1.19.pom", "tomcat-util-10.1.19.jar", "tomcat-util-10.1.19.pom", "tomcat-util-scan-10.1.19.jar", "tomcat-util-scan-10.1.19.pom", "tomcat-websocket-10.1.19.jar", "tomcat-websocket-10.1.19.pom", "tomcat-websocket-api-10.1.19.jar", "tomcat-websocket-api-10.1.19.pom", "tomcat-websocket-client-api-10.1.19.jar", "tomcat-websocket-client-api-10.1.19.pom"); + testDeployArtifacts("tomcat", "Skipping POM tomcat-annotations-api.pom with invalid version @MAVEN.DEPLOY.VERSION@", + "tomcat-annotations-api-10.1.19.jar", "tomcat-annotations-api-10.1.19.pom", "tomcat-api-10.1.19.jar", + "tomcat-api-10.1.19.pom", "tomcat-catalina-10.1.19.jar", "tomcat-catalina-10.1.19.pom", + "tomcat-catalina-ant-10.1.19.jar", "tomcat-catalina-ant-10.1.19.pom", "tomcat-catalina-ha-10.1.19.jar", + "tomcat-catalina-ha-10.1.19.pom", "tomcat-coyote-10.1.19.jar", "tomcat-coyote-10.1.19.pom", + "tomcat-dbcp-10.1.19.jar", "tomcat-dbcp-10.1.19.pom", "tomcat-el-api-10.1.19.jar", "tomcat-el-api-10.1.19.pom", + "tomcat-embed-core-10.1.19.jar", "tomcat-embed-core-10.1.19.pom", "tomcat-embed-el-10.1.19.jar", + "tomcat-embed-el-10.1.19.pom", "tomcat-embed-jasper-10.1.19.jar", "tomcat-embed-jasper-10.1.19.pom", + "tomcat-embed-programmatic-10.1.19.jar", "tomcat-embed-programmatic-10.1.19.pom", + "tomcat-embed-websocket-10.1.19.jar", "tomcat-embed-websocket-10.1.19.pom", "tomcat-jasper-10.1.19.jar", + "tomcat-jasper-10.1.19.pom", "tomcat-jasper-el-10.1.19.jar", "tomcat-jasper-el-10.1.19.pom", + "tomcat-jaspic-api-10.1.19.jar", "tomcat-jaspic-api-10.1.19.pom", "tomcat-jdbc-10.1.19.jar", + "tomcat-jdbc-10.1.19.pom", "tomcat-jni-10.1.19.jar", "tomcat-jni-10.1.19.pom", "tomcat-jsp-api-10.1.19.jar", + "tomcat-jsp-api-10.1.19.pom", "tomcat-juli-10.1.19.jar", "tomcat-juli-10.1.19.pom", + "tomcat-servlet-api-10.1.19.jar", "tomcat-servlet-api-10.1.19.pom", "tomcat-ssi-10.1.19.jar", + "tomcat-ssi-10.1.19.pom", "tomcat-storeconfig-10.1.19.jar", "tomcat-storeconfig-10.1.19.pom", + "tomcat-tribes-10.1.19.jar", "tomcat-tribes-10.1.19.pom", "tomcat-util-10.1.19.jar", "tomcat-util-10.1.19.pom", + "tomcat-util-scan-10.1.19.jar", "tomcat-util-scan-10.1.19.pom", "tomcat-websocket-10.1.19.jar", + "tomcat-websocket-10.1.19.pom", "tomcat-websocket-api-10.1.19.jar", "tomcat-websocket-api-10.1.19.pom", + "tomcat-websocket-client-api-10.1.19.jar", "tomcat-websocket-client-api-10.1.19.pom"); } }