Skip to content

Commit

Permalink
Fix Gradle 8.12 deprecation warning
Browse files Browse the repository at this point in the history
- We should not reference project from task execution phase
  • Loading branch information
breskeby committed Dec 18, 2024
1 parent e2a56d6 commit 7a4c16a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
12 changes: 9 additions & 3 deletions src/main/groovy/com/netflix/gradle/plugins/deb/Deb.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ 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
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")
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class DebCopyAction extends AbstractPackagingCopyAction<Deb> {
private final MaintainerScriptsGenerator maintainerScriptsGenerator
private final InstallLineGenerator installLineGenerator

DebCopyAction(Deb debTask) {
DebCopyAction(Deb debTask, File debianDir) {
super(debTask)
debTaskPropertiesValidator.validate(debTask)
dependencies = []
Expand All @@ -82,7 +82,7 @@ class DebCopyAction extends AbstractPackagingCopyAction<Deb> {
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,15 +31,18 @@ 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
@Optional
@PathSensitive(PathSensitivity.NONE)
File changeLogFile

Rpm() {
super()
@Inject
Rpm(ProjectLayout projectLayout) {
super(projectLayout)
archiveExtension.set 'rpm'
notCompatibleWithConfigurationCache("nebula.ospackage does not support configuration cache")
}
Expand Down

0 comments on commit 7a4c16a

Please # to comment.