Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable incubating model resolver in dev mode and quarkus:dependency-tree #40946

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ private void logTree(final Consumer<String> log) throws MojoExecutionException {
"Parameter 'mode' was set to '" + mode + "' while expected one of 'dev', 'test' or 'prod'");
}
}
// enable the incubating model resolver impl by default for this mojo
modelResolver.setIncubatingModelResolver(
IncubatingApplicationModelResolver.isIncubatingEnabled(project.getProperties()));
!IncubatingApplicationModelResolver.isIncubatingModelResolverProperty(project.getProperties(), "false"));
modelResolver.setDepLogConfig(DependencyLoggingConfig.builder()
.setMessageConsumer(log)
.setVerbose(verbose)
Expand Down
4 changes: 3 additions & 1 deletion devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,9 @@ private QuarkusDevModeLauncher newLauncher(Boolean debugPortOk, String bootstrap
.setDevMode(true)
.setTest(LaunchMode.TEST.equals(getLaunchModeClasspath()))
.setCollectReloadableDependencies(!noDeps)
.setIncubatingModelResolver(IncubatingApplicationModelResolver.isIncubatingEnabled(project.getProperties()))
// enabled the incubating model resolver for in dev mode
.setIncubatingModelResolver(!IncubatingApplicationModelResolver
.isIncubatingModelResolverProperty(project.getProperties(), "false"))
.resolveModel(mvnCtx.getCurrentProject().getAppArtifact());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ private CuratedApplication doBootstrap(QuarkusBootstrapMojo mojo, LaunchMode mod

final BootstrapAppModelResolver modelResolver = new BootstrapAppModelResolver(artifactResolver(mojo, mode))
.setIncubatingModelResolver(
IncubatingApplicationModelResolver.isIncubatingEnabled(mojo.mavenProject().getProperties()))
IncubatingApplicationModelResolver.isIncubatingEnabled(mojo.mavenProject().getProperties())
|| mode == LaunchMode.DEVELOPMENT
&& !IncubatingApplicationModelResolver.isIncubatingModelResolverProperty(
mojo.mavenProject().getProperties(), "false"))
.setDevMode(mode == LaunchMode.DEVELOPMENT)
.setTest(mode == LaunchMode.TEST)
.setCollectReloadableDependencies(mode == LaunchMode.DEVELOPMENT || mode == LaunchMode.TEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.Set;
import java.util.TreeSet;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;

import io.quarkus.bootstrap.model.ApplicationModel;
Expand Down Expand Up @@ -83,8 +82,9 @@ void createBuildTimeActions(BuildProducer<BuildTimeActionBuildItem> buildTimeAct
}

private boolean isEnabled() {
Config c = ConfigProvider.getConfig();
return c.getValue("quarkus.bootstrap.incubating-model-resolver", Boolean.class);
var value = ConfigProvider.getConfig().getConfigValue("quarkus.bootstrap.incubating-model-resolver");
// if it's not false and if it's false it doesn't come from the default value
return value == null || !"false".equals(value.getValue()) || "default values".equals(value.getSourceName());
}

private void buildTree(ApplicationModel model, Root root, Optional<Set<String>> allGavs, Optional<String> toTarget) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -172,11 +173,12 @@ private BootstrapAppModelResolver initAppModelResolver(MavenArtifactResolver art
.setDevMode(devMode);
var project = artifactResolver.getMavenContext().getCurrentProject();
if (project != null) {
appModelResolver.setIncubatingModelResolver(
IncubatingApplicationModelResolver.isIncubatingEnabled(
project.getModelBuildingResult() == null
? project.getRawModel().getProperties()
: project.getModelBuildingResult().getEffectiveModel().getProperties()));
final Properties modelProps = project.getModelBuildingResult() == null
? project.getRawModel().getProperties()
: project.getModelBuildingResult().getEffectiveModel().getProperties();
appModelResolver.setIncubatingModelResolver(IncubatingApplicationModelResolver.isIncubatingEnabled(modelProps)
|| devMode
&& !IncubatingApplicationModelResolver.isIncubatingModelResolverProperty(modelProps, "false"));
}
return appModelResolver;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
Expand Down Expand Up @@ -82,15 +83,44 @@ public class IncubatingApplicationModelResolver {

/**
* Temporary method that will be removed once this implementation becomes the default.
* <p>
* Returns {@code true} if system or POM property {@code quarkus.bootstrap.incubating-model-resolver}
* is set to {@code true}.
*
* @return true if this implementation is enabled
*/
public static boolean isIncubatingEnabled(Properties projectProperties) {
return Boolean.parseBoolean(getIncubatingModelResolverProperty(projectProperties));
}

/**
* Temporary method that will be removed once this implementation becomes the default.
* <p>
* Calls {@link #getIncubatingModelResolverProperty(Properties)} and checks whether the returned value
* equals the passed in {@code value}.
*
* @return true if value of quarkus.bootstrap.incubating-model-resolver property is equal to the passed in value
*/
public static boolean isIncubatingModelResolverProperty(Properties projectProperties, String value) {
Objects.requireNonNull(value);
return value.equals(getIncubatingModelResolverProperty(projectProperties));
}

/**
* Temporary method that will be removed once this implementation becomes the default.
* <p>
* Returns value of system or POM property {@code quarkus.bootstrap.incubating-model-resolver}.
* The system property is checked first and if its value is not {@code null}, it's returned.
* Otherwise, the value of POM property is returned as the result.
*
* @return value of system or POM property quarkus.bootstrap.incubating-model-resolver or null if it's not set
*/
public static String getIncubatingModelResolverProperty(Properties projectProperties) {
var value = System.getProperty(INCUBATING_MODEL_RESOLVER);
if (value == null && projectProperties != null) {
value = String.valueOf(projectProperties.get(INCUBATING_MODEL_RESOLVER));
if (value != null || projectProperties == null) {
return value;
}
return Boolean.parseBoolean(value);
return String.valueOf(projectProperties.get(INCUBATING_MODEL_RESOLVER));
}

public static IncubatingApplicationModelResolver newInstance() {
Expand Down
Loading