use of io.quarkus.maven.dependency.ArtifactDependency in project quarkus by quarkusio.
the class CollectDependenciesBase method addCollectedDep.
protected void addCollectedDep(final TsArtifact artifact, final String scope, boolean optional, int... flags) {
int allFlags = DependencyFlags.RUNTIME_CP | DependencyFlags.DEPLOYMENT_CP;
if (optional) {
allFlags |= DependencyFlags.OPTIONAL;
}
for (int f : flags) {
allFlags |= f;
}
if (expectedResult.isEmpty()) {
expectedResult = new ArrayList<>();
}
expectedResult.add(new ArtifactDependency(artifact.toArtifact(), scope, allFlags));
}
use of io.quarkus.maven.dependency.ArtifactDependency in project quarkus by quarkusio.
the class ConditionalDependencyScenarioTwoTest method assertAppModel.
@Override
protected void assertAppModel(ApplicationModel appModel) throws Exception {
final Set<Dependency> deploymentDeps = appModel.getDependencies().stream().filter(d -> d.isDeploymentCp() && !d.isRuntimeCp()).map(d -> new ArtifactDependency(d)).collect(Collectors.toSet());
final Set<Dependency> expected = new HashSet<>();
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-f-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-g-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-h-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-k-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-l-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-j-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-m-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-n-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-i-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-o-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-p-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-r-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-s-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-t-deployment", TsArtifact.DEFAULT_VERSION), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV(TsArtifact.DEFAULT_GROUP_ID, "ext-u-deployment", TsArtifact.DEFAULT_VERSION), "runtime", DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, new HashSet<>(deploymentDeps));
}
use of io.quarkus.maven.dependency.ArtifactDependency in project quarkus by quarkusio.
the class PackageAppTestBase method testBootstrap.
@Override
protected void testBootstrap(QuarkusBootstrap creator) throws Exception {
System.setProperty("quarkus.package.type", "legacy-jar");
try {
CuratedApplication curated = creator.bootstrap();
assertAppModel(curated.getApplicationModel());
final String[] expectedExtensions = expectedExtensionDependencies();
if (expectedExtensions != null) {
assertExtensionDependencies(curated.getApplicationModel(), expectedExtensions);
}
assertDeploymentDeps(curated.getApplicationModel().getDependencies().stream().filter(d -> d.isDeploymentCp() && !d.isRuntimeCp()).map(d -> new ArtifactDependency(d)).collect(Collectors.toSet()));
AugmentAction action = curated.createAugmentor();
AugmentResult outcome = action.createProductionApplication();
final Path libDir = outcome.getJar().getLibraryDir();
assertTrue(Files.isDirectory(libDir));
final Set<String> actualLib = new HashSet<>();
try (Stream<Path> stream = Files.list(libDir)) {
final Iterator<Path> i = stream.iterator();
while (i.hasNext()) {
actualLib.add(i.next().getFileName().toString());
}
}
final Path runnerJar = outcome.getJar().getPath();
assertTrue(Files.exists(runnerJar));
try (JarFile jar = new JarFile(runnerJar.toFile())) {
final Attributes mainAttrs = jar.getManifest().getMainAttributes();
// assert the main class
assertEquals(MAIN_CLS, mainAttrs.getValue("Main-Class"));
// assert the Class-Path contains all the entries in the lib dir
final String cp = mainAttrs.getValue("Class-Path");
assertNotNull(cp);
String[] cpEntries = Arrays.stream(cp.trim().split("\\s+")).filter(s -> !s.trim().isEmpty()).toArray(String[]::new);
assertEquals(actualLib.size(), cpEntries.length);
for (String entry : cpEntries) {
assertTrue(entry.startsWith(LIB_PREFIX));
assertTrue(actualLib.contains(entry.substring(LIB_PREFIX.length())));
}
}
List<String> missingEntries = Collections.emptyList();
for (String entry : expectedLib) {
if (!actualLib.remove(entry)) {
if (missingEntries.isEmpty()) {
missingEntries = new ArrayList<>();
}
missingEntries.add(entry);
}
}
StringBuilder buf = null;
if (!missingEntries.isEmpty()) {
buf = new StringBuilder();
buf.append("Missing entries: ").append(missingEntries.get(0));
for (int i = 1; i < missingEntries.size(); ++i) {
buf.append(", ").append(missingEntries.get(i));
}
}
if (!actualLib.isEmpty()) {
if (buf == null) {
buf = new StringBuilder();
} else {
buf.append("; ");
}
final Iterator<String> i = actualLib.iterator();
buf.append("Extra entries: ").append(i.next());
while (i.hasNext()) {
buf.append(", ").append(i.next());
}
}
if (buf != null) {
fail(buf.toString());
}
} finally {
System.clearProperty("quarkus.package.type");
}
}
use of io.quarkus.maven.dependency.ArtifactDependency in project quarkus by quarkusio.
the class ProvidedExtensionDepsTest method assertDeploymentDeps.
@Override
protected void assertDeploymentDeps(Set<Dependency> deploymentDeps) throws Exception {
final Set<Dependency> expected = new HashSet<>();
expected.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a-deployment", "1"), "compile", DependencyFlags.DEPLOYMENT_CP));
expected.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a-deployment-dep", "1"), "compile", DependencyFlags.DEPLOYMENT_CP));
assertEquals(expected, deploymentDeps);
}
use of io.quarkus.maven.dependency.ArtifactDependency in project quarkus by quarkusio.
the class ExcludeLibDepsTest method assertAppModel.
@Override
protected void assertAppModel(ApplicationModel appModel) throws Exception {
final Set<Dependency> expectedDeployDeps = new HashSet<>();
expectedDeployDeps.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a-deployment", "1"), "compile", DependencyFlags.DEPLOYMENT_CP));
assertEquals(expectedDeployDeps, appModel.getDependencies().stream().filter(d -> d.isDeploymentCp() && !d.isRuntimeCp()).map(d -> new ArtifactDependency(d)).collect(Collectors.toSet()));
final Set<Dependency> expectedRuntimeDeps = new HashSet<>();
expectedRuntimeDeps.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a", "1"), "compile", DependencyFlags.DIRECT, DependencyFlags.RUNTIME_EXTENSION_ARTIFACT, DependencyFlags.RUNTIME_CP, DependencyFlags.DEPLOYMENT_CP, DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT));
expectedRuntimeDeps.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a-dep-1", "1"), "compile", DependencyFlags.RUNTIME_CP, DependencyFlags.DEPLOYMENT_CP));
expectedRuntimeDeps.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a-dep-2", "1"), "compile", DependencyFlags.RUNTIME_CP, DependencyFlags.DEPLOYMENT_CP));
expectedRuntimeDeps.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a-dep-trans-1", "1"), "compile", DependencyFlags.RUNTIME_CP, DependencyFlags.DEPLOYMENT_CP));
expectedRuntimeDeps.add(new ArtifactDependency(new GACTV("io.quarkus.bootstrap.test", "ext-a-dep-trans-2", "1"), "compile", DependencyFlags.RUNTIME_CP, DependencyFlags.DEPLOYMENT_CP));
assertEquals(expectedRuntimeDeps, appModel.getRuntimeDependencies().stream().map(d -> new ArtifactDependency(d)).collect(Collectors.toSet()));
final Set<Dependency> expectedFullDeps = new HashSet<>();
expectedFullDeps.addAll(expectedDeployDeps);
expectedFullDeps.addAll(expectedRuntimeDeps);
assertEquals(expectedFullDeps, appModel.getDependencies().stream().map(d -> new ArtifactDependency(d)).collect(Collectors.toSet()));
}
Aggregations