@Override
  public List<FileEntriesLayer> createLayers() throws IOException {
    // Clear the exploded-artifact root first
    if (Files.exists(targetExplodedWarRoot)) {
      MoreFiles.deleteRecursively(targetExplodedWarRoot, RecursiveDeleteOption.ALLOW_INSECURE);
    }

    ZipUtil.unzip(warPath, targetExplodedWarRoot, true);
    Predicate<Path> isFile = Files::isRegularFile;
    Predicate<Path> isInWebInfLib =
        path -> path.startsWith(targetExplodedWarRoot.resolve("WEB-INF").resolve("lib"));
    Predicate<Path> isSnapshot = path -> path.getFileName().toString().contains("SNAPSHOT");

    // Non-snapshot layer
    Predicate<Path> isInWebInfLibAndIsNotSnapshot = isInWebInfLib.and(isSnapshot.negate());
    FileEntriesLayer nonSnapshotLayer =
        ArtifactLayers.getDirectoryContentsAsLayer(
            ArtifactLayers.DEPENDENCIES,
            targetExplodedWarRoot,
            isFile.and(isInWebInfLibAndIsNotSnapshot),
            appRoot);

    // Snapshot layer
    Predicate<Path> isInWebInfLibAndIsSnapshot = isInWebInfLib.and(isSnapshot);
    FileEntriesLayer snapshotLayer =
        ArtifactLayers.getDirectoryContentsAsLayer(
            ArtifactLayers.SNAPSHOT_DEPENDENCIES,
            targetExplodedWarRoot,
            isFile.and(isInWebInfLibAndIsSnapshot),
            appRoot);

    // Classes layer.
    Predicate<Path> isClass = path -> path.getFileName().toString().endsWith(".class");
    Predicate<Path> isInWebInfClasses =
        path -> path.startsWith(targetExplodedWarRoot.resolve("WEB-INF").resolve("classes"));
    Predicate<Path> classesPredicate = isInWebInfClasses.and(isClass);
    FileEntriesLayer classesLayer =
        ArtifactLayers.getDirectoryContentsAsLayer(
            ArtifactLayers.CLASSES, targetExplodedWarRoot, classesPredicate, appRoot);

    // Resources layer.
    Predicate<Path> resourcesPredicate = isInWebInfLib.or(isClass).negate();
    FileEntriesLayer resourcesLayer =
        ArtifactLayers.getDirectoryContentsAsLayer(
            ArtifactLayers.RESOURCES,
            targetExplodedWarRoot,
            isFile.and(resourcesPredicate),
            appRoot);

    ArrayList<FileEntriesLayer> layers = new ArrayList<>();
    if (!nonSnapshotLayer.getEntries().isEmpty()) {
      layers.add(nonSnapshotLayer);
    }
    if (!snapshotLayer.getEntries().isEmpty()) {
      layers.add(snapshotLayer);
    }
    if (!resourcesLayer.getEntries().isEmpty()) {
      layers.add(resourcesLayer);
    }
    if (!classesLayer.getEntries().isEmpty()) {
      layers.add(classesLayer);
    }

    return layers;
  }
@Test
  public void testCreateLayers_allLayers_correctExtractionPaths()
      throws IOException, URISyntaxException {
    // Prepare war file for test
    Path tempDirectory = temporaryFolder.getRoot().toPath();
    Path warContents = Paths.get(Resources.getResource("war/standard/allLayers").toURI());
    Path standardWar = zipUpDirectory(warContents, tempDirectory.resolve("standardWar.war"));

    Path explodedWarDestination = temporaryFolder.newFolder("exploded-war").toPath();
    StandardWarExplodedProcessor processor =
        new StandardWarExplodedProcessor(standardWar, explodedWarDestination, APP_ROOT);
    List<FileEntriesLayer> layers = processor.createLayers();

    assertThat(layers.size()).isEqualTo(4);

    FileEntriesLayer nonSnapshotLayer = layers.get(0);
    FileEntriesLayer snapshotLayer = layers.get(1);
    FileEntriesLayer resourcesLayer = layers.get(2);
    FileEntriesLayer classesLayer = layers.get(3);

    assertThat(nonSnapshotLayer.getEntries())
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly("/my/app/WEB-INF/lib/dependency-1.0.0.jar");
    assertThat(snapshotLayer.getEntries())
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly("/my/app/WEB-INF/lib/dependencyX-1.0.0-SNAPSHOT.jar");
    assertThat(resourcesLayer.getEntries())
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly(
            "/my/app/META-INF/context.xml",
            "/my/app/Test.jsp",
            "/my/app/WEB-INF/web.xml",
            "/my/app/WEB-INF/classes/package/test.properties");
    assertThat(classesLayer.getEntries())
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly(
            "/my/app/WEB-INF/classes/MyClass2.class",
            "/my/app/WEB-INF/classes/package/MyClass.class");
  }