Skip to content

Instantly share code, notes, and snippets.

@lordofthejars
Created September 16, 2014 09:33
Show Gist options
  • Select an option

  • Save lordofthejars/54ddd481ad331ade858a to your computer and use it in GitHub Desktop.

Select an option

Save lordofthejars/54ddd481ad331ade858a to your computer and use it in GitHub Desktop.
//Instead of
archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
.importDirectory(WEBAPP_SRC).as(GenericArchive.class),
"/", Filters.include(".*\\.js$"))
archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
.importDirectory(WEBAPP_SRC).as(GenericArchive.class),
"/", Filters.include(".*\\.css$"))
archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
.importDirectory(WEBAPP_SRC).as(GenericArchive.class),
"/", Filters.include(".*\\.xhtml"))
//You can use
private static final Path WEBAPP_SRC_PATH = Paths.get("src","main","webapp");
private static final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**.{xhtml,css,js}");
Files.find(WEBAPP_SRC_PATH, Integer.MAX_VALUE, (path, attr) -> matcher.matches(path))
.forEach((p) -> archive.addAsWebResource(p.toFile(), WEBAPP_SRC_PATH.relativize(p).toString()));
@aslakknutsen
Copy link
Copy Markdown

couldn't you as well technically make it:

archive.merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                                .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                        "/", Filters.include(".*\\.(js|css|xhtml)$"))

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment