Пример #1
0
  private IOFileFilter createExcludeUserLibsTestsFilter(String appName) {
    IOFileFilter excludeDirFilter = new ExcludeDirFileFilter("");

    for (JsLib jsLib : brjs.app(appName).jsLibs()) {
      if (jsLib.parentNode() instanceof App) {
        excludeDirFilter =
            new AndFileFilter(excludeDirFilter, new ExcludeDirFileFilter(jsLib.getName(), "test"));
      }
    }

    return excludeDirFilter;
  }
Пример #2
0
  @Override
  protected void doCommand(JSAPResult parsedArgs)
      throws CommandArgumentsException, CommandOperationException {
    String appName = parsedArgs.getString("app-name");
    String disclaimer = "/*\n* " + parsedArgs.getString("disclaimer") + "\n*/\n\n";
    App app = brjs.app(appName);

    if (!app.dirExists())
      throw new CommandArgumentsException("Could not find application '" + appName + "'", this);

    File destinationZipLocation =
        new File(brjs.storageDir("exported-app").getAbsolutePath() + "/" + appName + ".zip");

    try {
      File temporaryExportDir = FileUtility.createTemporaryDirectory(appName);

      IOFileFilter excludeUserLibraryTestsFilter = createExcludeUserLibsTestsFilter(appName);
      NotFileFilter brjsJarFilter =
          new NotFileFilter(
              new AndFileFilter(new PrefixFileFilter("brjs-"), new SuffixFileFilter(".jar")));
      IOFileFilter combinedFilter =
          new AndFileFilter(new ExcludeDirFileFilter("js-test-driver", "bundles"), brjsJarFilter);

      combinedFilter = new AndFileFilter(combinedFilter, excludeUserLibraryTestsFilter);

      createResourcesFromSdkTemplate(app.dir(), temporaryExportDir, combinedFilter);
      includeDisclaimerInDirectoryClasses(new File(temporaryExportDir, "libs"), disclaimer);
      FileUtility.zipFolder(temporaryExportDir, destinationZipLocation, false);
    } catch (Exception e) {
      throw new CommandOperationException(
          "Could not create application zip for application '" + appName + "'", e);
    }

    logger.info("Successfully exported application '" + appName + "'");
    logger.info(" " + destinationZipLocation.getAbsolutePath());
  }