From 661fb37770db8f7a93aba48bb5f37d6d783e92d1 Mon Sep 17 00:00:00 2001 From: Danny Thomas Date: Wed, 18 May 2016 16:11:54 -0700 Subject: [PATCH] Improve rule source logging --- .../plugin/resolutionrules/ResolutionRulesPluginSpec.groovy | 6 +++--- .../plugin/resolutionrules/ResolutionRulesPlugin.groovy | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/functionalTest/groovy/nebula/plugin/resolutionrules/ResolutionRulesPluginSpec.groovy b/src/functionalTest/groovy/nebula/plugin/resolutionrules/ResolutionRulesPluginSpec.groovy index be5ce83..855ebfe 100644 --- a/src/functionalTest/groovy/nebula/plugin/resolutionrules/ResolutionRulesPluginSpec.groovy +++ b/src/functionalTest/groovy/nebula/plugin/resolutionrules/ResolutionRulesPluginSpec.groovy @@ -188,9 +188,9 @@ class ResolutionRulesPluginSpec extends IntegrationSpec { def result = runTasksSuccessfully('dependencies') then: - [rulesJsonFile, rulesZipFile, rulesJarFile].each { - assert result.standardOutput.contains("Using ${it.absolutePath} as a dependency rules source") - } + result.standardOutput.contains 'Using all-rules-sources (all-rules-sources.json) a dependency rules source' + result.standardOutput.contains "Using all-rules-sources ($projectDir/rules.jar) a dependency rules source" + result.standardOutput.contains "Using all-rules-sources ($projectDir/rules.zip) a dependency rules source" } def 'replace module'() { diff --git a/src/main/groovy/nebula/plugin/resolutionrules/ResolutionRulesPlugin.groovy b/src/main/groovy/nebula/plugin/resolutionrules/ResolutionRulesPlugin.groovy index 54a7039..891b3b4 100644 --- a/src/main/groovy/nebula/plugin/resolutionrules/ResolutionRulesPlugin.groovy +++ b/src/main/groovy/nebula/plugin/resolutionrules/ResolutionRulesPlugin.groovy @@ -89,10 +89,8 @@ class ResolutionRulesPlugin implements Plugin { for (file in files) { if (isIncludedRuleFile(file.name, extension)) { ResolutionJsonValidator.validateJsonFile(file) - LOGGER.info("Using $file as a dependency rules source") rules.add(parseJsonFile(file)) } else if (file.name.endsWith(JAR_EXT) || file.name.endsWith(ZIP_EXT)) { - LOGGER.info("Using $file as a dependency rules source") ZipFile zip = new ZipFile(file) try { Enumeration entries = zip.entries() @@ -128,18 +126,20 @@ class ResolutionRulesPlugin implements Plugin { return false } - private static String ruleSet(String filename) { + static String ruleSet(String filename) { return filename.substring(0, filename.lastIndexOf(JSON_EXT)) } static Rules parseJsonFile(File file) { def ruleSet = ruleSet(file.name) + LOGGER.info("Using $ruleSet (${file.name}) a dependency rules source") rulesFromJson(ruleSet, new JsonSlurper().parse(file) as Map) } static Rules parseJsonStream(ZipFile zip, ZipEntry entry) { def stream = zip.getInputStream(entry) def ruleSet = ruleSet(new File(entry.name).name) + LOGGER.info("Using $ruleSet (${zip.name}) a dependency rules source") rulesFromJson(ruleSet, new JsonSlurper().parse(stream) as Map) }