Common functionality to be able to download a SDK and use it within Gradle
Type | Name and description |
---|---|
static String |
INSTALLER_VERSION |
static boolean |
IS_WINDOWS |
Constructor and description |
---|
protected AbstractDistributionInstaller
(String distributionName, String distributionVersion, String basePath, Project project) Creates setup for installing to a local cache. |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
addExecPattern(String... relPaths) Add patterns for files to be marked exe, |
|
protected File |
getAndVerifyDistributionRoot(File distDir, String distributionDescription) Validates that the unpacked distribution is good. |
|
File |
getDistributionRoot() Returns the location which is the top or home folder for a distribution. |
|
protected BaseProgressLogger |
getLogger() Returns the logger currently in use. |
|
protected Project |
getProject() Returns the attached project |
|
protected java.util.List<File> |
listDirs(File distDir) Provides a list of directories below an unpacked distribution |
|
File |
locateDistributionInCustomLocation(String version) Override this method to provide alternative means to look for distributions. |
|
void |
setChecksum(String cs) Set a checksum that needs to be verified against downloaded archive |
|
void |
setDownloadRoot(File downloadRootDir) Sets a download root directory for the distribution. |
|
void |
setSdkManCandidateName(String sdkCandidateName) Set candidate name for SdkMan if the latter should be searched for installed versions |
|
protected void |
unpack(File srcArchive, File destDir) Unpacks a downloaded archive. |
|
protected void |
unpackMSI(File srcArchive, File destDir, java.util.Map<String, String> env) Provides the capability of unpacking an MSI file under Windows by calling out to msiexec . |
|
URI |
uriFromVersion(String version) Creates a download URI from a given distribution version |
|
protected void |
verifyDownloadChecksum(String sourceUrl, File localCompressedFile, String expectedSum) Verifies the checksum (if provided) of a newly downloaded distribution archive. |
Creates setup for installing to a local cache.
distributionName
- Descriptive name of the distributiondistributionVersion
- Version of the distribution to obtainbasePath
- Relative path below Gradle User Home to create cache for all version of this distribution type.project
- Gradle project that this downloader is attached to.Add patterns for files to be marked exe, Calling this method multiple times simply appends for patterns
relPaths
- One or more ANT-stype include patternsValidates that the unpacked distribution is good.
The default implementation simply checks that only one directory should exist and then uses that. You should override this method if your distribution in question does not follow the common practice of one top-level directory.
distDir
.distDir
- Directory where distribution was unpacked to.distributionDescription
- A descriptive name of the distributionReturns the location which is the top or home folder for a distribution. This value is affected by setDownloadRoot(java.io.File) and the parameters passed in during construction time.
Returns the logger currently in use.
Returns the attached project
Provides a list of directories below an unpacked distribution
distDir
- Unpacked distribution directoryOverride this method to provide alternative means to look for distributions.
Set a checksum that needs to be verified against downloaded archive
cs
- SHA-256 Hex-encoded checksumSets a download root directory for the distribution. If not supplied the default is to use the Gradle User Home. This method is provided for convenience and is mostly only used for testing purposes. The folder will be created at download time if it does not exist.
downloadRootDir
- Any writeable directory on the filesystem.Set candidate name for SdkMan if the latter should be searched for installed versions
sdkCandidateName
- SDK Candidate name. This is the same names that will be shown when
running sdk list candidates
on the script-line.Unpacks a downloaded archive.
The default implementation supports the following formats:
If you need MSI support you need to override this method and call out to the provided unpackMSI method yourself.
srcArchive
- The location of the download archivedestDir
- The directory where the archive needs to be unpacked into Provides the capability of unpacking an MSI file under Windows by calling out to msiexec
.
msiexec
will be located via the system search path.
srcArchive
- The location of the download MSIdestDir
- The directory where the MSI needs to be unpacked intoenv
- Environment to use. Can be null or empty inwhich case a default environment will be usedCreates a download URI from a given distribution version
version
- Version of the distribution to downloadVerifies the checksum (if provided) of a newly downloaded distribution archive.
Only SHA-256 is supported at this point in time.
sourceUrl
- The URL/URI where it was downloaded fromlocalCompressedFile
- The location of the downloaded archiveexpectedSum
- The expected checksum. Can be null in which case no checks will be performed.Groovy Documentation