Skip to content

Commit

Permalink
[Quarkus] Pass "quarkus." properties to maven builds
Browse files Browse the repository at this point in the history
  • Loading branch information
avano committed Sep 20, 2023
1 parent 15fac1a commit 48a98b6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private Map<String, String> getProperties() {
if (!QuarkusConfiguration.isQuarkusNative()) {
properties.put("quarkus.openshift.command", getJavaCommand());
}
properties.putAll(QuarkusConfiguration.fromSystemProperties());
return properties;
}

Expand Down Expand Up @@ -181,7 +182,7 @@ private boolean deployPodFailed() {

private boolean integrationPodFailed() {
final List<Pod> pods = OpenshiftClient.get().getLabeledPods("app.kubernetes.io/name", name);
if (pods.size() == 0) {
if (pods.isEmpty()) {
return false;
} else {
return OpenshiftClient.get().isPodFailed(OpenshiftClient.get().getLabeledPods("app.kubernetes.io/name", name).get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -31,17 +32,21 @@ public QuarkusApp(AbstractIntegrationBuilder<?> integrationBuilder) {
String quarkusMavenPluginCreate = String.format("%s:%s:%s:create",
QuarkusConfiguration.quarkusPlatformGroupId(), "quarkus-maven-plugin", QuarkusConfiguration.quarkusPlatformVersion());

Map<String, String> properties = new HashMap<>(Map.of(
"projectGroupId", TestConfiguration.appGroupId(),
"projectArtifactId", name,
"platformGroupId", QuarkusConfiguration.quarkusPlatformGroupId(),
"platformArtifactId", QuarkusConfiguration.quarkusPlatformArtifactId(),
"platformVersion", QuarkusConfiguration.quarkusPlatformVersion(),
"extensions", OpenshiftConfiguration.isOpenshift() ? "openshift" : ""
));

properties.putAll(QuarkusConfiguration.fromSystemProperties());

Maven.invoke(new BuildRequest.Builder()
.withBaseDirectory(TestConfiguration.appLocation())
.withGoals(quarkusMavenPluginCreate)
.withProperties(Map.of(
"projectGroupId", TestConfiguration.appGroupId(),
"projectArtifactId", name,
"platformGroupId", QuarkusConfiguration.quarkusPlatformGroupId(),
"platformArtifactId", QuarkusConfiguration.quarkusPlatformArtifactId(),
"platformVersion", QuarkusConfiguration.quarkusPlatformVersion(),
"extensions", OpenshiftConfiguration.isOpenshift() ? "openshift" : ""
))
.withProperties(properties)
.withLogFile(getLogPath(Phase.GENERATE))
.withLogMarker(LogStream.marker(name, Phase.GENERATE))
.build()
Expand All @@ -52,13 +57,16 @@ public QuarkusApp(AbstractIntegrationBuilder<?> integrationBuilder) {
customizeProject(integrationBuilder.getDependencies());
customizePlugins(integrationBuilder.getPlugins());

properties = new HashMap<>(Map.of(
"skipTests", "true",
"quarkus.native.container-build", "true"
));
properties.putAll(QuarkusConfiguration.fromSystemProperties());

BuildRequest.Builder requestBuilder = new BuildRequest.Builder()
.withBaseDirectory(TestConfiguration.appLocation().resolve(name))
.withGoals("clean", "package")
.withProperties(Map.of(
"skipTests", "true",
"quarkus.native.container-build", "true"
))
.withProperties(properties)
.withLogFile(getLogPath(Phase.BUILD))
.withLogMarker(LogStream.marker(name, Phase.BUILD));
if (QuarkusConfiguration.isQuarkusNative() && !OpenshiftConfiguration.isOpenshift()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

import software.tnb.product.camel.CamelConfiguration;

import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class QuarkusConfiguration extends CamelConfiguration {
// All properties starting with "quarkus." are propagated to the maven builds (to allow customizing quarkus build "globally")
// To include only properties passed as system properties, this list contains properties that are defined in this class
// and are filtered out and not passed to the maven build (or are passed as different properties)
// if you're adding a new property and it starts with "quarkus.", consider adding it to this set
private static final Set<String> ignoredQuarkusProperties =
Set.of("quarkus.version", "quarkus.native", "quarkus.platform.group-id", "quarkus.platform.artifact-id", "quarkus.platform.version");
public static final String CAMEL_QUARKUS_VERSION = "camel-quarkus.version";

public static final String DEFAULT_CAMEL_QUARKUS_VERSION = "2.13.3";
Expand Down Expand Up @@ -65,4 +75,17 @@ public static String camelQuarkusPlatformVersion() {
return getProperty(CAMEL_QUARKUS_PLATFORM_VERSION);
}

/**
* Collect all "quarkus." properties defined as system properties and filter out properties from QuarkusConfiguration class.
*
* @return map of quarkus properties
*/
public static Map<String, String> fromSystemProperties() {
return System.getProperties()
.entrySet()
.stream()
.filter(e -> e.getKey().toString().startsWith("quarkus."))
.filter(e -> !ignoredQuarkusProperties.contains(e.getKey().toString()))
.collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
}
}

0 comments on commit 48a98b6

Please sign in to comment.