Skip to content

Commit

Permalink
Support conditional dependencies on regular artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Loubyansky committed Nov 25, 2024
1 parent 87e1d39 commit 24d3ec1
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public TsQuarkusExt setConditionalDeps(TsQuarkusExt... exts) {
return setDescriptorProp(BootstrapConstants.CONDITIONAL_DEPENDENCIES, buf.toString());
}

public TsQuarkusExt setConditionalDevDeps(TsQuarkusExt... exts) {
public TsQuarkusExt setConditionalDevDeps(TsArtifact... artifacts) {
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());
buf.append(artifacts[i++]);
while (i < artifacts.length) {
buf.append(' ').append(artifacts[i++]);
}
return setDescriptorProp(BootstrapConstants.CONDITIONAL_DEV_DEPENDENCIES, buf.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ConditionalDependenciesDevModelTestCase extends CollectDependencies
@Override
protected BootstrapAppModelResolver newAppModelResolver(LocalProject currentProject) throws Exception {
var resolver = super.newAppModelResolver(currentProject);
//resolver.setIncubatingModelResolver(false);
//resolver.setIncubatingModelResolver(true);
return resolver;
}

Expand Down Expand Up @@ -76,8 +76,20 @@ protected void setupDependencies() {
| DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT);
addCollectedDeploymentDep(extF.getDeployment());

final TsQuarkusExt extH = new TsQuarkusExt("ext-h");
install(extH, false);
addCollectedDep(extH.getRuntime(),
DependencyFlags.RUNTIME_CP
| DependencyFlags.DEPLOYMENT_CP
| DependencyFlags.RUNTIME_EXTENSION_ARTIFACT);
addCollectedDeploymentDep(extH.getDeployment());
final TsArtifact devOnlyLib = TsArtifact.jar("dev-only-lib");
devOnlyLib.addDependency(extH);
install(devOnlyLib, false);
addCollectedDep(devOnlyLib, DependencyFlags.RUNTIME_CP | DependencyFlags.DEPLOYMENT_CP);

final TsQuarkusExt extG = new TsQuarkusExt("ext-g");
extG.setConditionalDevDeps(extB);
extG.setConditionalDevDeps(extB.getRuntime(), devOnlyLib);
install(extG, false);
installAsDep(extG.getRuntime(),
DependencyFlags.DIRECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected void setupDependencies() {
addCollectedDeploymentDep(extF.getDeployment());

final TsQuarkusExt extG = new TsQuarkusExt("ext-g");
extG.setConditionalDevDeps(extB);
extG.setConditionalDevDeps(extB.getRuntime());
install(extG, false);
installAsDep(extG.getRuntime(),
DependencyFlags.DIRECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected void setupDependencies() {
install(extE, false);

final TsQuarkusExt extG = new TsQuarkusExt("ext-g");
extG.setConditionalDevDeps(extB, extC, extE);
extG.setConditionalDevDeps(extB.getRuntime(), extC.getRuntime(), extE.getRuntime());
install(extG, false);
installAsDep(extG.getRuntime(),
DependencyFlags.DIRECT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.quarkus.bootstrap.resolver.test;

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 RequiredConditionalDependencyTest 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");
installAsDep(extA);
final TsQuarkusExt extB = new TsQuarkusExt("ext-b");
extB.setDependencyCondition(extA);
install(extB, false);
addCollectedDep(extB.getRuntime(),
DependencyFlags.RUNTIME_CP
| DependencyFlags.DEPLOYMENT_CP
| DependencyFlags.RUNTIME_EXTENSION_ARTIFACT);
addCollectedDeploymentDep(extB.getDeployment());
final TsQuarkusExt extC = new TsQuarkusExt("ext-c");
extC.setConditionalDeps(extB);
install(extC, false);
addCollectedDep(extC.getRuntime(),
DependencyFlags.RUNTIME_CP
| DependencyFlags.DEPLOYMENT_CP
| DependencyFlags.RUNTIME_EXTENSION_ARTIFACT);
addCollectedDeploymentDep(extC.getDeployment());
final TsQuarkusExt extD = new TsQuarkusExt("ext-d");
extD.addDependency(extC);
install(extD, false);
addCollectedDep(extD.getRuntime(),
DependencyFlags.RUNTIME_CP
| DependencyFlags.DEPLOYMENT_CP
| DependencyFlags.RUNTIME_EXTENSION_ARTIFACT);
addCollectedDeploymentDep(extD.getDeployment());
final TsQuarkusExt extE = new TsQuarkusExt("ext-e");
extE.addDependency(extD);
extE.setDependencyCondition(extA);
install(extE, false);
addCollectedDep(extE.getRuntime(),
DependencyFlags.RUNTIME_CP
| DependencyFlags.DEPLOYMENT_CP
| DependencyFlags.RUNTIME_EXTENSION_ARTIFACT);
addCollectedDeploymentDep(extE.getDeployment());
final TsQuarkusExt extF = new TsQuarkusExt("ext-f");
extF.setConditionalDeps(extE);
installAsDep(extF);
}
}
Loading

0 comments on commit 24d3ec1

Please sign in to comment.