Skip to content

Instantly share code, notes, and snippets.

Created December 2, 2020 10:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Verify bundle checksum in Liferay Workspace
// 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:
'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 { "[workspace-extra] Verifying checksum of the used bundle file '${src}', as found in the bundleCacheDir"
tasks.findByName('downloadBundle').configure {
finalizedBy verifyBundle
Copy link

sustacek commented Dec 2, 2020


  • Gradle 5.x (because of tasks.register)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment