Skip to content

Commit

Permalink
Introduce deprecation logger to bypass Gradle 8.12 upcoming deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Dec 12, 2024
1 parent 8a98bc7 commit faceeb0
Show file tree
Hide file tree
Showing 20 changed files with 240 additions and 227 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.gradle.util.GradleVersion
plugins {
id 'com.netflix.nebula.plugin-plugin' version '21.2.1'
id 'com.netflix.nebula.optional-base' version '9.0.0'
id "org.jetbrains.kotlin.jvm" version "1.9.0"
id "org.jetbrains.kotlin.jvm" version "2.1.0"
id 'java-gradle-plugin'
id "org.gradle.test-retry" version "1.5.0"
}
Expand Down
29 changes: 7 additions & 22 deletions gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,29 @@ com.github.tomakehurst:wiremock:2.17.0=integTestCompileClasspath,integTestRuntim
com.google.guava:guava:20.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.googlecode.javaewah:JavaEWAH:1.1.12=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.jayway.jsonpath:json-path:2.4.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.jcraft:jsch.agentproxy.connector-factory:0.0.7=integTestRuntimeClasspath,testRuntimeClasspath
com.jcraft:jsch.agentproxy.core:0.0.7=integTestRuntimeClasspath,testRuntimeClasspath
com.jcraft:jsch.agentproxy.pageant:0.0.7=integTestRuntimeClasspath,testRuntimeClasspath
com.jcraft:jsch.agentproxy.sshagent:0.0.7=integTestRuntimeClasspath,testRuntimeClasspath
com.jcraft:jsch.agentproxy.svnkit-trilead-ssh2:0.0.7=integTestRuntimeClasspath,testRuntimeClasspath
com.jcraft:jsch.agentproxy.usocket-jna:0.0.7=integTestRuntimeClasspath,testRuntimeClasspath
com.jcraft:jsch.agentproxy.usocket-nc:0.0.7=integTestRuntimeClasspath,testRuntimeClasspath
com.jcraft:jzlib:1.1.2=integTestRuntimeClasspath,testRuntimeClasspath
com.netflix.nebula:gradle-contacts-plugin:7.0.1=integTestRuntimeClasspath,testRuntimeClasspath
com.netflix.nebula:gradle-info-plugin:12.1.4=integTestRuntimeClasspath,testRuntimeClasspath
com.netflix.nebula:gradle-info-plugin:13.1.0=integTestRuntimeClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-dependencies-comparison:0.2.1=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-gradle-interop:2.1.1=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-project-plugin:10.1.5=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-publishing-plugin:20.3.0=integTestRuntimeClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-test:10.5.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-gradle-interop:2.3.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-project-plugin:11.0.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-publishing-plugin:21.0.0=integTestRuntimeClasspath,testRuntimeClasspath
com.netflix.nebula:nebula-test:10.6.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
com.perforce:p4java:2015.2.1365273=integTestRuntimeClasspath,testRuntimeClasspath
com.squareup.moshi:moshi:1.12.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.squareup.okio:okio:2.10.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.trilead:trilead-ssh2:1.0.0-build220=integTestRuntimeClasspath,testRuntimeClasspath
commons-codec:commons-codec:1.10=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
commons-logging:commons-logging:1.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
de.regnis.q.sequence:sequence-library:1.0.3=integTestRuntimeClasspath,testRuntimeClasspath
javax.servlet:javax.servlet-api:3.1.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
joda-time:joda-time:2.10=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
junit:junit-dep:4.11=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
junit:junit:4.13.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.java.dev.jna:jna-platform:5.7.0=integTestRuntimeClasspath,testRuntimeClasspath
net.java.dev.jna:jna:5.7.0=integTestRuntimeClasspath,testRuntimeClasspath
net.java.dev.jna:platform:3.4.0=integTestRuntimeClasspath,testRuntimeClasspath
net.minidev:accessors-smart:1.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.minidev:json-smart:2.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
net.sf.jopt-simple:jopt-simple:5.0.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.ajoberstar.grgit:grgit-core:4.1.1=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.antlr:antlr-runtime:3.4=integTestRuntimeClasspath,testRuntimeClasspath
org.antlr:antlr4-runtime:4.5.1-1=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.commons:commons-lang3:3.12.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.httpcomponents:httpclient:4.5.5=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand All @@ -67,10 +56,8 @@ org.eclipse.jetty:jetty-xml:9.2.24.v20180105=integTestCompileClasspath,integTest
org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hamcrest:hamcrest-core:1.3=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hamcrest:hamcrest:2.2=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-common:1.9.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:1.9.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib-common:1.4.20=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains.kotlin:kotlin-stdlib:2.1.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.jetbrains:annotations:13.0=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.9.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.9.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand All @@ -81,8 +68,6 @@ org.ow2.asm:asm:5.0.4=integTestCompileClasspath,integTestRuntimeClasspath,testCo
org.slf4j:slf4j-api:1.7.30=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.spockframework:spock-core:2.3-groovy-3.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.spockframework:spock-junit4:2.3-groovy-3.0=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.tmatesoft.sqljet:sqljet:1.1.10=integTestRuntimeClasspath,testRuntimeClasspath
org.tmatesoft.svnkit:svnkit:1.8.12=integTestRuntimeClasspath,testRuntimeClasspath
org.xmlunit:xmlunit-core:2.5.1=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
org.xmlunit:xmlunit-legacy:2.5.1=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
empty=annotationProcessor,integTestAnnotationProcessor,testAnnotationProcessor
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.11.1-bin.zip
distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-8.12-20241210012659+0000-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.TaskProvider
import org.gradle.internal.deprecation.DeprecationLogger

