Search in sources :

Example 21 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class MockArtifactResolver method resolve.

@Override
public ArtifactSpec resolve(ArtifactSpec spec) throws Exception {
    File resolved = resolvedArtifacts.get(spec);
    if (resolved == null) {
        Archive archive = artifacts.get(spec);
        if (archive != null) {
            resolved = File.createTempFile(spec.artifactId(), ".jar");
            resolved.delete();
            resolved.deleteOnExit();
            archive.as(ZipExporter.class).exportTo(resolved);
            this.resolvedArtifacts.put(spec, resolved);
        }
    }
    spec.file = resolved;
    return spec;
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) File(java.io.File)

Example 22 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class MockArtifactResolver method add.

public void add(ArtifactSpec spec) {
    Archive archive = ShrinkWrap.create(JavaArchive.class);
    archive.add(EmptyAsset.INSTANCE, "nothing");
    Entry entry = new Entry(spec);
    this.entries.put(spec, entry);
    this.artifacts.put(spec, archive);
}
Also used : Archive(org.jboss.shrinkwrap.api.Archive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive)

Example 23 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class BuildTool method repackageWar.

public void repackageWar(File file) throws IOException {
    this.log.info("Repackaging .war: " + file);
    Path backupPath = get(file);
    move(file, backupPath, this.log);
    Archive original = ShrinkWrap.create(JavaArchive.class);
    try (InputStream inputStream = Files.newInputStream(backupPath)) {
        original.as(ZipImporter.class).importFrom(inputStream);
    }
    WebInfLibFilteringArchive repackaged = new WebInfLibFilteringArchive(original, this.dependencyManager);
    repackaged.as(ZipExporter.class).exportTo(file, true);
    this.log.info("Repackaged .war: " + file);
}
Also used : Path(java.nio.file.Path) Archive(org.jboss.shrinkwrap.api.Archive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ZipExporter(org.jboss.shrinkwrap.api.exporter.ZipExporter) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter)

Example 24 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class ApimanManagerApiDeploymentTest method testApimanGatewayWAR.

@Test
public void testApimanGatewayWAR() throws Exception {
    File warFile = Maven.resolver().resolve("io.apiman:apiman-gateway-platforms-war-wildfly8-api:war:1.3.1.Final").withoutTransitivity().asSingleFile();
    WildFlyConfigBuilder cfgBuilder = new WildFlyConfigBuilder();
    cfgBuilder.addDefaultSources();
    Config cfg = cfgBuilder.build();
    Archive archive = ShrinkWrap.createFromZipFile(JAXRSArchive.class, warFile);
    OpenApiConfig config = new OpenApiConfig(cfg);
    OpenApiDocument.INSTANCE.reset();
    OpenApiDeploymentProcessor processor = new OpenApiDeploymentProcessor(config, archive);
    processor.process();
    new OpenApiServletContextListener().contextInitialized(null);
    String actual = OpenApiSerializer.serialize(OpenApiDocument.INSTANCE.get(), Format.JSON);
    String expected = loadResource(getClass().getResource("testApimanGatewayWAR.expected.json"));
    // System.out.println(actual);
    assertJsonEquals(expected, actual);
}
Also used : WildFlyConfigBuilder(org.wildfly.microprofile.config.WildFlyConfigBuilder) Archive(org.jboss.shrinkwrap.api.Archive) JAXRSArchive(org.wildfly.swarm.jaxrs.JAXRSArchive) OpenApiServletContextListener(org.wildfly.swarm.microprofile.openapi.deployment.OpenApiServletContextListener) OpenApiConfig(org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig) Config(org.eclipse.microprofile.config.Config) OpenApiConfig(org.wildfly.swarm.microprofile.openapi.api.OpenApiConfig) File(java.io.File) Test(org.junit.Test)

Example 25 with Archive

use of org.jboss.shrinkwrap.api.Archive in project wildfly-swarm by wildfly-swarm.

the class RuntimeDeployer method archives.

protected static Stream<Archive> archives(Collection<Path> paths) {
    return paths.stream().map(path -> {
        String simpleName = path.getFileName().toString();
        Archive archive = ShrinkWrap.create(JavaArchive.class, simpleName);
        archive.as(ZipImporter.class).importFrom(path.toFile());
        return archive;
    });
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) GenericArchive(org.jboss.shrinkwrap.api.GenericArchive) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Archive(org.jboss.shrinkwrap.api.Archive) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter)

Aggregations

Archive (org.jboss.shrinkwrap.api.Archive)37 Node (org.jboss.shrinkwrap.api.Node)17 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)12 Test (org.junit.Test)12 File (java.io.File)11 URL (java.net.URL)10 ArrayList (java.util.ArrayList)9 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)8 JolokiaFraction (org.wildfly.swarm.jolokia.JolokiaFraction)8 BufferedReader (java.io.BufferedReader)7 IOException (java.io.IOException)7 InputStreamReader (java.io.InputStreamReader)7 Map (java.util.Map)7 HashMap (java.util.HashMap)6 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)6 List (java.util.List)5 ZipImporter (org.jboss.shrinkwrap.api.importer.ZipImporter)5 DeploymentContext (org.wildfly.swarm.container.runtime.cdi.DeploymentContext)5 JARArchive (org.wildfly.swarm.spi.api.JARArchive)5 Path (java.nio.file.Path)4