public ClassPath getToolingImplementationClasspath( ProgressLoggerFactory progressLoggerFactory, File userHomeDir) { if (installedDistribution == null) { File installDir; try { File realUserHomeDir = userHomeDir != null ? userHomeDir : myUserHomeDir != null ? myUserHomeDir : GradleUserHomeLookup.gradleUserHome(); Install install = new Install( new ProgressReportingDownload(progressLoggerFactory), new PathAssembler(realUserHomeDir)); installDir = install.createDist(wrapperConfiguration); } catch (FileNotFoundException e) { throw new IllegalArgumentException( String.format("The specified %s does not exist.", getDisplayName()), e); } catch (Exception e) { throw new GradleConnectionException( String.format( "Could not install Gradle distribution from '%s'.", wrapperConfiguration.getDistribution()), e); } installedDistribution = new InstalledDistribution(installDir, getDisplayName(), getDisplayName()); } return installedDistribution.getToolingImplementationClasspath( progressLoggerFactory, userHomeDir); }
public File createDist(WrapperConfiguration configuration) throws Exception { final URI distributionUrl = configuration.getDistribution(); final PathAssembler.LocalDistribution localDistribution = pathAssembler.getDistribution(configuration); final File distDir = localDistribution.getDistributionDir(); final File localZipFile = localDistribution.getZipFile(); return exclusiveFileAccessManager.access( localZipFile, new Callable<File>() { public File call() throws Exception { final File markerFile = new File(localZipFile.getParentFile(), localZipFile.getName() + ".ok"); if (distDir.isDirectory() && markerFile.isFile()) { return getDistributionRoot(distDir, distDir.getAbsolutePath()); } boolean needsDownload = !localZipFile.isFile(); if (needsDownload) { File tmpZipFile = new File(localZipFile.getParentFile(), localZipFile.getName() + ".part"); tmpZipFile.delete(); System.out.println("Downloading " + distributionUrl); download.download(distributionUrl, tmpZipFile); tmpZipFile.renameTo(localZipFile); } List<File> topLevelDirs = listDirs(distDir); for (File dir : topLevelDirs) { System.out.println("Deleting directory " + dir.getAbsolutePath()); deleteDir(dir); } System.out.println( "Unzipping " + localZipFile.getAbsolutePath() + " to " + distDir.getAbsolutePath()); unzip(localZipFile, distDir); File root = getDistributionRoot(distDir, distributionUrl.toString()); setExecutablePermissions(root); markerFile.createNewFile(); return root; } }); }
public String getDisplayName() { return String.format("Gradle distribution '%s'", wrapperConfiguration.getDistribution()); }