Skip to content

Commit

Permalink
Merge pull request #15736 from aloubyansky/conditional-extension-deps
Browse files Browse the repository at this point in the history
Conditional extension dependencies support for Maven-based projects
  • Loading branch information
aloubyansky authored Mar 18, 2021
2 parents 5aea757 + af0c4fb commit 0f83aca
Show file tree
Hide file tree
Showing 55 changed files with 3,032 additions and 251 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package io.quarkus.deployment.conditionaldeps;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import io.quarkus.bootstrap.model.AppArtifact;
import io.quarkus.bootstrap.model.AppDependency;
import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.deployment.runnerjar.ExecutableOutputOutcomeTestBase;

public class CascadingConditionalDependenciesTest extends ExecutableOutputOutcomeTestBase {

@Override
protected TsArtifact modelApp() {

final TsQuarkusExt extA = new TsQuarkusExt("ext-a");
final TsQuarkusExt extB = new TsQuarkusExt("ext-b");
final TsQuarkusExt extC = new TsQuarkusExt("ext-c");
final TsQuarkusExt extD = new TsQuarkusExt("ext-d");
final TsQuarkusExt extE = new TsQuarkusExt("ext-e");
final TsQuarkusExt extF = new TsQuarkusExt("ext-f");
final TsQuarkusExt extG = new TsQuarkusExt("ext-g");
final TsQuarkusExt extH = new TsQuarkusExt("ext-h");

extA.setConditionalDeps(extB, extF);

extB.setDependencyCondition(extC);
extB.setConditionalDeps(extD);

extD.setDependencyCondition(extE);

extE.addDependency(extC);
extE.setDependencyCondition(extA);
extE.setDependencyCondition(extG);

extF.setDependencyCondition(extD);

extG.setDependencyCondition(extH);

addToExpectedLib(extA.getRuntime());
addToExpectedLib(extB.getRuntime());
addToExpectedLib(extC.getRuntime());
addToExpectedLib(extD.getRuntime());
addToExpectedLib(extE.getRuntime());
addToExpectedLib(extF.getRuntime());

install(extA);
install(extB);
install(extC);
install(extD);
install(extE);
install(extF);
install(extG);
install(extH);

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

@Override
protected void assertDeploymentDeps(List<AppDependency> deploymentDeps) throws Exception {
final Set<AppDependency> expected = new HashSet<>();
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), "runtime"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-d-deployment", TsArtifact.DEFAULT_VERSION), "runtime"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-e-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-f-deployment", TsArtifact.DEFAULT_VERSION), "runtime"));
assertEquals(expected, new HashSet<>(deploymentDeps));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.quarkus.deployment.conditionaldeps;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import io.quarkus.bootstrap.model.AppArtifact;
import io.quarkus.bootstrap.model.AppDependency;
import io.quarkus.bootstrap.model.AppModel;
import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.deployment.runnerjar.ExecutableOutputOutcomeTestBase;

public class ConditionalDependencyWithSingleConditionTest extends ExecutableOutputOutcomeTestBase {

@Override
protected TsArtifact modelApp() {

final TsQuarkusExt extA = new TsQuarkusExt("ext-a");

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

final TsQuarkusExt extC = new TsQuarkusExt("ext-c");
extC.setConditionalDeps(extB);

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

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

@Override
protected void assertAppModel(AppModel appModel) throws Exception {
final List<AppDependency> deploymentDeps = appModel.getDeploymentDependencies();
final Set<AppDependency> expected = new HashSet<>();
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), "runtime"));
assertEquals(expected, new HashSet<>(deploymentDeps));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.quarkus.deployment.conditionaldeps;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import io.quarkus.bootstrap.model.AppArtifact;
import io.quarkus.bootstrap.model.AppDependency;
import io.quarkus.bootstrap.resolver.TsArtifact;
import io.quarkus.bootstrap.resolver.TsQuarkusExt;
import io.quarkus.deployment.runnerjar.ExecutableOutputOutcomeTestBase;

