Esempio n. 1
0
  private void writeJarOptions(
      String inputEntryOptionName, String outputEntryOptionName, ClassPath classPath) {
    if (classPath != null) {
      for (int index = 0; index < classPath.size(); index++) {
        ClassPathEntry entry = classPath.get(index);
        String optionName = entry.isOutput() ? outputEntryOptionName : inputEntryOptionName;

        writer.print(optionName);
        writer.print(' ');
        writer.print(relativeFileName(entry.getFile()));

        // Append the filters, if any.
        boolean filtered = false;

        // For backward compatibility, the aar and apk filters come
        // first.
        filtered = writeFilter(filtered, entry.getAarFilter());
        filtered = writeFilter(filtered, entry.getApkFilter());
        filtered = writeFilter(filtered, entry.getZipFilter());
        filtered = writeFilter(filtered, entry.getEarFilter());
        filtered = writeFilter(filtered, entry.getWarFilter());
        filtered = writeFilter(filtered, entry.getJarFilter());
        filtered = writeFilter(filtered, entry.getFilter());

        if (filtered) {
          writer.print(ConfigurationConstants.CLOSE_ARGUMENTS_KEYWORD);
        }

        writer.println();
      }
    }
  }
  /**
   * Creates a DataEntryReader that can read the given class path entry.
   *
   * @param messagePrefix a prefix for messages that are printed out.
   * @param classPathEntry the input class path entry.
   * @param reader a data entry reader to which the reading of actual classes and resource files can
   *     be delegated.
   * @return a DataEntryReader for reading the given class path entry.
   */
  public static DataEntryReader createDataEntryReader(
      String messagePrefix, ClassPathEntry classPathEntry, DataEntryReader reader) {
    boolean isApk = classPathEntry.isApk();
    boolean isJar = classPathEntry.isJar();
    boolean isAar = classPathEntry.isAar();
    boolean isWar = classPathEntry.isWar();
    boolean isEar = classPathEntry.isEar();
    boolean isZip = classPathEntry.isZip();

    List filter = classPathEntry.getFilter();
    List apkFilter = classPathEntry.getApkFilter();
    List jarFilter = classPathEntry.getJarFilter();
    List aarFilter = classPathEntry.getAarFilter();
    List warFilter = classPathEntry.getWarFilter();
    List earFilter = classPathEntry.getEarFilter();
    List zipFilter = classPathEntry.getZipFilter();

    System.out.println(
        messagePrefix
            + (isApk
                ? "apk"
                : isJar
                    ? "jar"
                    : isAar ? "aar" : isWar ? "war" : isEar ? "ear" : isZip ? "zip" : "directory")
            + " ["
            + classPathEntry.getName()
            + "]"
            + (filter != null
                    || apkFilter != null
                    || jarFilter != null
                    || aarFilter != null
                    || warFilter != null
                    || earFilter != null
                    || zipFilter != null
                ? " (filtered)"
                : ""));

    // Add a filter, if specified.
    if (filter != null) {
      reader =
          new FilteredDataEntryReader(
              new DataEntryNameFilter(new ListParser(new FileNameParser()).parse(filter)), reader);
    }

    // Unzip any apks, if necessary.
    reader = wrapInJarReader(reader, isApk, apkFilter, ".apk");
    if (!isApk) {
      // Unzip any jars, if necessary.
      reader = wrapInJarReader(reader, isJar, jarFilter, ".jar");
      if (!isJar) {
        // Unzip any aars, if necessary.
        reader = wrapInJarReader(reader, isAar, aarFilter, ".aar");
        if (!isAar) {
          // Unzip any wars, if necessary.
          reader = wrapInJarReader(reader, isWar, warFilter, ".war");
          if (!isWar) {
            // Unzip any ears, if necessary.
            reader = wrapInJarReader(reader, isEar, earFilter, ".ear");
            if (!isEar) {
              // Unzip any zips, if necessary.
              reader = wrapInJarReader(reader, isZip, zipFilter, ".zip");
            }
          }
        }
      }
    }

    return reader;
  }