diff --git a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java index d9886d3bdd8e00..b00fb467d212d1 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromOriginalJarTestBase.java @@ -72,8 +72,17 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() throws Exception { final QuarkusBootstrap.Builder bootstrap = QuarkusBootstrap.builder() .setApplicationRoot(applicationRoot) .setProjectRoot(applicationRoot) - .setAppModelResolver(resolver) - .setTest(isBootstrapForTestMode()); + .setAppModelResolver(resolver); + + switch (getBootstrapMode()) { + case PROD: + break; + case TEST: + bootstrap.setTest(true); + break; + default: + throw new IllegalArgumentException("Not supported bootstrap mode " + getBootstrapMode()); + } if (createWorkspace() || !wsModules.isEmpty()) { System.setProperty("basedir", ws.toAbsolutePath().toString()); diff --git a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromWorkspaceModuleTestBase.java b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromWorkspaceModuleTestBase.java index 4b02780956a774..6b48998c16cb86 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromWorkspaceModuleTestBase.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/BootstrapFromWorkspaceModuleTestBase.java @@ -19,8 +19,16 @@ protected QuarkusBootstrap.Builder initBootstrapBuilder() .setApplicationRoot(applicationRoot) .setProjectRoot(applicationRoot) .setTargetDirectory(appModel.getAppArtifact().getWorkspaceModule().getBuildDir().toPath()) - .setAppModelResolver(resolver) - .setTest(isBootstrapForTestMode()); + .setAppModelResolver(resolver); + switch (getBootstrapMode()) { + case PROD: + break; + case TEST: + bootstrap.setTest(true); + break; + default: + throw new IllegalArgumentException("Not supported bootstrap mode " + getBootstrapMode()); + } return bootstrap; } } diff --git a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsInTestModeTest.java b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsInTestModeTest.java index 95c7dcf563b713..cc36dc92e3c34d 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsInTestModeTest.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsInTestModeTest.java @@ -5,6 +5,7 @@ import java.util.HashSet; import java.util.Set; +import io.quarkus.bootstrap.app.QuarkusBootstrap; import io.quarkus.bootstrap.model.ApplicationModel; import io.quarkus.bootstrap.resolver.TsArtifact; import io.quarkus.bootstrap.resolver.TsDependency; @@ -17,8 +18,8 @@ public class ProvidedExtensionDepsInTestModeTest extends BootstrapFromOriginalJarTestBase { @Override - protected boolean isBootstrapForTestMode() { - return true; + protected QuarkusBootstrap.Mode getBootstrapMode() { + return QuarkusBootstrap.Mode.TEST; } @Override diff --git a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsTestModeTest.java b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsTestModeTest.java index 26b8f66d583c20..7f6d175f67e71e 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsTestModeTest.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/runnerjar/ProvidedExtensionDepsTestModeTest.java @@ -7,6 +7,7 @@ import org.eclipse.aether.util.artifact.JavaScopes; +import io.quarkus.bootstrap.app.QuarkusBootstrap; import io.quarkus.bootstrap.model.ApplicationModel; import io.quarkus.bootstrap.resolver.TsArtifact; import io.quarkus.bootstrap.resolver.TsDependency; @@ -19,8 +20,8 @@ public class ProvidedExtensionDepsTestModeTest extends BootstrapFromOriginalJarTestBase { @Override - protected boolean isBootstrapForTestMode() { - return true; + protected QuarkusBootstrap.Mode getBootstrapMode() { + return QuarkusBootstrap.Mode.TEST; } @Override diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/BootstrapConstants.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/BootstrapConstants.java index 6c2aa72680a476..9261602b006a89 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/BootstrapConstants.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/BootstrapConstants.java @@ -10,6 +10,7 @@ public interface BootstrapConstants { String SERIALIZED_TEST_APP_MODEL = "quarkus-internal-test.serialized-app-model.path"; String DESCRIPTOR_FILE_NAME = "quarkus-extension.properties"; String CONDITIONAL_DEPENDENCIES = "conditional-dependencies"; + String CONDITIONAL_DEV_DEPENDENCIES = "conditional-dev-dependencies"; String DEPENDENCY_CONDITION = "dependency-condition"; /** diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java index d8861642c21714..e2e54d1c7c1a5f 100644 --- a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/ResolverSetupCleanup.java @@ -18,6 +18,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import io.quarkus.bootstrap.app.QuarkusBootstrap; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; import io.quarkus.bootstrap.resolver.maven.IncubatingApplicationModelResolver; import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; @@ -143,15 +144,24 @@ protected boolean cleanWorkDir() { return true; } - protected boolean isBootstrapForTestMode() { - return false; + protected QuarkusBootstrap.Mode getBootstrapMode() { + return QuarkusBootstrap.Mode.PROD; } protected BootstrapAppModelResolver newAppModelResolver(LocalProject currentProject) throws Exception { final BootstrapAppModelResolver appModelResolver = new BootstrapAppModelResolver(newArtifactResolver(currentProject)); appModelResolver.setIncubatingModelResolver(IncubatingApplicationModelResolver.isIncubatingEnabled(null)); - if (isBootstrapForTestMode()) { - appModelResolver.setTest(true); + switch (getBootstrapMode()) { + case PROD: + break; + case TEST: + appModelResolver.setTest(true); + break; + case DEV: + appModelResolver.setDevMode(true); + break; + default: + throw new IllegalArgumentException("Not supported bootstrap mode " + getBootstrapMode()); } return appModelResolver; } diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsQuarkusExt.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsQuarkusExt.java index f6374e54a47de6..e5bc50e9a74895 100644 --- a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsQuarkusExt.java +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/TsQuarkusExt.java @@ -44,6 +44,16 @@ public TsQuarkusExt setConditionalDeps(TsQuarkusExt... exts) { return setDescriptorProp(BootstrapConstants.CONDITIONAL_DEPENDENCIES, buf.toString()); } + public TsQuarkusExt setConditionalDevDeps(TsQuarkusExt... exts) { + final StringBuilder buf = new StringBuilder(); + int i = 0; + buf.append(exts[i++].getRuntime().toString()); + while (i < exts.length) { + buf.append(' ').append(exts[i++].getRuntime().toString()); + } + return setDescriptorProp(BootstrapConstants.CONDITIONAL_DEV_DEPENDENCIES, buf.toString()); + } + public TsQuarkusExt setDependencyCondition(TsQuarkusExt... exts) { final StringBuilder buf = new StringBuilder(); int i = 0; diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesDevModelTestCase.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesDevModelTestCase.java new file mode 100644 index 00000000000000..20c22683e39fa9 --- /dev/null +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesDevModelTestCase.java @@ -0,0 +1,88 @@ +package io.quarkus.bootstrap.resolver.test; + +import io.quarkus.bootstrap.app.QuarkusBootstrap; +import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver; +import io.quarkus.bootstrap.resolver.CollectDependenciesBase; +import io.quarkus.bootstrap.resolver.TsArtifact; +import io.quarkus.bootstrap.resolver.TsQuarkusExt; +import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; +import io.quarkus.maven.dependency.DependencyFlags; + +public class ConditionalDependenciesDevModelTestCase extends CollectDependenciesBase { + + @Override + protected BootstrapAppModelResolver newAppModelResolver(LocalProject currentProject) throws Exception { + var resolver = super.newAppModelResolver(currentProject); + resolver.setIncubatingModelResolver(false); + return resolver; + } + + @Override + protected QuarkusBootstrap.Mode getBootstrapMode() { + return QuarkusBootstrap.Mode.DEV; + } + + @Override + protected void setupDependencies() { + + final TsQuarkusExt extA = new TsQuarkusExt("ext-a"); + install(extA, false); + addCollectedDeploymentDep(extA.getDeployment()); + + installAsDep(extA.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + + final TsQuarkusExt extB = new TsQuarkusExt("ext-b"); + install(extB, false); + addCollectedDep(extB.getRuntime(), DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extB.getDeployment()); + + final TsQuarkusExt extC = new TsQuarkusExt("ext-c"); + extC.setDependencyCondition(extB); + install(extC, false); + addCollectedDep(extC.getRuntime(), DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extC.getDeployment()); + + final TsQuarkusExt extD = new TsQuarkusExt("ext-d"); + install(extD, false); + installAsDep(extD.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extD.getDeployment()); + + final TsArtifact libE = TsArtifact.jar("lib-e"); + install(libE, true); + final TsArtifact libEBuildTIme = TsArtifact.jar("lib-e-build-time"); + install(libEBuildTIme); + addCollectedDeploymentDep(libEBuildTIme); + + final TsQuarkusExt extE = new TsQuarkusExt("ext-e"); + extE.setDependencyCondition(extD); + extE.getRuntime().addDependency(libE); + extE.getDeployment().addDependency(libEBuildTIme); + install(extE, false); + addCollectedDep(extE.getRuntime(), DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extE.getDeployment()); + + final TsQuarkusExt extF = new TsQuarkusExt("ext-f"); + extF.setConditionalDeps(extC, extE); + install(extF, false); + installAsDep(extF.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extF.getDeployment()); + + final TsQuarkusExt extG = new TsQuarkusExt("ext-g"); + extG.setConditionalDevDeps(extB); + install(extG, false); + installAsDep(extG.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extG.getDeployment()); + } +} diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesProdModelTestCase.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesProdModelTestCase.java new file mode 100644 index 00000000000000..7a470e4f666cc8 --- /dev/null +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesProdModelTestCase.java @@ -0,0 +1,78 @@ +package io.quarkus.bootstrap.resolver.test; + +import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver; +import io.quarkus.bootstrap.resolver.CollectDependenciesBase; +import io.quarkus.bootstrap.resolver.TsArtifact; +import io.quarkus.bootstrap.resolver.TsQuarkusExt; +import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; +import io.quarkus.maven.dependency.DependencyFlags; + +public class ConditionalDependenciesProdModelTestCase extends CollectDependenciesBase { + + @Override + protected BootstrapAppModelResolver newAppModelResolver(LocalProject currentProject) throws Exception { + var resolver = super.newAppModelResolver(currentProject); + resolver.setIncubatingModelResolver(false); + return resolver; + } + + @Override + protected void setupDependencies() { + + final TsQuarkusExt extA = new TsQuarkusExt("ext-a"); + install(extA, false); + addCollectedDeploymentDep(extA.getDeployment()); + + installAsDep(extA.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + + final TsQuarkusExt extB = new TsQuarkusExt("ext-b"); + install(extB, false); + + final TsQuarkusExt extC = new TsQuarkusExt("ext-c"); + extC.setDependencyCondition(extB); + install(extC, false); + + final TsQuarkusExt extD = new TsQuarkusExt("ext-d"); + install(extD, false); + installAsDep(extD.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extD.getDeployment()); + + final TsArtifact libE = TsArtifact.jar("lib-e"); + install(libE, true); + final TsArtifact libEBuildTIme = TsArtifact.jar("lib-e-build-time"); + install(libEBuildTIme); + addCollectedDeploymentDep(libEBuildTIme); + + final TsQuarkusExt extE = new TsQuarkusExt("ext-e"); + extE.setDependencyCondition(extD); + extE.getRuntime().addDependency(libE); + extE.getDeployment().addDependency(libEBuildTIme); + install(extE, false); + addCollectedDep(extE.getRuntime(), DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extE.getDeployment()); + + final TsQuarkusExt extF = new TsQuarkusExt("ext-f"); + extF.setConditionalDeps(extC, extE); + install(extF, false); + installAsDep(extF.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extF.getDeployment()); + + final TsQuarkusExt extG = new TsQuarkusExt("ext-g"); + extG.setConditionalDevDeps(extB); + install(extG, false); + installAsDep(extG.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extG.getDeployment()); + } +} diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/RuntimeOnlyApplicationModelTestCase.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesRuntimeOnlyProdModelTestCase.java similarity index 96% rename from independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/RuntimeOnlyApplicationModelTestCase.java rename to independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesRuntimeOnlyProdModelTestCase.java index f0ddf15c9ede3a..cf246b9a85f2f4 100644 --- a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/RuntimeOnlyApplicationModelTestCase.java +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/ConditionalDependenciesRuntimeOnlyProdModelTestCase.java @@ -7,7 +7,7 @@ import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; import io.quarkus.maven.dependency.DependencyFlags; -public class RuntimeOnlyApplicationModelTestCase extends CollectDependenciesBase { +public class ConditionalDependenciesRuntimeOnlyProdModelTestCase extends CollectDependenciesBase { private static final boolean runtimeOnly = true; diff --git a/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/DevModeConditionalDependencyWithExtraConditionTestCase.java b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/DevModeConditionalDependencyWithExtraConditionTestCase.java new file mode 100644 index 00000000000000..77ecac97bf92f3 --- /dev/null +++ b/independent-projects/bootstrap/core/src/test/java/io/quarkus/bootstrap/resolver/test/DevModeConditionalDependencyWithExtraConditionTestCase.java @@ -0,0 +1,63 @@ +package io.quarkus.bootstrap.resolver.test; + +import io.quarkus.bootstrap.app.QuarkusBootstrap; +import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver; +import io.quarkus.bootstrap.resolver.CollectDependenciesBase; +import io.quarkus.bootstrap.resolver.TsQuarkusExt; +import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; +import io.quarkus.maven.dependency.DependencyFlags; + +public class DevModeConditionalDependencyWithExtraConditionTestCase extends CollectDependenciesBase { + + @Override + protected BootstrapAppModelResolver newAppModelResolver(LocalProject currentProject) throws Exception { + var resolver = super.newAppModelResolver(currentProject); + resolver.setIncubatingModelResolver(false); + return resolver; + } + + @Override + protected QuarkusBootstrap.Mode getBootstrapMode() { + return QuarkusBootstrap.Mode.DEV; + } + + @Override + protected void setupDependencies() { + + final TsQuarkusExt extA = new TsQuarkusExt("ext-a"); + install(extA, false); + addCollectedDeploymentDep(extA.getDeployment()); + + installAsDep(extA.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + + final TsQuarkusExt extB = new TsQuarkusExt("ext-b"); + install(extB, false); + addCollectedDep(extB.getRuntime(), DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extB.getDeployment()); + + final TsQuarkusExt extC = new TsQuarkusExt("ext-c"); + extC.setDependencyCondition(extA); + install(extC, false); + addCollectedDep(extC.getRuntime(), DependencyFlags.RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extC.getDeployment()); + + final TsQuarkusExt extD = new TsQuarkusExt("ext-d"); + install(extD, false); + + final TsQuarkusExt extE = new TsQuarkusExt("ext-e"); + extE.setDependencyCondition(extD); + install(extE, false); + + final TsQuarkusExt extG = new TsQuarkusExt("ext-g"); + extG.setConditionalDevDeps(extB, extC, extE); + install(extG, false); + installAsDep(extG.getRuntime(), + DependencyFlags.DIRECT + | DependencyFlags.RUNTIME_EXTENSION_ARTIFACT + | DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT); + addCollectedDeploymentDep(extG.getDeployment()); + } +} diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java index d0f1b3a3139f97..2bc13f5a18ccdf 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/BootstrapAppModelResolver.java @@ -378,6 +378,7 @@ private ApplicationModel buildAppModel(ResolvedDependencyBuilder appArtifact, .setCollectCompileOnly(filteredProvidedDeps) .setDependencyLogging(depLogConfig) .setRuntimeModelOnly(runtimeModelOnly) + .setDevMode(devmode) .resolve(collectRtDepsRequest); } else { ApplicationDependencyTreeResolver.newInstance() @@ -387,6 +388,7 @@ private ApplicationModel buildAppModel(ResolvedDependencyBuilder appArtifact, .setCollectCompileOnly(filteredProvidedDeps) .setBuildTreeConsumer(depLogConfig == null ? null : depLogConfig.getMessageConsumer()) .setRuntimeModelOnly(runtimeModelOnly) + .setDevMode(devmode) .resolve(collectRtDepsRequest); } if (logTime) { diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java index a5d2ce58cde78f..6505fab69b4cd2 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java @@ -2,7 +2,6 @@ import static io.quarkus.bootstrap.util.DependencyUtils.getKey; import static io.quarkus.bootstrap.util.DependencyUtils.newDependencyBuilder; -import static io.quarkus.bootstrap.util.DependencyUtils.toArtifact; import java.io.BufferedReader; import java.io.IOException; @@ -52,10 +51,8 @@ import io.quarkus.bootstrap.BootstrapConstants; import io.quarkus.bootstrap.BootstrapDependencyProcessingException; import io.quarkus.bootstrap.model.ApplicationModelBuilder; -import io.quarkus.bootstrap.model.CapabilityContract; import io.quarkus.bootstrap.model.PlatformImportsImpl; import io.quarkus.bootstrap.resolver.AppModelResolverException; -import io.quarkus.bootstrap.util.BootstrapUtils; import io.quarkus.bootstrap.util.DependencyUtils; import io.quarkus.bootstrap.util.PropertyUtils; import io.quarkus.bootstrap.workspace.WorkspaceModule; @@ -107,6 +104,7 @@ public static Artifact getRuntimeArtifact(DependencyNode dep) { private Consumer buildTreeConsumer; private List collectCompileOnly; private boolean runtimeModelOnly; + private boolean devMode; public ApplicationDependencyTreeResolver setArtifactResolver(MavenArtifactResolver resolver) { this.resolver = resolver; @@ -140,11 +138,28 @@ public ApplicationDependencyTreeResolver setCollectCompileOnly(List return this; } + /** + * Whether to limit the resulting {@link io.quarkus.bootstrap.model.ApplicationModel} to the runtime dependencies. + * + * @param runtimeModelOnly whether to limit the resulting application model to the runtime dependencies + * @return self + */ public ApplicationDependencyTreeResolver setRuntimeModelOnly(boolean runtimeModelOnly) { this.runtimeModelOnly = runtimeModelOnly; return this; } + /** + * Whether an application model is resolved for dev mode + * + * @param devMode whether an application model is resolved for dev mode + * @return self + */ + public ApplicationDependencyTreeResolver setDevMode(boolean devMode) { + this.devMode = devMode; + return this; + } + public void resolve(CollectRequest collectRtDepsRequest) throws AppModelResolverException { this.managedDeps = collectRtDepsRequest.getManagedDependencies(); @@ -473,7 +488,7 @@ private void visitRuntimeDependency(DependencyNode node) { clearWalkingFlag(COLLECT_DIRECT_DEPS); if (extDep != null) { - extDep.info.ensureActivated(); + extDep.info.ensureActivated(appBuilder); visitExtensionDependency(extDep); } visitRuntimeDependencies(node.getChildren()); @@ -584,7 +599,7 @@ private ExtensionInfo getExtensionInfoOrNull(Artifact artifact, List boolean contains(T[] arr, T item) { + for (int i = 0; i < arr.length; ++i) { + if (item.equals(arr[i])) { + return true; + } + } + return false; + } + + private static String toCompactCoords(Artifact a) { + final StringBuilder b = new StringBuilder(); + b.append(a.getGroupId()).append(':').append(a.getArtifactId()).append(':'); + if (!a.getClassifier().isEmpty()) { + b.append(a.getClassifier()).append(':'); + } + if (!ArtifactCoords.TYPE_JAR.equals(a.getExtension())) { + b.append(a.getExtension()).append(':'); + } + b.append(a.getVersion()); + return b.toString(); + } +} diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/IncubatingApplicationModelResolver.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/IncubatingApplicationModelResolver.java index b569ce9c5d500c..7a44fecf8f5a16 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/IncubatingApplicationModelResolver.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/IncubatingApplicationModelResolver.java @@ -5,7 +5,6 @@ import static io.quarkus.bootstrap.util.DependencyUtils.getWinner; import static io.quarkus.bootstrap.util.DependencyUtils.hasWinner; import static io.quarkus.bootstrap.util.DependencyUtils.newDependencyBuilder; -import static io.quarkus.bootstrap.util.DependencyUtils.toArtifact; import java.io.BufferedReader; import java.io.IOException; @@ -51,10 +50,8 @@ import io.quarkus.bootstrap.BootstrapConstants; import io.quarkus.bootstrap.BootstrapDependencyProcessingException; import io.quarkus.bootstrap.model.ApplicationModelBuilder; -import io.quarkus.bootstrap.model.CapabilityContract; import io.quarkus.bootstrap.model.PlatformImportsImpl; import io.quarkus.bootstrap.resolver.AppModelResolverException; -import io.quarkus.bootstrap.util.BootstrapUtils; import io.quarkus.bootstrap.util.DependencyUtils; import io.quarkus.bootstrap.workspace.WorkspaceModule; import io.quarkus.maven.dependency.ArtifactCoords; @@ -140,6 +137,7 @@ public static IncubatingApplicationModelResolver newInstance() { private DependencyLoggingConfig depLogging; private List collectCompileOnly; private boolean runtimeModelOnly; + private boolean devMode; public IncubatingApplicationModelResolver setArtifactResolver(MavenArtifactResolver resolver) { this.resolver = resolver; @@ -173,11 +171,28 @@ public IncubatingApplicationModelResolver setCollectCompileOnly(List return this; } + /** + * Whether to limit the resulting {@link io.quarkus.bootstrap.model.ApplicationModel} to the runtime dependencies. + * + * @param runtimeModelOnly whether to limit the resulting application model to the runtime dependencies + * @return self + */ public IncubatingApplicationModelResolver setRuntimeModelOnly(boolean runtimeModelOnly) { this.runtimeModelOnly = runtimeModelOnly; return this; } + /** + * Whether an application model is resolved for dev mode + * + * @param devMode whether an application model is resolved for dev mode + * @return self + */ + public IncubatingApplicationModelResolver setDevMode(boolean devMode) { + this.devMode = devMode; + return this; + } + public void resolve(CollectRequest collectRtDepsRequest) throws AppModelResolverException { this.managedDeps = collectRtDepsRequest.getManagedDependencies(); // managed dependencies will be a bit augmented with every added extension, so let's load the properties early @@ -612,7 +627,7 @@ void setFlags(byte walkingFlags) { } parentExtDep = parentExtDep.parent; } - ext.info.ensureActivated(); + ext.info.ensureActivated(appBuilder); } var existingDep = appBuilder.getDependency(resolvedDep.getKey()); @@ -760,7 +775,7 @@ private ExtensionInfo getExtensionInfoOrNull(Artifact artifact, List depth = new ArrayList<>(); diff --git a/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java b/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java index 61fdffab18d13a..5a3f8cda0625b0 100644 --- a/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java +++ b/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/ExtensionDescriptorMojo.java @@ -227,6 +227,13 @@ public static class RemovedResources { @Parameter private List conditionalDependencies = new ArrayList<>(0); + /** + * Conditional dependencies that should be + * enabled in case an application is launched in dev mode and certain classpath conditions have been satisfied. + */ + @Parameter + private List conditionalDevDependencies = new ArrayList<>(0); + /** * Extension dependency condition that should be * satisfied for this extension to be enabled @@ -303,6 +310,16 @@ public void execute() throws MojoExecutionException { final Properties props = new Properties(); props.setProperty(BootstrapConstants.PROP_DEPLOYMENT_ARTIFACT, deployment); + if (!conditionalDevDependencies.isEmpty()) { + final StringBuilder buf = new StringBuilder(); + int i = 0; + buf.append(ArtifactCoords.fromString(conditionalDevDependencies.get(i++))); + while (i < conditionalDevDependencies.size()) { + buf.append(' ').append(ArtifactCoords.fromString(conditionalDevDependencies.get(i++))); + } + props.setProperty(BootstrapConstants.CONDITIONAL_DEV_DEPENDENCIES, buf.toString()); + } + if (!conditionalDependencies.isEmpty()) { final StringBuilder buf = new StringBuilder(); int i = 0;