public class ConditionalDependencyWithTwoConditionsTest extends ExecutableOutputOutcomeTestBase {

@Override
protected TsArtifact modelApp() {

final TsQuarkusExt extA = new TsQuarkusExt("ext-a");
final TsQuarkusExt extD = new TsQuarkusExt("ext-d");

final TsQuarkusExt extB = new TsQuarkusExt("ext-b");
extB.setDependencyCondition(extA, extD);
install(extB);

final TsQuarkusExt extC = new TsQuarkusExt("ext-c");
extC.setConditionalDeps(extB);

addToExpectedLib(extA.getRuntime());
addToExpectedLib(extB.getRuntime());
addToExpectedLib(extC.getRuntime());
addToExpectedLib(extD.getRuntime());

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

@Override
protected void assertDeploymentDeps(List<AppDependency> deploymentDeps) throws Exception {
final Set<AppDependency> expected = new HashSet<>();
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-c-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-a-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-b-deployment", TsArtifact.DEFAULT_VERSION), "runtime"));
expected.add(new AppDependency(
new AppArtifact(TsArtifact.DEFAULT_GROUP_ID, "ext-d-deployment", TsArtifact.DEFAULT_VERSION), "compile"));
assertEquals(expected, new HashSet<>(deploymentDeps));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.quarkus.deployment.conditionaldeps;

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

public class DependencyConditionMatchesConditionalDependencyTest extends ExecutableOutputOutcomeTestBase {

@Override
protected TsArtifact modelApp() {

final TsQuarkusExt extA = new TsQuarkusExt("ext-a");

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

final TsQuarkusExt extD = new TsQuarkusExt("ext-d");
extD.setDependencyCondition(extB);
extD.setConditionalDeps(extB);

final TsQuarkusExt extC = new TsQuarkusExt("ext-c");
extC.setConditionalDeps(extD);

install(extA);
install(extB);
install(extC);
install(extD);

addToExpectedLib(extA.getRuntime());
addToExpectedLib(extB.getRuntime());
addToExpectedLib(extC.getRuntime());
addToExpectedLib(extD.getRuntime());

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

@Override
protected String[] expectedExtensionDependencies() {
return new String[] {
"ext-a",
"ext-b",
"ext-c",
"ext-d"
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.quarkus.deployment.conditionaldeps;

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

public class ExcludedDirectConditionalDependencyTest extends ExecutableOutputOutcomeTestBase {

@Override
protected TsArtifact modelApp() {

final TsQuarkusExt extA = new TsQuarkusExt("ext-a");

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

final TsQuarkusExt extD = new TsQuarkusExt("ext-d");

final TsQuarkusExt extE = new TsQuarkusExt("ext-e");
extE.setDependencyCondition(extD);
install(extE);

final TsQuarkusExt extC = new TsQuarkusExt("ext-c");
extC.setConditionalDeps(extB, extE);

addToExpectedLib(extA.getRuntime());
addToExpectedLib(extC.getRuntime());
addToExpectedLib(extD.getRuntime());
addToExpectedLib(extE.getRuntime());

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

@Override
protected String[] expectedExtensionDependencies() {
return new String[] {
"ext-a",
"ext-c",
"ext-d",
"ext-e"
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.quarkus.deployment.conditionaldeps;

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

public class ExcludedTransitiveConditionalDependencyTest extends ExecutableOutputOutcomeTestBase {

@Override
protected TsArtifact modelApp() {

final TsQuarkusExt extA = new TsQuarkusExt("ext-a");

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

final TsQuarkusExt extC = new TsQuarkusExt("ext-c");
extC.setConditionalDeps(extB);

final TsQuarkusExt extD = new TsQuarkusExt("ext-d");
extD.addDependency(extC);

addToExpectedLib(extA.getRuntime());
addToExpectedLib(extC.getRuntime());
addToExpectedLib(extD.getRuntime());

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

@Override
protected String[] expectedExtensionDependencies() {
return new String[] {
"ext-a",
"ext-c",
"ext-d"
};
}
}
Loading

0 comments on commit 0f83aca

Please sign in to comment.