示例#1
0
 protected void addZipFile(File file) throws MojoExecutionException, IOException, GitAPIException {
   if (file == null || !file.exists() || !file.isFile()) {
     throw new MojoExecutionException("Zip file does not exist: " + file);
   }
   File unzipDir = new File(buildDir, "fabric/profiles");
   unzipDir.mkdirs();
   try {
     Zips.unzip(new FileInputStream(file), unzipDir);
   } catch (IOException e) {
     throw new MojoExecutionException(
         "Failed to unzip file "
             + file.getCanonicalPath()
             + " to "
             + getGitBuildPathDescription()
             + ". "
             + e,
         e);
   }
 }
示例#2
0
  private static Collection<String> extract(final String zip) throws IOException {
    final File tmp = new File(SystemInstance.get().getBase().getDirectory(), TEMP_DIR);
    if (!tmp.exists()) {
      try {
        Files.mkdirs(tmp);
      } catch (Files.FileRuntimeException fre) {
        // ignored
      }
    }

    final File zipFile = new File(realLocation(zip));
    final File extracted = new File(tmp, zipFile.getName().replace(".zip", ""));
    if (extracted.exists()) {
      return list(extracted);
    } else {
      Files.mkdirs(extracted);
    }

    Zips.unzip(zipFile, extracted);
    return list(extracted);
  }