org.jboss.shrinkwrap.api.importer.ExplodedImporter Java Examples

The following examples show how to use org.jboss.shrinkwrap.api.importer.ExplodedImporter. 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 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 #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 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 #4
Source File: Swarm.java    From thorntail with Apache License 2.0 6 votes vote down vote up
private void createShrinkWrapDomain() {
    ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
    try {
        if (isFatJar()) {
            Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
            Thread.currentThread().setContextClassLoader(appModule.getClassLoader());
        }
        Domain domain = ShrinkWrap.getDefaultDomain();
        domain.getConfiguration().getExtensionLoader().addOverride(ZipExporter.class, ZipExporterImpl.class);
        domain.getConfiguration().getExtensionLoader().addOverride(ZipImporter.class, ZipImporterImpl.class);
        domain.getConfiguration().getExtensionLoader().addOverride(ExplodedExporter.class, ExplodedExporterImpl.class);
        domain.getConfiguration().getExtensionLoader().addOverride(ExplodedImporter.class, ExplodedImporterImpl.class);
        domain.getConfiguration().getExtensionLoader().addOverride(JavaArchive.class, JavaArchiveImpl.class);
        domain.getConfiguration().getExtensionLoader().addOverride(WebArchive.class, WebArchiveImpl.class);
    } catch (Exception e) {
        SwarmMessages.MESSAGES.shrinkwrapDomainSetupFailed(e);
    } finally {
        Thread.currentThread().setContextClassLoader(originalCl);
    }
}
 
Example #5
Source File: Mvn.java    From tomee with Apache License 2.0 5 votes vote down vote up
private Builder add(final Archive<?> webArchive, final File dir, final String root) {
    if (dir == null || !dir.exists()) {
        return this;
    }

    final KnownResourcesFilter filter = new KnownResourcesFilter(dir, root, this.filter);
    filter.update(
        webArchive.merge(
            ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                .importDirectory(dir).as(GenericArchive.class), root, filter));

    return this;
}
 
Example #6
Source File: TomeeDevArchiveProvider.java    From krazo with Apache License 2.0 5 votes vote down vote up
@Override
public WebArchive getBaseArchive() {
    return ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(resolveMvcSpecJar())
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-core.jar")
                            .importDirectory("../core/target/classes")
                            .as(JavaArchive.class)
            )
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-cxf.jar")
                            .importDirectory("../cxf/target/classes")
                            .as(JavaArchive.class)
            );
}
 
Example #7
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 #8
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 #9
Source File: ArtifactManager.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public List<JavaArchive> allArtifacts(String... groupIdExclusions) throws IOException {
    Map<String, JavaArchive> archives = new HashMap<>();
    Set<String> archivesPaths;

    final List<String> exclusions = Arrays.asList(groupIdExclusions);

    ApplicationEnvironment env = ApplicationEnvironment.get();
    archivesPaths = env.resolveDependencies(exclusions);

    // package the shrinkwrap bits
    for (final String element : archivesPaths) {

        final File artifact = new File(element);

        if (artifact.isFile()) {
            archives.put(artifact.getName(), ShrinkWrap.create(ZipImporter.class, artifact.getName())
                    .importFrom(artifact)
                    .as(JavaArchive.class));
        } else {

            final String archiveName = FileSystemLayout.archiveNameForClassesDir(artifact.toPath());

            // pack resources and classes of the same project into one archive
            if (archives.containsKey(archiveName)) {
                archives.get(archiveName).as(ExplodedImporter.class).importDirectory(artifact);
            } else {
                archives.put(archiveName, ShrinkWrap.create(ExplodedImporter.class, archiveName)
                        .importDirectory(artifact)
                        .as(JavaArchive.class));
            }
        }
    }

    return new ArrayList<>(archives.values());
}
 
Example #10
Source File: DefaultWarDeploymentFactory.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean setupUsingAppArtifact(Archive<?> archive) throws IOException {
    File exploded = ExplodedApplicationArtifactLocator.get();
    if (exploded != null && exploded.canRead()) {
        // Use exploded deployment from tmp dir
        archive.as(ExplodedImporter.class).importDirectory(exploded);
        return true;
    }
    return super.setupUsingAppArtifact(archive);
}
 
