Skip to content

Commit

Permalink
Fix issue with version selector not being available when applying rej…
Browse files Browse the repository at this point in the history
…ect rule
  • Loading branch information
rpalcolea committed Sep 29, 2021
1 parent 4ff67e4 commit 39dbf35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class ResolutionRulesPluginSpec extends IntegrationSpec {
def result = runTasks('dependencies', '--configuration', 'compileClasspath')

then:
!result.standardError.contains("esolution rules could not resolve all dependencies to align configuration ':compileClasspath':\n" +
!result.standardError.contains("Resolution rules could not resolve all dependencies to align configuration ':compileClasspath':\n" +
" - com.google.guava:guava:19.0 -> com.google.guava:guava:19.0 - Could not find com.google.guava:guava:19.0")
}
}
7 changes: 1 addition & 6 deletions src/main/kotlin/nebula/plugin/resolutionrules/rules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,6 @@ data class RejectRule(
val moduleVersionId = module.toModuleVersionId()
@Transient lateinit var versionSelector: VersionSelector

init {
if (moduleVersionId.version.isNotEmpty()) {
versionSelector = VersionWithSelector(moduleVersionId.version).asSelector()
}
}

override fun apply(
project: Project,
configuration: Configuration,
Expand All @@ -259,6 +253,7 @@ data class RejectRules(val rules: List<RejectRule>) : Rule {
val candidate = selection.candidate
val rules = ruleByModuleIdentifier[candidate.moduleIdentifier] ?: return@all
rules.forEach { rule ->
rule.versionSelector = VersionWithSelector(rule.moduleVersionId.version).asSelector()
if (!rule.hasVersionSelector() || rule.versionSelector.accept(candidate.version)) {
val message = "rejected by rule ${rule.ruleSet} because '${rule.reason}'"
selection.reject(message)
Expand Down

0 comments on commit 39dbf35

Please sign in to comment.