From 98455c18d3bc413bf832e60f6c4cadba134f51ca Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Thu, 10 Jun 2021 15:24:53 +0200 Subject: [PATCH] Make SystemPackagingTask archive file config gradle 7 compatible --- .../packaging/SystemPackagingTask.groovy | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) 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 eae38b60..3e600e95 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy @@ -21,6 +21,7 @@ import groovy.transform.CompileDynamic import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.file.FileCollection import org.gradle.api.file.RegularFile +import org.gradle.api.file.RegularFileProperty import org.gradle.api.internal.ConventionMapping import org.gradle.api.internal.IConventionAware import org.gradle.api.internal.file.copy.CopyAction @@ -29,9 +30,12 @@ import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.Provider import org.gradle.api.tasks.* import org.gradle.api.tasks.bundling.AbstractArchiveTask +import org.gradle.util.GradleVersion import org.redline_rpm.header.Architecture import org.gradle.api.provider.Property +import java.util.concurrent.Callable + abstract class SystemPackagingTask extends AbstractArchiveTask { private static final String HOST_NAME = getLocalHostName() @@ -76,11 +80,10 @@ abstract class SystemPackagingTask extends AbstractArchiveTask { protected void applyConventions() { // For all mappings, we're only being called if it wasn't explicitly set on the task. In which case, we'll want // to pull from the parentExten. And only then would we fallback on some other value. + ConventionMapping mapping = ((IConventionAware) this).getConventionMapping() DeprecationLoggerUtils.whileDisabled { - - // Could come from extension mapping.map('packageName', { // BasePlugin defaults this to pluginConvention.getArchivesBaseName(), which in turns comes form project.name @@ -121,10 +124,25 @@ abstract class SystemPackagingTask extends AbstractArchiveTask { mapping.map('postUninstallFile', { parentExten?.getPostUninstallFile() }) // Task Specific - mapping.map('archiveName', { assembleArchiveName() }) - mapping.map('archivePath', { determineArchivePath() }) - mapping.map('archiveFile', { determineArchiveFile() }) - mapping.map('archiveVersion', { determineArchiveVersion() }) + if(GradleVersion.current().compareTo(GradleVersion.version("7.0.0")) >= 0) { + getArchiveFileName().convention(project.provider(new Callable() { + @Override + String call() throws Exception { + return assembleArchiveName(); + } + })) + getArchiveVersion().convention(project.provider(new Callable() { + @Override + String call() throws Exception { + return determineArchiveVersion(); + } + })) + } else { + mapping.map('archiveFile', { determineArchiveFile() }) + mapping.map('archiveName', { assembleArchiveName() }) + mapping.map('archivePath', { determineArchivePath() }) + mapping.map('archiveVersion', { determineArchiveVersion() }) + } } }