diff --git a/build.gradle b/build.gradle index ff769f746151c..79fa16990580f 100644 --- a/build.gradle +++ b/build.gradle @@ -276,23 +276,34 @@ subprojects { // //this information allows us, at runtime, to determine what libraries/versions exist on a given classpath - MessageDigest md = MessageDigest.getInstance("MD5") - md.update(String.valueOf(project.group).getBytes("UTF-8")) - md.update(String.valueOf(project.name).getBytes("UTF-8")) - md.update(String.valueOf(project.version).getBytes("UTF-8")) - byte[] digest = md.digest() - String hash = DatatypeConverter.printHexBinary(digest).toUpperCase() - - String versioningFileName = "__Versioning__" + hash - String versioningPayload = "{" + - "\"format\":\"v1\"," + - "\"project\":\"" + rootProject.group + ":" + rootProject.name + ":" + rootProject.version + "\"," + - "\"module\":\"" + project.group + ":" + project.name + ":" + project.version + "\"" + - "}" - - String outFolder = "${project.buildDir}/resources/main/META-INF/" - mkdir outFolder - file("${outFolder}/${versioningFileName}").text = versioningPayload + String moduleVersion = String.valueOf(project.version) + String projectVersion = String.valueOf(rootProject.version) + + if ("unspecified" != projectVersion && "unspecified" != moduleVersion) { + MessageDigest md = MessageDigest.getInstance("MD5") + md.update(String.valueOf(project.group).getBytes("UTF-8")) + md.update(String.valueOf(project.name).getBytes("UTF-8")) + md.update(moduleVersion.getBytes("UTF-8")) + byte[] digest = md.digest() + String hash = DatatypeConverter.printHexBinary(digest).toUpperCase() + + String versioningFileName = "__Versioning__" + hash + String versioningPayload = "{" + + "\"format\":\"v1\"," + + "\"project\":\"" + rootProject.group + ":" + rootProject.name + ":" + projectVersion + "\"," + + "\"module\":\"" + project.group + ":" + project.name + ":" + moduleVersion + "\"" + + "}" + + String outFolder = "${project.buildDir}/resources/main/META-INF/" + mkdir outFolder + + fileTree(dir: outFolder, include:'__Versioning__*').each { + //remove any left-overs from previous builds + it.delete() + } + + file("${outFolder}/${versioningFileName}").text = versioningPayload + } } from "$rootDir/LICENSE"