@@ -107,7 +107,6 @@ class ResolutionRulesPlugin : Plugin<Project> {
107107 return @configureEach
108108 }
109109
110- var dependencyRulesApplied = false
111110 project.onExecute {
112111 val ruleSet = extension.ruleSet()
113112 when {
@@ -122,7 +121,6 @@ class ResolutionRulesPlugin : Plugin<Project> {
122121 ruleSet.dependencyRulesPartTwo().forEach { rule ->
123122 rule.apply (project, config, config.resolutionStrategy, extension)
124123 }
125- dependencyRulesApplied = true
126124 }
127125 }
128126 }
@@ -150,7 +148,11 @@ class ResolutionRulesPlugin : Plugin<Project> {
150148abstract class NebulaResolutionRulesService : BuildService <NebulaResolutionRulesService .Params > {
151149 companion object {
152150 private val Logger : Logger = Logging .getLogger(NebulaResolutionRulesService ::class .java)
153- private val Mapper = objectMapper()
151+ private val Mapper = objectMapper
152+
153+ private const val JSON_EXTENSION = " json"
154+ private const val JAR_EXTENSION = " jar"
155+ private const val ZIP_EXTENSION = " zip"
154156
155157 fun registerService (project : Project ): Provider <NebulaResolutionRulesService > {
156158 return project.gradle.sharedServices.registerIfAbsent(
@@ -167,18 +169,18 @@ abstract class NebulaResolutionRulesService : BuildService<NebulaResolutionRules
167169 configuration.incoming.files.files.stream().use { stream ->
168170 return stream.flatMap { file ->
169171 when (file.extension) {
170- " json " -> {
172+ JSON_EXTENSION -> {
171173 Logger .debug(" nebula.resolution-rules uses: {}" , file.name)
172174 Stream .of(file.absolutePath to file.readBytes())
173175 }
174- " jar " , " zip " -> {
176+ JAR_EXTENSION , ZIP_EXTENSION -> {
175177 Logger .info(" nebula.resolution-rules is using ruleset: {}" , file.name)
176178 val zipFile = ZipFile (file)
177179 Collections .list(zipFile.entries()).stream()
178180 .onClose(zipFile::close)
179181 .flatMap { entry ->
180182 val entryFile = File (entry.name)
181- if (entryFile.extension == " json " ) {
183+ if (entryFile.extension == JSON_EXTENSION ) {
182184 Stream .of(" ${file.absolutePath} !${entry.name} " to zipFile.getInputStream(entry).readBytes())
183185 } else Stream .empty()
184186 }
@@ -190,7 +192,7 @@ abstract class NebulaResolutionRulesService : BuildService<NebulaResolutionRules
190192 }
191193 }.parallel()
192194 .map { (path, bytes) ->
193- val filePath = if ( path.contains( " ! " )) path.substringAfter( " ! " ) else path
195+ val filePath = path.substringAfterLast( ' ! ' , path)
194196 val file = File (filePath)
195197 val ruleSetName = file.nameWithoutExtension
196198 Logger .debug(" Using {} ({}) a dependency rules source" , ruleSetName, path)
0 commit comments