Skip to content

Commit 518ffe9

Browse files
committed
Prevent align rules from trying to align project dependencies. Adding a version causes Gradle to attempt to resolve an artifact
1 parent 7a26d08 commit 518ffe9

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
1.3.0 / 2016/04/28
22
==================
3+
- BUGFIX: Align rules attempt to align project dependencies, causing them to be resolved as remote artifacts
34
- Rules files may now be optional, so optionated rules aren't applied without users opting in
45
- Align rules support regular expressions in the group, includes and excludes
56
- Empty rules types can be excluded from rules files (required for backwards compatibility with old rules files, but also makes working with them nicer)

src/functionalTest/groovy/nebula/plugin/resolutionrules/AlignRulesMultiprojectSpec.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ class AlignRulesMultiprojectSpec extends IntegrationSpec {
9494
def results = runTasksSuccessfully(':b:dependencies', '--configuration', 'compile')
9595

9696
then:
97-
noExceptionThrown()
97+
results.standardOutput.contains("""compile - Dependencies for source set 'main'.
98+
\\--- project :a
99+
""")
98100
}
99101

100102
def 'cycle like behavior'() {

src/main/groovy/nebula/plugin/resolutionrules/Rules.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import org.gradle.api.Project
1919
import org.gradle.api.artifacts.*
2020
import org.gradle.api.artifacts.component.ComponentSelector
2121
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
22+
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
2223
import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.DefaultVersionComparator
2324
import org.gradle.api.specs.Specs
2425
import org.joda.time.DateTime
@@ -215,7 +216,7 @@ class AlignRules implements ProjectConfigurationRule {
215216

216217
def copy = configuration.copyRecursive()
217218
copy.exclude group: project.group, module: project.name
218-
def artifacts
219+
Set<ResolvedArtifact> artifacts
219220
def resolvedConfiguration = copy.resolvedConfiguration
220221
if (resolvedConfiguration.hasError()) {
221222
def lenientConfiguration = resolvedConfiguration.lenientConfiguration
@@ -225,7 +226,10 @@ class AlignRules implements ProjectConfigurationRule {
225226
artifacts = resolvedConfiguration.resolvedArtifacts
226227
}
227228

228-
def moduleVersions = artifacts.collect { it.moduleVersion }
229+
def moduleVersions = artifacts.findAll {
230+
// Exclude project artifacts from alignment
231+
!(it.id.componentIdentifier instanceof ProjectComponentIdentifier)
232+
}.collect { it.moduleVersion }
229233
def selectedVersion = [:]
230234
aligns.each { AlignRule align ->
231235
if (align.shouldNotBeSkipped(extension)) {

0 commit comments

Comments
 (0)