@groovy.transform.CompileStatic @groovy.util.logging.Slf4j @SuppressWarnings('AbstractClassWithoutAbstractMethod') abstract class AbstractDistributionInstaller
Common functionality to be able to download a SDK and use it within Gradle
Modifiers | Name | Description |
---|---|---|
static boolean |
IS_WINDOWS |
|
protected String |
distributionName |
Name of the distribution. |
protected ProjectOperations |
projectOperations |
Project operations that can used during downloading. |
Type | Name and description |
---|---|
ArtifactRootVerification |
artifactRootVerification |
ArtifactUnpacker |
artifactUnpacker |
String |
sdkManCandidateName |
Constructor and description |
---|
protected AbstractDistributionInstaller
(String distributionName, String basePath, ProjectOperations projectOperations) 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 |
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 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 . |
|
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. |
Name of the distribution.
Project operations that can used during downloading.
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.projectOperations
- 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 patternsCreates 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:
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 in which case a default environment will be usedValidates 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