Skip to content

Commit

Permalink
Don't update first level dependencies of transitive projects
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielThomas committed Mar 2, 2017
1 parent 44711a5 commit ba92a27
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class DependencyLockReader {
locks = locks.collectEntries { configurationName, deps ->
[(configurationName): deps.findAll { coord, info ->
def notUpdate = !updates.contains(coord)
def notTransitive = info.transitive == null
def hasRequestedVersion = info.requested != null
notUpdate && notTransitive && hasRequestedVersion
def isFirstLevel = info.transitive == null && info.requested != null
def isFirstLevelTransitive = info.transitive.any { deps[it].project }
notUpdate && (isFirstLevel || isFirstLevelTransitive)
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,12 +1050,75 @@ class DependencyLockLauncherSpec extends IntegrationSpec {
)

when:
def results = runTasksSuccessfully('updateLock', '-PdependencyLock.updateDependencies=test.example:qux')
runTasksSuccessfully('updateLock', '-PdependencyLock.updateDependencies=test.example:qux')

then:
new File(projectDir, 'build/dependencies.lock').text == updatedLock
}

def 'project first level transitives are kept locked during update'() {
setupCommonMultiproject()
addSubproject('sub3', """\
dependencies {
compile project(':sub4')
}
""".stripIndent())

addSubproject('sub4', """\
dependencies {
compile project(':sub2')
}
""".stripIndent())
def lockFile = new File(new File(projectDir, 'sub3'), 'dependencies.lock')
def lockText = LockGenerator.duplicateIntoConfigs('''\
"test.example:foo": {
"locked": "1.0.0",
"transitive": [
"test:sub2"
],
"viaOverride": "1.0.0"
},
"test:sub2": {
"project": true,
"transitive": [
"test:sub4"
]
},
"test:sub4": {
"project": true
}
'''.stripIndent())

when:
runTasksSuccessfully('generateLock', 'saveLock', '-PdependencyLock.override=test.example:foo:1.0.0')

then:
lockFile.text == lockText

when:
runTasksSuccessfully('updateLock', 'saveLock', '-PdependencyLock.updateDependencies=test.example:qux')

then:
def updateLockText = LockGenerator.duplicateIntoConfigs('''\
"test.example:foo": {
"locked": "1.0.0",
"transitive": [
"test:sub2"
]
},
"test:sub2": {
"project": true,
"transitive": [
"test:sub4"
]
},
"test:sub4": {
"project": true
}
'''.stripIndent())
lockFile.text == updateLockText
}

def 'generateLock interacts well with resolution rules'() {
buildFile << """\
plugins {
Expand Down Expand Up @@ -1263,14 +1326,15 @@ class DependencyLockLauncherSpec extends IntegrationSpec {
allprojects {
${applyPlugin(DependencyLockPlugin)}
group = 'test'
dependencyLock {
includeTransitives = true
}
}
subprojects {
apply plugin: 'java'
repositories { maven { url '${Fixture.repo}' } }
}
dependencyLock {
includeTransitives = true
}
""".stripIndent()
}
}

0 comments on commit ba92a27

Please sign in to comment.