@groovy.transform.CompileStatic @groovy.util.logging.Slf4j @SuppressWarnings(value: AbstractClassWithoutAbstractMethod) abstract class AbstractDistributionInstaller extends Object implements DistributionInstaller
Common functionality to be able to download a SDK and use it within Gradle
| Modifiers | Name | Description |
|---|---|---|
class |
AbstractDistributionInstaller.1 |
|
class |
AbstractDistributionInstaller.2 |
| Modifiers | Name | Description |
|---|---|---|
static boolean |
IS_MACOSX |
|
static boolean |
IS_WINDOWS |
|
protected ConfigCacheSafeOperations |
configCacheSafeOperations |
Project operations that can used during downloading. |
protected String |
distributionName |
Name of the distribution. |
protected java.util.List<String> |
execPatterns |
Defined execution patterns. |
| Type | Name and description |
|---|---|
ArtifactRootVerification |
artifactRootVerification |
ArtifactUnpacker |
artifactUnpacker |
String |
sdkManCandidateName |
| Constructor and description |
|---|
protected AbstractDistributionInstaller
(String distributionName, String basePath, ConfigCacheSafeOperations taskComponents)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 String |
extractFinalExtension(String filename)Extract the last extension in a file name. |
|
protected File |
getDistFromCache(String version)Creates a distribution if it does not exist already. |
|
protected File |
getDistFromSdkMan(String version)Attempts to locate distribution in the list of SdkMan candidates. |
|
Provider<File> |
getDistributionFile(String version, String fileRelPath)Locates a file within the distribution |
|
Provider<File> |
getDistributionRoot(String version)Returns the location which is the top or home folder for a distribution. |
|
String |
getSdkManCandidateName()SDKman candidate name for distribution. |
|
protected java.util.List<File> |
listDirs(File distDir)Provides a list of directories below an unpacked distribution |
|
protected File |
resolveDistributionLocationForVersion(String version)Resolves distribution location by looking in various locations. |
|
void |
setChecksum(String cs)Set a checksum that needs to be verified against downloaded archive |
|
void |
setDownloadRoot(Object 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 Parameters |
unpackParametersForExtension(String extension)Returns custom parameters for initialising an unpack engine. |
|
protected File |
verifyDistributionRoot(File distDir)Validates that the unpacked distribution is good. |
|
protected void |
verifyDownloadChecksum(String sourceUrl, File localCompressedFile, String expectedSum)Verifies the checksum (if provided) of a newly downloaded distribution archive. |
Project operations that can used during downloading.
Name of the distribution.
Defined execution patterns.
Creates setup for installing to a local cache.
distributionName - Descriptive name of the distributionbasePath - Relative path below Gradle User Home to create cache for all version of this distribution type.taskComponents - Gradle project operations that this downloader can use.Add patterns for files to be marked exe, Calling this method multiple times simply appends for patterns
relPaths - One or more ANT-stype include patternsExtract the last extension in a file name.
filename - FilenameCreates a distribution if it does not exist already.
Attempts to locate distribution in the list of SdkMan candidates.
Locates a file within the distribution
version - Version of distribution to search.fileRelPath - Relative path to the distribution root.Returns 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.
SDKman candidate name for distribution.
null.Provides a list of directories below an unpacked distribution
distDir - Unpacked distribution directoryResolves distribution location by looking in various locations.
version - Version to resolvenull if nothing could be found.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:
srcArchive - The location of the download archivedestDir - The directory where the archive needs to be unpacked intoReturns custom parameters for initialising an unpack engine.
Implementors can override this to return specific parameters depending on the kind of extension to unpack.
The default implementation sets a relative path for .dmg files and a basic environment
for .msi files.
extension - Archive or compressed file extension.null if no specific parameters exist.Validates 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 - Directory where distribution was unpacked to.distDir.Verifies 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