Skip to content

Commit

Permalink
Check whether a conditional dependency has already been activated bef…
Browse files Browse the repository at this point in the history
…ore scheduling it for processing
aloubyansky committed Oct 16, 2023
1 parent db14e26 commit 1b1db00
Showing 2 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkus.deployment.conditionaldeps;

import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.deployment.runnerjar.BootstrapFromOriginalJarTestBase;

public class ConditionalDependencyDependingOnItsDependentTest extends BootstrapFromOriginalJarTestBase {

@Override
protected TsArtifact composeApplication() {

final TsQuarkusExt extGConditional = new TsQuarkusExt("ext-g-conditional");

final TsQuarkusExt extA = new TsQuarkusExt("ext-a");
extA.setConditionalDeps(extGConditional);
extGConditional.addDependency(extA);

final TsQuarkusExt extB = new TsQuarkusExt("ext-b");
extGConditional.setDependencyCondition(extB);

addToExpectedLib(extA.getRuntime());
addToExpectedLib(extB.getRuntime());
addToExpectedLib(extGConditional.getRuntime());

install(extA);
install(extB);
install(extGConditional);

return TsArtifact.jar("app")
.addManagedDependency(platformDescriptor())
.addManagedDependency(platformProperties())
.addDependency(extA)
.addDependency(extB);
}

@Override
protected String[] expectedExtensionDependencies() {
return new String[] {
"ext-a",
"ext-b",
"ext-g-conditional"
};
}
}
Original file line number Diff line number Diff line change
@@ -332,8 +332,8 @@ private void visitRuntimeDependency(DependencyNode node) {
final byte prevWalkingFlags = walkingFlags;
final ExtensionDependency prevLastVisitedRtExtNode = lastVisitedRuntimeExtNode;

final boolean popExclusions;
if (popExclusions = !node.getDependency().getExclusions().isEmpty()) {
final boolean popExclusions = !node.getDependency().getExclusions().isEmpty();
if (popExclusions) {
exclusionStack.addLast(node.getDependency().getExclusions());
}

@@ -448,10 +448,18 @@ private void collectConditionalDependencies(ExtensionDependency dependent)
final DependencySelector selector = dependent.exclusions == null ? null
: new ExclusionDependencySelector(dependent.exclusions);
for (Artifact conditionalArtifact : dependent.info.conditionalDeps) {
if (selector != null && !selector.selectDependency(new Dependency(conditionalArtifact, "runtime"))) {
if (selector != null && !selector.selectDependency(new Dependency(conditionalArtifact, JavaScopes.RUNTIME))) {
continue;
}
final ExtensionInfo conditionalInfo = getExtensionInfoOrNull(conditionalArtifact);
if (conditionalInfo == null) {
log.warn(dependent.info.runtimeArtifact + " declares a conditional dependency on " + conditionalArtifact
+ " that is not a Quarkus extension and will be ignored");
continue;
}
if (conditionalInfo.activated) {
continue;
}
final ConditionalDependency conditionalDep = new ConditionalDependency(conditionalInfo, dependent);
conditionalDepsToProcess.add(conditionalDep);
collectConditionalDependencies(conditionalDep.getExtensionDependency());

0 comments on commit 1b1db00

Please sign in to comment.