From d0115d51ee3e5f948e2d073892387de851f322da Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Wed, 3 Feb 2021 22:31:06 +0000 Subject: [PATCH] Add required properties for expansion in the build ConfigSource. --- .../quarkus/maven/QuarkusBootstrapMojo.java | 8 +++++++ .../maven/QuarkusBootstrapProvider.java | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java index 031a190bb73f9c..983acef449b5b8 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapMojo.java @@ -3,6 +3,7 @@ import java.io.File; import java.util.List; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -47,6 +48,9 @@ public abstract class QuarkusBootstrapMojo extends AbstractMojo { @Parameter(defaultValue = "${project}", readonly = true, required = true) private MavenProject project; + @Parameter(defaultValue = "${session}", readonly = true) + private MavenSession session; + @Parameter(defaultValue = "${project.build.directory}") private File buildDir; @@ -128,6 +132,10 @@ protected MavenProject mavenProject() { return project; } + public MavenSession mavenSession() { + return session; + } + protected File buildDir() { return buildDir; } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java index f3924a4774601e..ccbf5a8f287a44 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java @@ -1,5 +1,8 @@ package io.quarkus.maven; +import static io.smallrye.common.expression.Expression.Flag.LENIENT_SYNTAX; +import static io.smallrye.common.expression.Expression.Flag.NO_TRIM; + import java.io.Closeable; import java.io.File; import java.io.IOException; @@ -25,6 +28,7 @@ import io.quarkus.bootstrap.model.PathsCollection; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; +import io.smallrye.common.expression.Expression; @Component(role = QuarkusBootstrapProvider.class, instantiationStrategy = "singleton") public class QuarkusBootstrapProvider implements Closeable { @@ -166,6 +170,23 @@ protected QuarkusBootstrap bootstrapQuarkus(QuarkusBootstrapMojo mojo) throws Mo effectiveProperties.putIfAbsent("quarkus.application.name", mojo.mavenProject().getArtifactId()); effectiveProperties.putIfAbsent("quarkus.application.version", mojo.mavenProject().getVersion()); + // Add other properties that may be required for expansion + for (Object value : effectiveProperties.values()) { + for (final String reference : Expression.compile((String) value, LENIENT_SYNTAX, NO_TRIM) + .getReferencedStrings()) { + String referenceValue = mojo.mavenSession().getUserProperties().getProperty(reference); + if (referenceValue != null) { + effectiveProperties.setProperty(reference, referenceValue); + continue; + } + + referenceValue = projectProperties.getProperty(reference); + if (referenceValue != null) { + effectiveProperties.setProperty(reference, referenceValue); + } + } + } + QuarkusBootstrap.Builder builder = QuarkusBootstrap.builder() .setAppArtifact(projectArtifact(mojo)) .setMavenArtifactResolver(artifactResolver(mojo))