Skip to content

Commit

Permalink
Enable incubating model resolver in dev mode and quarkus:dependency-tree
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Jun 3, 2024
1 parent d21c683 commit 7756ae4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 14 deletions.
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

0 comments on commit 7756ae4

Please sign in to comment.