Skip to content

Commit

Permalink
Merge pull request #179 from nebula-plugins/core-lock-ignore-extra-lo…
Browse files Browse the repository at this point in the history
…ckfiles-until-regeneration

Core lock: ignore extra lockfiles until lock update or regeneration
  • Loading branch information
OdysseusLives committed Oct 23, 2019
2 parents 75ed2f1 + bf4163f commit de9144f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ class CoreLockingHelper {
}

private void removeLockfilesForUnlockedConfigurations() {
def migrationTaskWasRequested = project.gradle.startParameter.taskNames.contains(DependencyLockTaskConfigurer.MIGRATE_TO_CORE_LOCKS_TASK_NAME)
if (!shouldLockAllConfigurations && !migrationTaskWasRequested) {
boolean migrationTaskWasRequested = project.gradle.startParameter.taskNames.contains(DependencyLockTaskConfigurer.MIGRATE_TO_CORE_LOCKS_TASK_NAME)
boolean hasWriteLocksFlag = project.gradle.startParameter.isWriteDependencyLocks()
boolean hasDependenciesToUpdate = !project.gradle.startParameter.getLockedDependenciesToUpdate().isEmpty()
boolean isUpdatingDependencies = hasWriteLocksFlag || hasDependenciesToUpdate

if (!shouldLockAllConfigurations && !migrationTaskWasRequested && isUpdatingDependencies) {
project.gradle.taskGraph.whenReady { taskGraph ->
LinkedList tasks = taskGraph.executionPlan.executionQueue
Task lastTask = tasks.last?.task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ class DependencyLockPluginWithCoreSpec extends AbstractDependencyLockPluginSpec
!cleanBuildResults.output.contains('FAILURE')
}

def 'generate core lock should lock delete stale lockfiles when regenerating'() {
def 'generate core lock should ignore extra lockfiles and then delete stale lockfiles when regenerating'() {
given:
buildFile.text = """\
plugins {
Expand Down Expand Up @@ -786,6 +786,15 @@ class DependencyLockPluginWithCoreSpec extends AbstractDependencyLockPluginSpec
def lockFile = new File(projectDir, '/gradle/dependency-locks/customConfiguration.lockfile')
lockFile.exists()

when:
def buildResult = runTasks('clean', 'build')

then:
!buildResult.output.contains('FAIL')

def customConfigurationLockFile = new File(projectDir, '/gradle/dependency-locks/customConfiguration.lockfile')
assert customConfigurationLockFile.exists()

when:
runTasks('dependencies', '--write-locks')

Expand All @@ -798,11 +807,11 @@ class DependencyLockPluginWithCoreSpec extends AbstractDependencyLockPluginSpec
assert expectedLocks.contains(actual)
}

def customConfigurationLockFile = new File(projectDir, '/gradle/dependency-locks/customConfiguration.lockfile')
assert !customConfigurationLockFile.exists()
def customConfigurationLockFileAfterWriteLocks = new File(projectDir, '/gradle/dependency-locks/customConfiguration.lockfile')
assert !customConfigurationLockFileAfterWriteLocks.exists()
}

def 'generate core lock should lock delete stale lockfiles when regenerating - multiproject setup'() {
def 'generate core lock should ignore extra lockfiles and then delete stale lockfiles when regenerating - multiproject setup'() {
given:
definePluginOutsideOfPluginBlock = true
buildFile.text = """\
Expand Down Expand Up @@ -854,6 +863,15 @@ class DependencyLockPluginWithCoreSpec extends AbstractDependencyLockPluginSpec
def lockFile = new File(projectDir, 'sub1/gradle/dependency-locks/customConfiguration.lockfile')
lockFile.exists()

when:
def buildResult = runTasks('clean', 'build')

then:
!buildResult.output.contains('FAIL')

def customConfigurationLockFile = new File(projectDir, 'sub1/gradle/dependency-locks/customConfiguration.lockfile')
assert customConfigurationLockFile.exists()

when:
runTasks('dependenciesForAll', '--write-locks')

Expand All @@ -866,8 +884,8 @@ class DependencyLockPluginWithCoreSpec extends AbstractDependencyLockPluginSpec
assert expectedLocks.contains(actual)
}

def customConfigurationLockFile = new File(projectDir, 'sub1/gradle/dependency-locks/customConfiguration.lockfile')
assert !customConfigurationLockFile.exists()
def customConfigurationLockFileAfterWriteLocks = new File(projectDir, 'sub1/gradle/dependency-locks/customConfiguration.lockfile')
assert !customConfigurationLockFileAfterWriteLocks.exists()
}

@Unroll
Expand Down

0 comments on commit de9144f

Please sign in to comment.