Skip to content

Commit

Permalink
Add required properties for expansion in the build ConfigSource.
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Feb 3, 2021
1 parent 237b725 commit d0115d5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -128,6 +132,10 @@ protected MavenProject mavenProject() {
return project;
}

public MavenSession mavenSession() {
return session;
}

protected File buildDir() {
return buildDir;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit d0115d5

Please sign in to comment.