Beispiel #1
0
 public File createDist(
     URI distributionUrl, String distBase, String distPath, String zipBase, String zipPath)
     throws Exception {
   File gradleHome = pathAssembler.gradleHome(distBase, distPath, distributionUrl);
   if (!alwaysDownload && !alwaysUnpack && gradleHome.isDirectory()) {
     return gradleHome;
   }
   File localZipFile = pathAssembler.distZip(zipBase, zipPath, distributionUrl);
   if (alwaysDownload || !localZipFile.exists()) {
     File tmpZipFile = new File(localZipFile.getParentFile(), localZipFile.getName() + ".part");
     tmpZipFile.delete();
     System.out.println("Downloading " + distributionUrl);
     download.download(distributionUrl, tmpZipFile);
     tmpZipFile.renameTo(localZipFile);
   }
   if (gradleHome.isDirectory()) {
     System.out.println("Deleting directory " + gradleHome.getAbsolutePath());
     deleteDir(gradleHome);
   }
   File distDest = gradleHome.getParentFile();
   System.out.println(
       "Unzipping " + localZipFile.getAbsolutePath() + " to " + distDest.getAbsolutePath());
   unzip(localZipFile, distDest);
   if (!gradleHome.isDirectory()) {
     throw new RuntimeException(
         String.format(
             "Gradle distribution '%s' does not contain expected directory '%s'.",
             distributionUrl, gradleHome.getName()));
   }
   setExecutablePermissions(gradleHome);
   return gradleHome;
 }