Created
December 2, 2020 10:17
-
-
Save sustacek/908fc668e45356595134150e7ff945f0 to your computer and use it in GitHub Desktop.
Verify bundle checksum in Liferay Workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure we can use the classes from the Download plugin, like the Verify below | |
buildscript { | |
repositories { jcenter() } | |
dependencies { classpath group: "de.undercouch", name: "gradle-download-task", version: "4.0.4" } | |
} | |
apply plugin: de.undercouch.gradle.tasks.download.DownloadTaskPlugin | |
[ | |
'SHA-256': 'liferay.workspace.bundle.checksum[sha-256]', | |
'MD5': 'liferay.workspace.bundle.checksum[md5]', | |
].each { checksumAlgorithm, expectedSumPropName -> | |
// Verify checksum using given algorithm, but only if the project property | |
// with the expected checksum was provided | |
def expectedSum = findProperty(expectedSumPropName) | |
if (expectedSum) { | |
def bundleFileName = gradle.liferayWorkspace.bundleUrl.substring(gradle.liferayWorkspace.bundleUrl.lastIndexOf('/') + 1) | |
def verifyBundle = tasks.register("verifyBundle${checksumAlgorithm}", Verify) { | |
src new File(gradle.liferayWorkspace.bundleCacheDir, bundleFileName) | |
algorithm checksumAlgorithm | |
checksum expectedSum | |
doFirst { | |
logger.info "[workspace-extra] Verifying checksum of the used bundle file '${src}', as found in the bundleCacheDir" | |
} | |
} | |
tasks.findByName('downloadBundle').configure { | |
finalizedBy verifyBundle | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires:
tasks.register
)