Search in sources :

Example 1 with ArtifactDependency

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));
}
Also used : ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency)

Example 2 with ArtifactDependency

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));
}
Also used : HashSet(java.util.HashSet) DependencyFlags(io.quarkus.maven.dependency.DependencyFlags) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) TsQuarkusExt(io.quarkus.bootstrap.resolver.TsQuarkusExt) Set(java.util.Set) BootstrapFromOriginalJarTestBase(io.quarkus.deployment.runnerjar.BootstrapFromOriginalJarTestBase) Dependency(io.quarkus.maven.dependency.Dependency) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TsArtifact(io.quarkus.bootstrap.resolver.TsArtifact) Collectors(java.util.stream.Collectors) GACTV(io.quarkus.maven.dependency.GACTV) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) Dependency(io.quarkus.maven.dependency.Dependency) GACTV(io.quarkus.maven.dependency.GACTV) HashSet(java.util.HashSet)

Example 3 with ArtifactDependency

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");
    }
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) CuratedApplication(io.quarkus.bootstrap.app.CuratedApplication) Arrays(java.util.Arrays) TsDependency(io.quarkus.bootstrap.resolver.TsDependency) JarFile(java.util.jar.JarFile) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) AugmentAction(io.quarkus.bootstrap.app.AugmentAction) Dependency(io.quarkus.maven.dependency.Dependency) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Path(java.nio.file.Path) OutputStream(java.io.OutputStream) AugmentResult(io.quarkus.bootstrap.app.AugmentResult) Properties(java.util.Properties) Iterator(java.util.Iterator) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) Collection(java.util.Collection) Set(java.util.Set) BootstrapConstants(io.quarkus.bootstrap.BootstrapConstants) IOException(java.io.IOException) ContentProvider(io.quarkus.bootstrap.resolver.TsArtifact.ContentProvider) TsArtifact(io.quarkus.bootstrap.resolver.TsArtifact) BootstrapTestBase(io.quarkus.bootstrap.resolver.BootstrapTestBase) Attributes(java.util.jar.Attributes) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) QuarkusBootstrap(io.quarkus.bootstrap.app.QuarkusBootstrap) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) Collections(java.util.Collections) Path(java.nio.file.Path) AugmentAction(io.quarkus.bootstrap.app.AugmentAction) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) Attributes(java.util.jar.Attributes) AugmentResult(io.quarkus.bootstrap.app.AugmentResult) JarFile(java.util.jar.JarFile) CuratedApplication(io.quarkus.bootstrap.app.CuratedApplication) HashSet(java.util.HashSet)

Example 4 with ArtifactDependency

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);
}
Also used : ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) TsDependency(io.quarkus.bootstrap.resolver.TsDependency) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) Dependency(io.quarkus.maven.dependency.Dependency) GACTV(io.quarkus.maven.dependency.GACTV) HashSet(java.util.HashSet)

Example 5 with ArtifactDependency

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()));
}
Also used : HashSet(java.util.HashSet) DependencyFlags(io.quarkus.maven.dependency.DependencyFlags) TsDependency(io.quarkus.bootstrap.resolver.TsDependency) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) TsQuarkusExt(io.quarkus.bootstrap.resolver.TsQuarkusExt) Set(java.util.Set) Dependency(io.quarkus.maven.dependency.Dependency) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TsArtifact(io.quarkus.bootstrap.resolver.TsArtifact) Collectors(java.util.stream.Collectors) GACTV(io.quarkus.maven.dependency.GACTV) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) TsDependency(io.quarkus.bootstrap.resolver.TsDependency) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) Dependency(io.quarkus.maven.dependency.Dependency) GACTV(io.quarkus.maven.dependency.GACTV) HashSet(java.util.HashSet)

Aggregations

ArtifactDependency (io.quarkus.maven.dependency.ArtifactDependency)15 Dependency (io.quarkus.maven.dependency.Dependency)13 GACTV (io.quarkus.maven.dependency.GACTV)12 HashSet (java.util.HashSet)11 TsDependency (io.quarkus.bootstrap.resolver.TsDependency)6 Collectors (java.util.stream.Collectors)6 ApplicationModel (io.quarkus.bootstrap.model.ApplicationModel)5 TsArtifact (io.quarkus.bootstrap.resolver.TsArtifact)5 TsQuarkusExt (io.quarkus.bootstrap.resolver.TsQuarkusExt)4 DependencyFlags (io.quarkus.maven.dependency.DependencyFlags)4 Set (java.util.Set)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 CuratedApplication (io.quarkus.bootstrap.app.CuratedApplication)3 QuarkusBootstrap (io.quarkus.bootstrap.app.QuarkusBootstrap)3 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 BootstrapMavenContext (io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext)2 MavenArtifactResolver (io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver)2 BootstrapFromOriginalJarTestBase (io.quarkus.deployment.runnerjar.BootstrapFromOriginalJarTestBase)2 ArtifactCoords (io.quarkus.maven.dependency.ArtifactCoords)2