From 46803a29059f200e349474c6bdba9606adc174e0 Mon Sep 17 00:00:00 2001 From: mricciuti Date: Sat, 29 Oct 2022 12:48:58 +0200 Subject: [PATCH] fix issue 416 - merge directories from extension to task configuration --- .../AbstractPackagingCopyAction.groovy | 2 +- .../packaging/SystemPackagingTask.groovy | 10 ++++++ .../rpm/RpmPluginIntegrationTest.groovy | 31 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/netflix/gradle/plugins/packaging/AbstractPackagingCopyAction.groovy b/src/main/groovy/com/netflix/gradle/plugins/packaging/AbstractPackagingCopyAction.groovy index 2a5c3e1c..142402c6 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/AbstractPackagingCopyAction.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/AbstractPackagingCopyAction.groovy @@ -107,7 +107,7 @@ abstract class AbstractPackagingCopyAction implem addProvides(provides) } - task.directories.each { directory -> + for (Directory directory: task.getAllDirectories()) { logger.debug "adding directory {}", directory.path addDirectory(directory) } 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 68e5abce..baaa9690 100755 --- a/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy +++ b/src/main/groovy/com/netflix/gradle/plugins/packaging/SystemPackagingTask.groovy @@ -323,6 +323,16 @@ abstract class SystemPackagingTask extends AbstractArchiveTask { } } + @Input + @Optional + List getAllDirectories() { + if (parentExten) { + return getDirectories() + parentExten.getDirectories() + } else { + return getDirectories() + } + } + @Override abstract AbstractPackagingCopyAction createCopyAction() diff --git a/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy b/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy index f1e902a6..9f0bfc2a 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy @@ -346,4 +346,35 @@ task buildRpm(type: Rpm) { def symlink = scan.files.find { it.name == './lib/bin/my-symlink' } symlink.header.type == SYMLINK } + + @Issue("https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/416") + def 'directory entries in ospackage extension propagates to rpm and deb'() { + given: + File bananaFile = new File(projectDir, 'test/banana') + FileUtils.forceMkdirParent(bananaFile) + bananaFile.text = 'banana' + + buildFile << """ +apply plugin: 'com.netflix.nebula.rpm' +apply plugin: 'com.netflix.nebula.ospackage-base' +version = '1.0.0' + +ospackage { + directory('/usr/share/myproduct/from-extension') +} +task buildRpm(type: Rpm) { + packageName = 'sample' + directory('/usr/share/myproduct/from-task') +} +""" + when: + runTasksSuccessfully('buildRpm') + + then: + // Evaluate response + def scanFiles = Scanner.scan(file('build/distributions/sample-1.0.0.noarch.rpm')).files + + ['./usr/share/myproduct/from-extension', './usr/share/myproduct/from-task'] == scanFiles*.name + [ DIR, DIR] == scanFiles*.type + } }