Example #11
Source File: BuildTool.java    From thorntail with Apache License 2.0 5 votes vote down vote up
private void addUberjarResources() {
    if (this.uberjarResourcesDirectory == null) {
        return;
    }

    if (!Files.exists(this.uberjarResourcesDirectory)) {
        return;
    }

    if (!Files.isDirectory(this.uberjarResourcesDirectory)) {
        return;
    }

    this.archive.as(ExplodedImporter.class).importDirectory(this.uberjarResourcesDirectory.toFile());
}
 
Example #12
Source File: EdgeResourceIT.java    From javaee8-jaxrs-sample with GNU General Public License v3.0 5 votes vote down vote up
@Deployment(testable = false)
    public static WebArchive createDeployment() {

        File[] extraJars = Maven.resolver().loadPomFromFile("pom.xml")
            .resolve(
                "org.projectlombok:lombok:1.16.8",
                // "org.modelmapper:modelmapper:0.7.5",
                // "org.apache.commons:commons-lang3:3.4",
                // "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.3",
                "io.jsonwebtoken:jjwt:0.8.0"
            )
            .withTransitivity()
            .asFile();

        final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
            .addAsLibraries(extraJars)
            .addPackages(true, Bootstrap.class.getPackage())
            // .addAsResource("test-log4j.properties", "log4j.properties")
            //Add JPA persistence configration.
            //WARN: In a war package, persistence.xml should be put into /WEB-INF/classes/META-INF/, not /META-INF
            //.addAsManifestResource("META-INF/test-persistence.xml", "persistence.xml")
            .addAsResource("META-INF/persistence.xml")
            .addAsResource("META-INF/orm.xml");

//            .addAsWebInfResource("test-web.xml", "web.xml")
//            // Enable CDI
//            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
        //  .addAsWebInfResource("test-jboss-deployment-structure.xml", "jboss-deployment-structure.xml");
        war.merge(
            ShrinkWrap.create(GenericArchive.class)
                .as(ExplodedImporter.class)
                .importDirectory("src/main/webapp")
                .as(GenericArchive.class),
            "/"
        );
        LOG.log(Level.INFO, "war to string @{0}", war.toString(true));
        return war;
    }
 
Example #13
Source File: WildflyDevArchiveProvider.java    From krazo with Apache License 2.0 5 votes vote down vote up
@Override
public WebArchive getBaseArchive() {
    return ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(resolveMvcSpecJar())
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-core.jar")
                            .importDirectory("../core/target/classes")
                            .as(JavaArchive.class)
            )
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-resteasy.jar")
                            .importDirectory("../resteasy/target/classes")
                            .as(JavaArchive.class)
            );
}
 
Example #14
Source File: LibertyDevArchiveProvider.java    From krazo with Apache License 2.0 5 votes vote down vote up
@Override
public WebArchive getBaseArchive() {
    return ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(resolveMvcSpecJar())
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-core.jar")
                            .importDirectory("../core/target/classes")
                            .as(JavaArchive.class)
            )
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-cxf.jar")
                            .importDirectory("../cxf/target/classes")
                            .as(JavaArchive.class)
            );
}
 
Example #15
Source File: GlassfishDevArchiveProvider.java    From krazo with Apache License 2.0 5 votes vote down vote up
@Override
public WebArchive getBaseArchive() {
    return ShrinkWrap.create(WebArchive.class)
            .addAsLibraries(resolveMvcSpecJar())
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-core.jar")
                            .importDirectory("../core/target/classes")
                            .as(JavaArchive.class)
            )
            .addAsLibraries(
                    ShrinkWrap.create(ExplodedImporter.class, "krazo-jersey.jar")
                            .importDirectory("../jersey/target/classes")
                            .as(JavaArchive.class)
            );
}
 
Example #16
Source File: SwaggerWebAppFraction.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
private Archive<?> loadFromDirectory(File directory) throws IOException {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);
    archive.as(ExplodedImporter.class).importDirectory(directory);
    return archive;
}
 
Example #17
Source File: SwaggerWebAppFraction.java    From thorntail with Apache License 2.0 4 votes vote down vote up
private Archive<?> loadFromDirectory(File directory) throws IOException {
    JARArchive archive = ShrinkWrap.create(JARArchive.class);
    archive.as(ExplodedImporter.class).importDirectory(directory);
    return archive;
}