org.jboss.shrinkwrap.api.Filters Java Examples

The following examples show how to use org.jboss.shrinkwrap.api.Filters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Deployments.java    From javaee7-petclinic with GNU General Public License v2.0 6 votes vote down vote up
public static WebArchive createSpecialtiesDeployment() {
    File[] deps = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().asFile();
    WebArchive war = null;
    try {
        war = ShrinkWrap.create(WebArchive.class, "specialties.war")
            .addClasses(SpecialtyController.class, LanguageBean.class,
                    SpecialtyDao.class, SpecialtyDaoImpl.class,
                    Owner.class, Pet.class, PetType.class,
                    Specialty.class, Vet.class, Visit.class)
            .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                    .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                    "/", Filters.include(".*\\.xhtml$|.*\\.html$"))
            .addAsResource("META-INF/persistence.xml")
            .addAsResource("messages_de.properties")
            .addAsResource("messages_en.properties")
            .addAsLibraries(deps)
            .addAsWebInfResource(
                    new StringAsset("<faces-config version=\"2.2\"/>"),
                    "faces-config.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return war;
}
 
Example #2
Source File: Deployments.java    From javaee7-petclinic with GNU General Public License v2.0 6 votes vote down vote up
public static WebArchive createPetTypeDeployment() {
    File[] deps = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().asFile();
    return ShrinkWrap.create(WebArchive.class, "pettypes.war")
            .addClasses(PetTypeController.class, LanguageBean.class,
                    PetTypeDao.class, PetTypeDaoImpl.class,
                    Owner.class, Pet.class, PetType.class,
                    Specialty.class, Vet.class, Visit.class)
            .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                    .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                    "/", Filters.include(".*\\.xhtml$|.*\\.html$"))
            .addAsResource("META-INF/persistence.xml")
            .addAsResource("messages_de.properties")
            .addAsResource("messages_en.properties")
            .addAsLibraries(deps)
            .addAsWebInfResource(
                    new StringAsset("<faces-config version=\"2.2\"/>"),
                    "faces-config.xml");
}
 
Example #3
Source File: Deployments.java    From javaee7-petclinic with GNU General Public License v2.0 6 votes vote down vote up
public static WebArchive createVetDeployment() {
    File[] deps = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().asFile();
    return ShrinkWrap.create(WebArchive.class, "vet.war")
            .addClasses(
                    SpecialtyController.class, VetController.class, LanguageBean.class,
                    SpecialtyConverter.class,
                    SpecialtyDao.class, SpecialtyDaoImpl.class,
                    VetDao.class, VetDaoImpl.class,
                    Owner.class, Pet.class, PetType.class,
                    Specialty.class, Vet.class, Visit.class,
                    VetSortingBean.class)
            .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                    .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                    "/", Filters.include(".*\\.xhtml$|.*\\.html$"))
            .addAsResource("META-INF/persistence.xml")
            .addAsResource("messages_de.properties")
            .addAsResource("messages_en.properties")
            .addAsLibraries(deps)
            .addAsWebInfResource(
                    new StringAsset("<faces-config version=\"2.2\"/>"),
                    "faces-config.xml");
}
 
Example #4
Source File: StudentResourceIntegrationTest.java    From tutorials with MIT License 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    JavaArchive[] kotlinRuntime = Maven.configureResolver()
            .workOffline()
            .withMavenCentralRepo(true)
            .withClassPathResolution(true)
            .loadPomFromFile("pom.xml")
            .resolve("org.jetbrains.kotlin:kotlin-stdlib:1.3.41")
            .withTransitivity()
            .as(JavaArchive.class);

    return ShrinkWrap.create(WebArchive.class, "kotlin.war")
            .addPackages(true, Filters.exclude(".*Test*"),
                    "com.baeldung.jeekotlin"
            )
            .addAsLibraries(kotlinRuntime)
            .addAsResource("META-INF/persistence.xml")
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example #5
Source File: MinimalMessagesTest.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
/**
 * X TODO creating a WebArchive is only a workaround because JavaArchive
 * cannot contain other archives.
 */
@Deployment
public static WebArchive deploy()
{
    JavaArchive testJar = ShrinkWrap
            .create(JavaArchive.class, "minimalMessageTest.jar")
            .addPackages(false, Filters.exclude(MessageContextTest.class),
                    MinimalMessagesTest.class.getPackage())
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

    return ShrinkWrap
            .create(WebArchive.class, "minimalMessageTest.war")
            .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
            .addAsLibraries(testJar)
            .addAsResource("customMinimalMessage_en.properties")
            .addAsResource("org/apache/deltaspike/test/core/api/message/MinimalMessages_en.properties")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
            .addAsServiceProvider(Extension.class,
                    MessageBundleExtension.class);
}
 
Example #6
Source File: Deployments.java    From javaee7-petclinic with GNU General Public License v2.0 5 votes vote down vote up
public static WebArchive createOwnerDeployment() {
    File[] deps = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeDependencies().resolve().withTransitivity().asFile();
    WebArchive war = null;
    try {
            war = ShrinkWrap.create(WebArchive.class, "owner.war")
            .addClasses(OwnerController.class, PetTypeController.class, LanguageBean.class,
                    OwnerService.class, OwnerServiceImpl.class,
                    OwnerDao.class, OwnerDaoImpl.class, PetDao.class, PetDaoImpl.class,
                    VisitDao.class, VisitDaoImpl.class,
                    PetTypeDao.class, PetTypeDaoImpl.class,
                    Owner.class, Pet.class, PetType.class,
                    Specialty.class, Vet.class, Visit.class)
            .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                    .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                    "/", Filters.include(".*\\.xhtml$"))
            .addAsResource("META-INF/persistence.xml")
            .addAsResource("messages_de.properties")
            .addAsResource("messages_en.properties")
            .addAsLibraries(deps)
            .addAsWebInfResource(
                            new StringAsset("<faces-config version=\"2.2\"/>"),
                            "faces-config.xml");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return war;
}
 
