Search in sources :

Example 1 with WildFlySwarmManifest

use of org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest in project wildfly-swarm by wildfly-swarm.

the class DependencyManagerTest method testAutodetectedSwarmJar.

@Test
public void testAutodetectedSwarmJar() throws Exception {
    // Explicitly asked-for dependencies are also the full resolved tree
    DeclaredDependencies declaredDependencies = new DeclaredDependencies();
    declaredDependencies.add(JAXRS_SPEC, SERVLET_SPEC);
    declaredDependencies.add(COMMON_DEP);
    declaredDependencies.add(JAXRS_FRACTION, JAXRS_SPEC);
    declaredDependencies.add(JAXRS_FRACTION, COMMON_DEP);
    declaredDependencies.add(JAXRS_FRACTION, UNDERTOW_FRACTION);
    declaredDependencies.add(JAXRS_SPEC, SERVLET_SPEC);
    manager.analyzeDependencies(true, declaredDependencies);
    assertThat(manager.getRemovableDependencies()).containsOnly(JAXRS_FRACTION, UNDERTOW_FRACTION);
    assertThat(manager.getDependencies()).containsOnly(JAXRS_FRACTION, UNDERTOW_FRACTION, JAXRS_SPEC, SERVLET_SPEC, COMMON_DEP);
    WildFlySwarmManifest manifest = manager.getWildFlySwarmManifest();
    assertThat(manifest.bootstrapArtifacts()).containsOnly(JAXRS_FRACTION.mavenGav(), UNDERTOW_FRACTION.mavenGav());
    assertThat(manifest.bootstrapModules()).containsOnly("org.wildfly.swarm.jaxrs", "org.wildfly.swarm.undertow");
    // still includes the jaxrs-spec because it was explicit and we just can't know
    assertThat(manifest.getDependencies()).containsOnly(SERVLET_SPEC.mavenGav(), JAXRS_SPEC.mavenGav(), COMMON_DEP.mavenGav());
}
Also used : WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest) Test(org.junit.Test)

Example 2 with WildFlySwarmManifest

use of org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest in project wildfly-swarm by wildfly-swarm.

the class DependencyManagerTest method testWithSwarmJarBeingOnlyUserOfDep.

@Test
public void testWithSwarmJarBeingOnlyUserOfDep() throws Exception {
    // Only :jaxrs is the explicit resolved tree, but brings in jaxrs-spec and common dep
    DeclaredDependencies declaredDependencies = new DeclaredDependencies();
    declaredDependencies.add(JAXRS_FRACTION, JAXRS_SPEC);
    declaredDependencies.add(JAXRS_FRACTION, COMMON_DEP);
    declaredDependencies.add(JAXRS_FRACTION, UNDERTOW_FRACTION);
    declaredDependencies.add(JAXRS_FRACTION, SERVLET_SPEC);
    manager.analyzeDependencies(false, declaredDependencies);
    assertThat(manager.getRemovableDependencies()).containsOnly(JAXRS_FRACTION, JAXRS_SPEC, UNDERTOW_FRACTION, SERVLET_SPEC, COMMON_DEP);
    assertThat(manager.getDependencies()).containsOnly(JAXRS_FRACTION, JAXRS_SPEC, UNDERTOW_FRACTION, SERVLET_SPEC, COMMON_DEP);
    WildFlySwarmManifest manifest = manager.getWildFlySwarmManifest();
    assertThat(manifest.bootstrapArtifacts()).containsOnly(JAXRS_FRACTION.mavenGav(), UNDERTOW_FRACTION.mavenGav());
    assertThat(manifest.bootstrapModules()).containsOnly("org.wildfly.swarm.jaxrs", "org.wildfly.swarm.undertow");
    assertThat(manifest.getDependencies()).isEmpty();
}
Also used : WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest) Test(org.junit.Test)

Example 3 with WildFlySwarmManifest

use of org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest in project wildfly-swarm by wildfly-swarm.

the class DependencyManagerTest method testAutodetectedSwarmJarNoExplicitCommon.

