From 7a4c16ab02cd946bacfae1ae863d266b892cd9c2 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Wed, 18 Dec 2024 09:18:21 +0100 Subject: [PATCH 1/2] Fix Gradle 8.12 deprecation warning - We should not reference project from task execution phase --- .../groovy/com/netflix/gradle/plugins/deb/Deb.groovy | 12 +++++++++--- .../netflix/gradle/plugins/deb/DebCopyAction.groovy | 4 ++-- .../plugins/docker/SystemPackageDockerfile.groovy | 7 ++++++- .../plugins/packaging/SystemPackagingTask.groovy | 8 ++++++-- .../groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy | 8 ++++++-- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy b/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy index b7ede4de..37e07bc0 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy @@ -20,6 +20,8 @@ import com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction import com.netflix.gradle.plugins.packaging.Dependency import com.netflix.gradle.plugins.packaging.SystemPackagingTask import com.netflix.gradle.plugins.utils.DeprecationLoggerUtils +import org.gradle.api.Project +import org.gradle.api.file.ProjectLayout import org.gradle.api.internal.ConventionMapping import org.gradle.api.internal.IConventionAware import org.gradle.api.tasks.Input @@ -27,11 +29,15 @@ import org.gradle.api.tasks.Optional import org.gradle.api.tasks.OutputFile import org.gradle.work.DisableCachingByDefault +import javax.inject.Inject + @DisableCachingByDefault class Deb extends SystemPackagingTask { - Deb() { - super() + + @Inject + Deb(ProjectLayout projectLayout) { + super(projectLayout) archiveExtension.set 'deb' notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache") } @@ -51,7 +57,7 @@ class Deb extends SystemPackagingTask { @Override AbstractPackagingCopyAction createCopyAction() { - return new DebCopyAction(this) + return new DebCopyAction(this, new File(projectLayout.buildDirectory.getAsFile().get(), "debian")) } @Override diff --git a/src/main/groovy/com/netflix/gradle/plugins/deb/DebCopyAction.groovy b/src/main/groovy/com/netflix/gradle/plugins/deb/DebCopyAction.groovy index 4ddc7794..c6256647 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/deb/DebCopyAction.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/deb/DebCopyAction.groovy @@ -68,7 +68,7 @@ class DebCopyAction extends AbstractPackagingCopyAction { private final MaintainerScriptsGenerator maintainerScriptsGenerator private final InstallLineGenerator installLineGenerator - DebCopyAction(Deb debTask) { + DebCopyAction(Deb debTask, File debianDir) { super(debTask) debTaskPropertiesValidator.validate(debTask) dependencies = [] @@ -82,7 +82,7 @@ class DebCopyAction extends AbstractPackagingCopyAction { dataProducers = [] installDirs = [] provides = [] - debianDir = new File(task.project.layout.buildDirectory.getAsFile().get(), "debian") + this.debianDir = debianDir debFileVisitorStrategy = new DebFileVisitorStrategy(dataProducers, installDirs) maintainerScriptsGenerator = new MaintainerScriptsGenerator(debTask, new TemplateHelper(debianDir, '/deb'), debianDir, new ApacheCommonsFileSystemActions()) installLineGenerator = new InstallLineGenerator() diff --git a/src/main/groovy/com/netflix/gradle/plugins/docker/SystemPackageDockerfile.groovy b/src/main/groovy/com/netflix/gradle/plugins/docker/SystemPackageDockerfile.groovy index f59000b7..79c7389c 100644 --- a/src/main/groovy/com/netflix/gradle/plugins/docker/SystemPackageDockerfile.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/docker/SystemPackageDockerfile.groovy @@ -2,15 +2,20 @@ package com.netflix.gradle.plugins.docker import com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction import com.netflix.gradle.plugins.packaging.SystemPackagingTask +import org.gradle.api.file.ProjectLayout import org.gradle.tooling.model.UnsupportedMethodException import org.gradle.work.DisableCachingByDefault +import javax.inject.Inject + @DisableCachingByDefault class SystemPackageDockerfile extends SystemPackagingTask { private final DockerfileInstructionManager dockerfileInstructionManager private static final ARCHIVE_NAME = 'Dockerfile' - SystemPackageDockerfile() { + @Inject + SystemPackageDockerfile(ProjectLayout projectLayout) { + super(projectLayout) dockerfileInstructionManager = new DockerfileInstructionManager() } diff --git a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy index 03c2f9bb..d356580f 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy @@ -20,6 +20,7 @@ import com.netflix.gradle.plugins.utils.DeprecationLoggerUtils import groovy.transform.CompileDynamic import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.file.FileCollection +import org.gradle.api.file.ProjectLayout import org.gradle.api.file.RegularFile import org.gradle.api.internal.ConventionMapping import org.gradle.api.internal.IConventionAware @@ -50,11 +51,14 @@ abstract class SystemPackagingTask extends OsPackageAbstractArchiveTask { @Internal ProjectPackagingExtension parentExten + @Internal + ProjectLayout projectLayout + // TODO Add conventions to pull from extension - SystemPackagingTask() { + SystemPackagingTask(ProjectLayout projectLayout) { super() exten = new SystemPackagingExtension() - + this.projectLayout = projectLayout // I have no idea where Project came from parentExten = project.extensions.findByType(ProjectPackagingExtension) if (parentExten) { diff --git a/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy b/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy index aa38d714..77cf6f9c 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy @@ -19,6 +19,7 @@ package com.netflix.gradle.plugins.rpm import com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction import com.netflix.gradle.plugins.packaging.SystemPackagingTask import com.netflix.gradle.plugins.utils.DeprecationLoggerUtils +import org.gradle.api.file.ProjectLayout import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.Optional import org.gradle.api.tasks.PathSensitive @@ -30,6 +31,8 @@ import org.redline_rpm.header.RpmType import org.gradle.api.internal.ConventionMapping import org.gradle.api.internal.IConventionAware +import javax.inject.Inject + @DisableCachingByDefault class Rpm extends SystemPackagingTask { @InputFile @@ -37,8 +40,9 @@ class Rpm extends SystemPackagingTask { @PathSensitive(PathSensitivity.NONE) File changeLogFile - Rpm() { - super() + @Inject + Rpm(ProjectLayout projectLayout) { + super(projectLayout) archiveExtension.set 'rpm' notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache") } From 19d88d6b793502d4a36a302d996d5621935e67ac Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Wed, 18 Dec 2024 10:01:29 +0100 Subject: [PATCH 2/2] Update Deb.groovy --- src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy b/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy index 37e07bc0..5b912e48 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy @@ -20,7 +20,6 @@ import com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction import com.netflix.gradle.plugins.packaging.Dependency import com.netflix.gradle.plugins.packaging.SystemPackagingTask import com.netflix.gradle.plugins.utils.DeprecationLoggerUtils -import org.gradle.api.Project import org.gradle.api.file.ProjectLayout import org.gradle.api.internal.ConventionMapping import org.gradle.api.internal.IConventionAware @@ -31,7 +30,6 @@ import org.gradle.work.DisableCachingByDefault import javax.inject.Inject - @DisableCachingByDefault class Deb extends SystemPackagingTask {