Skip to content

Commit

Permalink
revert breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Dec 6, 2023
1 parent 96aa623 commit cc17566
Show file tree
Hide file tree
Showing 33 changed files with 1,028 additions and 931 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.gradle.util.GradleVersion

plugins {
id 'com.netflix.nebula.plugin-plugin' version '20.10.0'
id 'com.netflix.nebula.plugin-plugin' version '20.8.1'
id 'com.netflix.nebula.optional-base' version '9.0.0'
id "org.jetbrains.kotlin.jvm" version "1.9.0"
id 'java-gradle-plugin'
Expand Down Expand Up @@ -88,8 +88,7 @@ tasks.named('compileKotlin') {

test.dependsOn jar

tasks.withType(Test).configureEach {
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
tasks.withType(Test) {
testLogging {
events "PASSED", "FAILED", "SKIPPED"
afterSuite { desc, result ->
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-rc-3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package nebula.plugin.dependencylock

import nebula.plugin.dependencylock.tasks.GenerateLockTask
import nebula.plugin.dependencylock.utils.ConfigurationFilters
import nebula.plugin.dependencylock.utils.ConfigurationUtils
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging

Expand Down Expand Up @@ -69,7 +69,7 @@ class ConfigurationsToLockFinder {

private Collection<String> gatherLockableConfigurationNames(Collection<String> configurationNames, Collection<String> gatheredConfigurations) {
def lockableConfigurationNames = []
def lockableConfigurations = ConfigurationUtils.lockableConfigurations(project, configurationNames as Set)
def lockableConfigurations = GenerateLockTask.lockableConfigurations(project, project, configurationNames as Set)
lockableConfigurations.each {
lockableConfigurationNames.add(it.name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,18 @@
*/
package nebula.plugin.dependencylock

import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty

abstract class DependencyLockExtension {
DependencyLockExtension() {
lockFile.convention('dependencies.lock')
globalLockFile.convention('global.lock')
configurationNames.convention([])
updateDependencies.convention([])
includeTransitives.convention(false)
lockAfterEvaluating.convention(true)
updateDependenciesFailOnInvalidCoordinates.convention(true)
updateDependenciesFailOnSimultaneousTaskUsage.convention(true)
updateDependenciesFailOnNonSpecifiedDependenciesToUpdate.convention(true)
additionalConfigurationsToLock.convention([])
}

abstract Property<String> getLockFile()
abstract Property<String> getGlobalLockFile()
abstract SetProperty<String> getConfigurationNames()
abstract SetProperty<String> getUpdateDependencies()
abstract Property<Boolean> getIncludeTransitives()
abstract Property<Boolean> getLockAfterEvaluating()
abstract Property<Boolean> getUpdateDependenciesFailOnInvalidCoordinates()
abstract Property<Boolean> getUpdateDependenciesFailOnSimultaneousTaskUsage()
abstract Property<Boolean> getUpdateDependenciesFailOnNonSpecifiedDependenciesToUpdate()
abstract SetProperty<String> getAdditionalConfigurationsToLock()

Set<String> skippedDependencies = [] as Set

class DependencyLockExtension {
String lockFile = 'dependencies.lock'
String globalLockFile = 'global.lock'
Set<String> configurationNames = [] as Set
Set<String> skippedConfigurationNamesPrefixes = [] as Set

Closure dependencyFilter = { String group, String name, String version -> true }
Set<String> updateDependencies = [] as Set
Set<String> skippedDependencies = [] as Set
boolean includeTransitives = false
boolean lockAfterEvaluating = true
boolean updateDependenciesFailOnInvalidCoordinates = true
boolean updateDependenciesFailOnSimultaneousTaskUsage = true
boolean updateDependenciesFailOnNonSpecifiedDependenciesToUpdate = true
Set<String> additionalConfigurationsToLock = [] as Set
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package nebula.plugin.dependencylock.diff

import org.gradle.api.Project
import nebula.dependencies.comparison.DependencyDiff
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ConfigurationContainer

interface DiffReportGenerator {
List<Map<String, Object>> generateDiffReport(Collection<Configuration> configurations, Map<String, List<DependencyDiff>> diffsByConfiguration)
List<Map<String, Object>> generateDiffReport(Project project, Map<String, List<DependencyDiff>> diffsByConfiguration)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ package nebula.plugin.dependencylock.tasks


import org.gradle.api.DefaultTask
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.work.DisableCachingByDefault

Expand All @@ -30,12 +29,9 @@ abstract class AbstractMigrateToCoreLocksTask extends DefaultTask {
String group = 'Locking'

@OutputFile
abstract Property<File> getOutputLock()
File outputLock

@Input
abstract SetProperty<String> getConfigurationNames()

@Input
abstract Property<Boolean> getIsCoreLockingEnabled()
Set<String> configurationNames

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import groovy.json.JsonSlurper
import nebula.dependencies.comparison.*
import nebula.plugin.dependencylock.diff.DiffReportGenerator
import nebula.plugin.dependencylock.utils.DependencyLockingFeatureFlags
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
Expand All @@ -25,54 +18,52 @@ import org.gradle.work.DisableCachingByDefault
import java.nio.charset.StandardCharsets

@DisableCachingByDefault
abstract class DiffLockTask extends AbstractLockTask {
class DiffLockTask extends AbstractLockTask {
@Internal
String description = 'Diff existing lock and generated lock file'

@InputFile
@Optional
@PathSensitive(PathSensitivity.NONE)
abstract Property<File> getExistingLockFile()
File existingLockFile

@Internal
abstract Property<File> getUpdatedLockFile()
File updatedLockFile

@OutputFile
abstract Property<File> getOutputFile()
@OutputDirectory
File outputDir = new File(project.layout.buildDirectory.getAsFile().get(), "dependency-lock")

@Input
abstract Property<Boolean> getIsPathAwareDependencyDiffEnabled()
@OutputFile
File diffFile = new File(outputDir, "lockdiff.${this.diffFileExtension()}")

@Internal
Collection<Configuration> configurations = []
private String diffFileExtension() {
DependencyLockingFeatureFlags.isPathAwareDependencyDiffEnabled() ? "json" : "txt"
}

@TaskAction
def diffLocks() {
ConfigurationsSet existingLock = readLocks(existingLockFile)
ConfigurationsSet newLock = readLocks(updatedLockFile)
File diffFile = outputFile.get()
if (isPathAwareDependencyDiffEnabled.isPresent() && isPathAwareDependencyDiffEnabled.get()) {
if (DependencyLockingFeatureFlags.isPathAwareDependencyDiffEnabled()) {
Map<String, List<DependencyDiff>> diffByConfiguration = new DependenciesComparison().performDiffByConfiguration(existingLock, newLock)
DiffReportGenerator generator = Class.forName("nebula.plugin.dependencylock.diff.PathAwareDiffReportGenerator").newInstance() as DiffReportGenerator
def lockDiff = generator.generateDiffReport(configurations, diffByConfiguration)
def lockDiff = generator.generateDiffReport(project, diffByConfiguration)
outputDir.mkdirs()
diffFile.text = JsonOutput.prettyPrint(JsonOutput.toJson(lockDiff))
} else {
if (newLock.isEmpty()) {
outputDir.mkdirs()
diffFile.withPrintWriter(StandardCharsets.UTF_8.displayName()) { writer ->
writer.println('--no updated locks to diff--')
}
} else {
List<DependencyDiff> diff = new DependenciesComparison().performDiff(existingLock, newLock)
writeDiff(diffFile, diff)
writeDiff(diff)
}
}
}

ConfigurationsSet readLocks(Provider<File> fileProvider) {
if(!fileProvider.isPresent()) {
return new ConfigurationsSet([:])
}
File file = fileProvider.get()
ConfigurationsSet readLocks(File file) {
if (!(file?.exists())) {
return new ConfigurationsSet([:])
}
Expand All @@ -87,7 +78,9 @@ abstract class DiffLockTask extends AbstractLockTask {
return new ConfigurationsSet(lock)
}

void writeDiff(File diffFile, List<DependencyDiff> diff) {
void writeDiff(List<DependencyDiff> diff) {
outputDir.mkdirs()

diffFile.withPrintWriter(StandardCharsets.UTF_8.displayName()) { writer ->
def newDeps = diff.findAll { it.isNew() }
if (!newDeps.isEmpty()) {
Expand Down
Loading

0 comments on commit cc17566

Please sign in to comment.