Skip to content

Commit

Permalink
Merge pull request #224 from chali/FixConfigurationMerging
Browse files Browse the repository at this point in the history
Fix merging configuration with the same changes
  • Loading branch information
chali authored Nov 4, 2021
2 parents e0dec84 + 25c9503 commit e1a64a1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,15 @@ class PathAwareDiffReportGenerator : DiffReportGenerator {
other as DependencyPathElement

if (selected.id != other.selected.id) return false
if (children != other.children) return false

return true
}

override fun hashCode(): Int {
return selected.id.hashCode()
var result = selected.id.hashCode()
result = 31 * result + children.hashCode()
return result
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class PathAwareDependencyDiffSpec extends IntegrationTestKitSpec {
'test.example:transitive-consumer4:2.0.0 -> test.example:transitive-dependency:2.0.0',
'some.group:dependency:1.0.0',
'some.group:dependency:2.0.0',
'test.example:dependency1:1.0.0',
'test.example:dependency1:2.0.0',
'test.example:dependency2:1.0.0',
'test.example:dependency2:2.0.0',
]

def generator = new GradleDependencyGenerator(new DependencyGraph(myGraph))
Expand Down Expand Up @@ -859,4 +863,43 @@ class PathAwareDependencyDiffSpec extends IntegrationTestKitSpec {
common.change.description == "new local submodule"
common.change.type == "NEW"
}

def 'properly aggregate configurations with the same dependencies into report'() {
new File("${projectDir}/gradle.properties").text = "systemProp.nebula.features.pathAwareDependencyDiff=true"
def dependenciesLock = new File(projectDir, 'dependencies.lock')
buildFile << """\
plugins {
id 'nebula.dependency-lock'
}
apply plugin: 'java'
repositories {
maven { url '${repoDir.absolutePath}' }
}
dependencyLock {
includeTransitives = true
}
dependencies {
compileOnly 'test.example:dependency1:2.0.0'
runtimeOnly 'test.example:dependency2:2.0.0'
}
""".stripIndent()

when:
def result = runTasks('generateLock', 'diffLock')

then:
def lockdiff = new JsonSlurper().parse(new File(projectDir, 'build/dependency-lock/lockdiff.json'))
def directDependenciesCompileClasspath = lockdiff.find { it.configurations.contains("compileClasspath")} ["differentPaths"]
def direct1 = directDependenciesCompileClasspath.find { it.dependency == "test.example:dependency1"}
direct1.version == "2.0.0"
direct1.change.type == "NEW"

def directDependenciesRuntimeClasspath = lockdiff.find { it.configurations.contains("runtimeClasspath")} ["differentPaths"]
def direct2 = directDependenciesRuntimeClasspath.find { it.dependency == "test.example:dependency2"}
direct2.version == "2.0.0"
direct2.change.type == "NEW"
}
}

0 comments on commit e1a64a1

Please sign in to comment.