Search in sources :

Example 6 with WildFlySwarmManifest

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

the class DependencyManagerTest method testWithApplicationAlsoUsingDep.

@Test
public void testWithApplicationAlsoUsingDep() throws Exception {
    // :jaxrs and common dep are explicit, implying application needs common
    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);
    declaredDependencies.add(COMMON_DEP);
    manager.analyzeDependencies(false, declaredDependencies);
    assertThat(manager.getRemovableDependencies()).containsOnly(JAXRS_FRACTION, JAXRS_SPEC, UNDERTOW_FRACTION, SERVLET_SPEC);
    assertThat(manager.getDependencies()).containsOnly(JAXRS_FRACTION, JAXRS_SPEC, COMMON_DEP, UNDERTOW_FRACTION, SERVLET_SPEC);
    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()).containsOnly(COMMON_DEP.mavenGav());
}
Also used : WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest) Test(org.junit.Test)

Example 7 with WildFlySwarmManifest

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

the class AbstractBootstrapIntegrationTestCase method createBootstrapArchive.

protected JavaArchive createBootstrapArchive(String mainClassName, String appArtifact) throws IOException {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class);
    archive.as(ZipImporter.class).importFrom(new JarFile(findBootstrapJar()));
    Properties props = new Properties();
    if (appArtifact != null) {
        props.put(BootstrapProperties.APP_ARTIFACT, appArtifact);
    }
    ByteArrayOutputStream propsOut = new ByteArrayOutputStream();
    props.store(propsOut, "");
    propsOut.close();
    archive.addAsManifestResource(new ByteArrayAsset(propsOut.toByteArray()), "wildfly-swarm.properties");
    if (appArtifact != null) {
        WildFlySwarmManifest manifest = new WildFlySwarmManifest();
        manifest.setAsset(appArtifact);
        archive.add(new StringAsset(manifest.toString()), WildFlySwarmManifest.CLASSPATH_LOCATION);
    }
    if (mainClassName != null) {
        Manifest manifest = new Manifest();
        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
        manifest.getMainAttributes().put(new Attributes.Name("Wildfly-Swarm-Main-Class"), mainClassName);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        manifest.write(out);
        out.close();
        archive.addAsManifestResource(new ByteArrayAsset(out.toByteArray()), "MANIFEST.MF");
    }
    return archive;
}
Also used : StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter) Attributes(java.util.jar.Attributes) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JarFile(java.util.jar.JarFile) Properties(java.util.Properties) BootstrapProperties(org.wildfly.swarm.bootstrap.util.BootstrapProperties) Manifest(java.util.jar.Manifest) WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) 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