@Override
  public ManifestIdentifier identify(Config config) {
    final String manifestPath = config.manifest();
    if (manifestPath.equals(Config.NONE)) {
      return new ManifestIdentifier((String) null, null, null, null, null);
    }

    // Try to locate the manifest file as a classpath resource; fallback to using the base dir.
    final Path manifestFile;
    final String resourceName = manifestPath.startsWith("/") ? manifestPath : ("/" + manifestPath);
    final URL resourceUrl = getClass().getResource(resourceName);
    if (resourceUrl != null && "file".equals(resourceUrl.getProtocol())) {
      // Construct a path to the manifest file relative to the current working directory.
      final Path workingDirectory = Paths.get(System.getProperty("user.dir"));
      final Path absolutePath = Fs.fromUrl(resourceUrl);
      manifestFile = workingDirectory.relativize(absolutePath);
    } else {
      manifestFile = getBaseDir().resolve(manifestPath);
    }

    final Path baseDir = manifestFile.getParent();
    final Path resDir = baseDir.resolve(config.resourceDir());
    final Path assetDir = baseDir.resolve(config.assetDir());

    List<ManifestIdentifier> libraries;
    if (config.libraries().length == 0) {
      // If there is no library override, look through subdirectories.
      try {
        libraries = findLibraries(resDir);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } else {
      libraries = new ArrayList<>();
      for (String libraryDirName : config.libraries()) {
        Path libDir = baseDir.resolve(libraryDirName);
        libraries.add(
            new ManifestIdentifier(
                null,
                libDir.resolve(Config.DEFAULT_MANIFEST_NAME),
                libDir.resolve(Config.DEFAULT_RES_FOLDER),
                libDir.resolve(Config.DEFAULT_ASSET_FOLDER),
                null));
      }
    }

    return new ManifestIdentifier(config.packageName(), manifestFile, resDir, assetDir, libraries);
  }
@Test
  public void withDotDotSlashManifest_identify() throws Exception {
    configBuilder.setManifest("../DifferentManifest.xml");

    ManifestIdentifier manifestIdentifier = myMavenManifestFactory.identify(configBuilder.build());
    assertThat(manifestIdentifier.getManifestFile())
        .isEqualTo(Paths.get("_fakefs_path/to/../DifferentManifest.xml"));
    assertThat(manifestIdentifier.getResDir()).isEqualTo(Paths.get("_fakefs_path/to/../res"));
  }