Merge pull request #15226 from rjernst/fix_update_shas

Fix updateShas to not barf on disabled license checks and even compile correctly
This commit is contained in:
Ryan Ernst 2015-12-03 23:34:33 -08:00
commit 4b1fc8ff22
2 changed files with 4 additions and 3 deletions

View File

@ -69,7 +69,7 @@ import java.util.regex.Pattern
* </pre>
*/
public class DependencyLicensesTask extends DefaultTask {
private static final String SHA_EXTENSION = '.sha1'
static final String SHA_EXTENSION = '.sha1'
// TODO: we should be able to default this to eg compile deps, but we need to move the licenses
// check from distribution to core (ie this should only be run on java projects)

View File

@ -35,6 +35,7 @@ public class UpdateShasTask extends DefaultTask {
public UpdateShasTask() {
description = 'Updates the sha files for the dependencyLicenses check'
onlyIf { parentTask.licensesDir.exists() }
}
@TaskAction
@ -42,13 +43,13 @@ public class UpdateShasTask extends DefaultTask {
Set<File> shaFiles = new HashSet<File>()
parentTask.licensesDir.eachFile {
String name = it.getName()
if (name.endsWith(SHA_EXTENSION)) {
if (name.endsWith(DependencyLicensesTask.SHA_EXTENSION)) {
shaFiles.add(it)
}
}
for (File dependency : parentTask.dependencies) {
String jarName = dependency.getName()
File shaFile = new File(parentTask.licensesDir, jarName + SHA_EXTENSION)
File shaFile = new File(parentTask.licensesDir, jarName + DependencyLicensesTask.SHA_EXTENSION)
if (shaFile.exists() == false) {
logger.lifecycle("Adding sha for ${jarName}")
String sha = MessageDigest.getInstance("SHA-1").digest(dependency.getBytes()).encodeHex().toString()