import static nebula.plugin.dependencylock.tasks.GenerateLockTask.filterNonLockableConfigurationsAndProvideWarningsForGlobalLockSubproject
import static nebula.plugin.dependencylock.tasks.GenerateLockTask.lockableConfigurations
Expand Down Expand Up @@ -154,9 +155,12 @@ class DependencyLockTaskConfigurer {

saveLockTask.configure { saveTask ->
saveTask.doFirst {
SaveLockTask globalSave = project.rootProject.tasks.findByName(SAVE_GLOBAL_LOCK_TASK_NAME) as SaveLockTask
if (globalSave?.outputLock?.exists()) {
throw new GradleException('Cannot save individual locks when global lock is in place, run deleteGlobalLock task')
//TODO: address Invocation of Task.project at execution time has been deprecated.
DeprecationLogger.whileDisabled {
SaveLockTask globalSave = project.rootProject.tasks.findByName(SAVE_GLOBAL_LOCK_TASK_NAME) as SaveLockTask
if (globalSave?.outputLock?.exists()) {
throw new GradleException('Cannot save individual locks when global lock is in place, run deleteGlobalLock task')
}
}
}
saveTask.conventionMapping.with {
Expand Down Expand Up @@ -190,10 +194,13 @@ class DependencyLockTaskConfigurer {

globalSaveLockTask.configure { globalSaveTask ->
globalSaveTask.doFirst {
project.subprojects.each { Project sub ->
SaveLockTask save = sub.tasks.findByName(SAVE_LOCK_TASK_NAME) as SaveLockTask
if (save && save.outputLock?.exists()) {
throw new GradleException('Cannot save global lock, one or more individual locks are in place, run deleteLock task')
//TODO: address Invocation of Task.project at execution time has been deprecated.
DeprecationLogger.whileDisabled {
project.subprojects.each { Project sub ->
SaveLockTask save = sub.tasks.findByName(SAVE_LOCK_TASK_NAME) as SaveLockTask
if (save && save.outputLock?.exists()) {
throw new GradleException('Cannot save global lock, one or more individual locks are in place, run deleteLock task')
}
}
}
}
Expand Down Expand Up @@ -240,7 +247,10 @@ class DependencyLockTaskConfigurer {
globalLockTask.configure { globalGenerateTask ->
globalGenerateTask.notCompatibleWithConfigurationCache("Dependency locking plugin tasks require project access. Please consider using Gradle's dependency locking mechanism")
globalGenerateTask.doFirst {
project.subprojects.each { sub -> sub.repositories.each { repo -> project.repositories.add(repo) } }
//TODO: address Invocation of Task.project at execution time has been deprecated.
DeprecationLogger.whileDisabled {
project.subprojects.each { sub -> sub.repositories.each { repo -> project.repositories.add(repo) } }
}
}
globalGenerateTask.conventionMapping.with {
dependenciesLock = { getBuildDirGlobalLockFile(lockFilename, extension) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.internal.deprecation.DeprecationLogger
import org.gradle.work.DisableCachingByDefault

import java.nio.charset.StandardCharsets
Expand Down Expand Up @@ -42,23 +43,26 @@ class DiffLockTask extends AbstractLockTask {

@TaskAction
def diffLocks() {
ConfigurationsSet existingLock = readLocks(existingLockFile)
ConfigurationsSet newLock = readLocks(updatedLockFile)
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(project, diffByConfiguration)
outputDir.mkdirs()
diffFile.text = JsonOutput.prettyPrint(JsonOutput.toJson(lockDiff))
} else {
if (newLock.isEmpty()) {
//TODO: address Invocation of Task.project at execution time has been deprecated.
DeprecationLogger.whileDisabled {
ConfigurationsSet existingLock = readLocks(existingLockFile)
ConfigurationsSet newLock = readLocks(updatedLockFile)
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(project, diffByConfiguration)
outputDir.mkdirs()
diffFile.withPrintWriter(StandardCharsets.UTF_8.displayName()) { writer ->
writer.println('--no updated locks to diff--')
}
diffFile.text = JsonOutput.prettyPrint(JsonOutput.toJson(lockDiff))
} else {
List<DependencyDiff> diff = new DependenciesComparison().performDiff(existingLock, newLock)
writeDiff(diff)
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(diff)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import org.gradle.internal.deprecation.DeprecationLogger
import org.gradle.work.DisableCachingByDefault

@DisableCachingByDefault
class GenerateLockTask extends AbstractLockTask {
private String WRITE_CORE_LOCK_TASK_TO_RUN = "`./gradlew dependencies --write-locks`"
private String MIGRATE_TO_CORE_LOCK_TASK_NAME = "migrateToCoreLocks"
private static final Logger LOGGER = Logging.getLogger(GenerateLockTask)

@Internal
Expand Down Expand Up @@ -72,25 +71,31 @@ class GenerateLockTask extends AbstractLockTask {

@TaskAction
void lock() {
if (DependencyLockingFeatureFlags.isCoreLockingEnabled()) {
def dependencyLockExtension = project.extensions.findByType(DependencyLockExtension)
def globalLockFile = new File(project.projectDir, dependencyLockExtension.globalLockFile)
if (globalLockFile.exists()) {
throw new BuildCancelledException("Legacy global locks are not supported with core locking.\n" +
"Please remove global locks.\n" +
" - Global locks: ${globalLockFile.absolutePath}")
}
//TODO: address Invocation of Task.project at execution time has been deprecated.
DeprecationLogger.whileDisabled {
final String WRITE_CORE_LOCK_TASK_TO_RUN = "`./gradlew dependencies --write-locks`"
final String MIGRATE_TO_CORE_LOCK_TASK_NAME = "migrateToCoreLocks"
if (DependencyLockingFeatureFlags.isCoreLockingEnabled()) {
def dependencyLockExtension = project.extensions.findByType(DependencyLockExtension)
def globalLockFile = new File(project.projectDir, dependencyLockExtension.globalLockFile)
if (globalLockFile.exists()) {
throw new BuildCancelledException("Legacy global locks are not supported with core locking.\n" +
"Please remove global locks.\n" +
" - Global locks: ${globalLockFile.absolutePath}")
}

throw new BuildCancelledException("generateLock is not supported with core locking.\n" +
"Please use $WRITE_CORE_LOCK_TASK_TO_RUN\n" +
"or do a one-time migration with `./gradlew $MIGRATE_TO_CORE_LOCK_TASK_NAME` to preserve the current lock state")
}
if (DependencyLockTaskConfigurer.shouldIgnoreDependencyLock(project)) {
throw new DependencyLockException("Dependency locks cannot be generated. The plugin is disabled for this project (dependencyLock.ignore is set to true)")
throw new BuildCancelledException("generateLock is not supported with core locking.\n" +
"Please use $WRITE_CORE_LOCK_TASK_TO_RUN\n" +
"or do a one-time migration with `./gradlew $MIGRATE_TO_CORE_LOCK_TASK_NAME` to preserve the current lock state")
}
if (DependencyLockTaskConfigurer.shouldIgnoreDependencyLock(project)) {
throw new DependencyLockException("Dependency locks cannot be generated. The plugin is disabled for this project (dependencyLock.ignore is set to true)")
}
Collection<Configuration> confs = getConfigurations() ?: lockableConfigurations(project, project, getConfigurationNames(), getSkippedConfigurationNames())
Map dependencyMap = new GenerateLockFromConfigurations().lock(confs)
new DependencyLockWriter(getDependenciesLock(), getSkippedDependencies()).writeLock(dependencyMap)
}
Collection<Configuration> confs = getConfigurations() ?: lockableConfigurations(project, project, getConfigurationNames(), getSkippedConfigurationNames())
Map dependencyMap = new GenerateLockFromConfigurations().lock(confs)
new DependencyLockWriter(getDependenciesLock(), getSkippedDependencies()).writeLock(dependencyMap)

}

static Collection<Configuration> lockableConfigurations(Project taskProject, Project project, Set<String> configurationNames, Set<String> skippedConfigurationNamesPrefixes = []) {
Expand Down
Loading

0 comments on commit faceeb0

Please sign in to comment.