Example #7
Source File: AbstractApplicationArchiveProcessor.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
public void process(Archive<?> archive, TestClass testClass) {
    if (archive instanceof EnterpriseArchive) {
        final EnterpriseArchive ear = (EnterpriseArchive) archive;

        Map<ArchivePath, Node> wars = ear.getContent(Filters.include(".*\\.war"));
        for (Map.Entry<ArchivePath, Node> war : wars.entrySet()) {
            handleWebArchive(ear.getAsType(WebArchive.class, war.getKey()));
        }
    } else if (archive instanceof WebArchive) {
        handleWebArchive((WebArchive) archive);
    } else {
        throw new IllegalArgumentException("Can only handle .ear or .war deployments: " + archive);
    }
}
 
Example #8
Source File: MoviesArquillianHtmlUnitTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment
public static WebArchive createDeployment() {
    WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
            .addClasses(Movie.class, MoviesBean.class, MoviesArquillianHtmlUnitTest.class, ActionServlet.class)
            .addAsResource(new ClassLoaderAsset("META-INF/persistence.xml"), "META-INF/persistence.xml");

    war.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                    .importDirectory(Basedir.basedir(WEBAPP_SRC)).as(GenericArchive.class),
            "/", Filters.includeAll());

    return war;
}
 
Example #9
Source File: StaticContentContainer.java    From thorntail with Apache License 2.0 4 votes vote down vote up
/** Enable static content to be served from a given base in the classpath.
 *
 * @param base The path prefix to use for static content.
 * @return
 */
@SuppressWarnings("unchecked")
default T staticContent(String base) {
    //as(WARArchive.class).addModule("org.wildfly.swarm.undertow", "runtime");

    try {
        // Add all the static content from the current app to the archive
        // I believe it does not make sense to call archiveFromCurrentApp() again if this archive was created by DefaultWarDeploymentFactory
        Archive allResources = contains(DefaultWarDeploymentFactory.MARKER_PATH) ? this : DefaultWarDeploymentFactory.archiveFromCurrentApp();

        // Here we define static as basically anything that's not a
        // Java class file or under WEB-INF or META-INF
        mergeIgnoringDuplicates(allResources, base, Filters.exclude(".*\\.class$"));
    } catch (Exception ex) {
        log.log(Level.WARNING, "Error setting up static resources", ex);
    }

    Node node = get(EXTERNAL_MOUNT_PATH);
    UndertowExternalMountsAsset asset;
    if (node == null) {
        asset = new UndertowExternalMountsAsset();
        add(asset, EXTERNAL_MOUNT_PATH);
    } else {
        Asset tempAsset = node.getAsset();
        if (!(tempAsset instanceof UndertowExternalMountsAsset)) {
            asset = new UndertowExternalMountsAsset(tempAsset.openStream());
            add(asset, EXTERNAL_MOUNT_PATH);
        } else {
            asset = (UndertowExternalMountsAsset) node.getAsset();
        }
    }

    // Add external mounts for static content so changes are picked up
    // immediately during development
    Path webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "webapp");
    if (base != null) {
        webResources = webResources.resolve(base);
    }
    if (Files.exists(webResources)) {
        asset.externalMount(webResources.toString());
    }
    webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "resources");
    if (base != null) {
        webResources = webResources.resolve(base);
    }
    if (Files.exists(webResources)) {
        asset.externalMount(webResources.toString());
    }

    return (T) this;
}
 
Example #10
Source File: StaticContentContainer.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
default T staticContent(String base) {
    as(WARArchive.class).addModule("org.wildfly.swarm.undertow", "runtime");

    try {
        // Add all the static content from the current app to the archive
        Archive allResources = DefaultWarDeploymentFactory.archiveFromCurrentApp();
        // Here we define static as basically anything that's not a
        // Java class file or under WEB-INF or META-INF
        mergeIgnoringDuplicates(allResources, base, Filters.exclude(".*\\.class$"));
    } catch (Exception ex) {
        log.log(Level.WARNING, "Error setting up static resources", ex);
    }

    Node node = get("WEB-INF/undertow-external-mounts.conf");
    UndertowExternalMountsAsset asset;
    if (node == null) {
        asset = new UndertowExternalMountsAsset();
        add(asset, "WEB-INF/undertow-external-mounts.conf");
    } else {
        asset = (UndertowExternalMountsAsset) node.getAsset();
    }

    // Add external mounts for static content so changes are picked up
    // immediately during development
    Path webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "webapp");
    if (base != null) {
        webResources = webResources.resolve(base);
    }
    if (Files.exists(webResources)) {
        asset.externalMount(webResources.toString());
    }
    webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "resources");
    if (base != null) {
        webResources = webResources.resolve(base);
    }
    if (Files.exists(webResources)) {
        asset.externalMount(webResources.toString());
    }

    return (T) this;
}