@Test
public void testAutodetectedSwarmJarNoExplicitCommon() throws Exception {
    // Explicitly asked-for dependencies are also the full resolved tree
    DeclaredDependencies declaredDependencies = new DeclaredDependencies();
    declaredDependencies.add(JAXRS_SPEC, SERVLET_SPEC);
    declaredDependencies.add(JAXRS_FRACTION, JAXRS_SPEC);
    declaredDependencies.add(JAXRS_FRACTION, COMMON_DEP);
    declaredDependencies.add(JAXRS_FRACTION, UNDERTOW_FRACTION);
    declaredDependencies.add(JAXRS_SPEC, SERVLET_SPEC);
    manager.analyzeDependencies(true, declaredDependencies);
    assertThat(manager.getRemovableDependencies()).containsOnly(JAXRS_FRACTION, UNDERTOW_FRACTION, COMMON_DEP);
    assertThat(manager.getDependencies()).containsOnly(JAXRS_FRACTION, UNDERTOW_FRACTION, SERVLET_SPEC, JAXRS_SPEC, COMMON_DEP);
    WildFlySwarmManifest manifest = manager.getWildFlySwarmManifest();
    assertThat(manifest.bootstrapArtifacts()).containsOnly(JAXRS_FRACTION.mavenGav(), UNDERTOW_FRACTION.mavenGav());
    assertThat(manifest.bootstrapModules()).containsOnly("org.wildfly.swarm.jaxrs", "org.wildfly.swarm.undertow");
    // still includes the jaxrs-spec because it was explicit and we just can't know
    assertThat(manifest.getDependencies()).containsOnly(JAXRS_SPEC.mavenGav(), SERVLET_SPEC.mavenGav());
}
Also used : WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest) Test(org.junit.Test)

Example 4 with WildFlySwarmManifest

use of org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest in project wildfly-swarm by wildfly-swarm.

the class DependencyManagerTest method testNoSwarmJars.

@Test
public void testNoSwarmJars() throws Exception {
    // Explicitly asked-for dependencies are also the full resolved tree
    DeclaredDependencies declaredDependencies = new DeclaredDependencies();
    declaredDependencies.add(JAXRS_SPEC, SERVLET_SPEC);
    declaredDependencies.add(COMMON_DEP);
    manager.analyzeDependencies(false, declaredDependencies);
    assertThat(manager.getRemovableDependencies()).isEmpty();
    assertThat(manager.getDependencies()).containsOnly(JAXRS_SPEC, SERVLET_SPEC, COMMON_DEP);
    WildFlySwarmManifest manifest = manager.getWildFlySwarmManifest();
    // these are empty because we have not actually done any auto-detection.
    assertThat(manifest.bootstrapArtifacts()).isEmpty();
    assertThat(manifest.bootstrapModules()).isEmpty();
    assertThat(manifest.getDependencies()).containsOnly(SERVLET_SPEC.mavenGav(), JAXRS_SPEC.mavenGav(), COMMON_DEP.mavenGav());
}
Also used : WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest) Test(org.junit.Test)

Example 5 with WildFlySwarmManifest

use of org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest in project wildfly-swarm by wildfly-swarm.

the class BuildTool method addWildFlySwarmApplicationManifest.

private void addWildFlySwarmApplicationManifest() {
    WildFlySwarmManifest manifest = this.dependencyManager.getWildFlySwarmManifest();
    this.properties.put("swarm.uberjar.build.user", System.getProperty("user.name"));
    if (!this.hollow) {
        this.properties.put(BootstrapProperties.APP_ARTIFACT, this.projectAsset.getSimpleName());
    }
    manifest.setProperties(this.properties);
    manifest.bundleDependencies(this.bundleDependencies);
    manifest.setMainClass(this.mainClass);
    manifest.setHollow(this.hollow);
    this.archive.add(new ByteArrayAsset(manifest.toString().getBytes(StandardCharsets.UTF_8)), WildFlySwarmManifest.CLASSPATH_LOCATION);
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest)

Aggregations

WildFlySwarmManifest (org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest)7 Test (org.junit.Test)5 ByteArrayAsset (org.jboss.shrinkwrap.api.asset.ByteArrayAsset)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Properties (java.util.Properties)1 Attributes (java.util.jar.Attributes)1 JarFile (java.util.jar.JarFile)1 Manifest (java.util.jar.Manifest)1 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)1 ZipImporter (org.jboss.shrinkwrap.api.importer.ZipImporter)1 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)1 BootstrapProperties (org.wildfly.swarm.bootstrap.util.BootstrapProperties)1