Skip to content

Commit

Permalink
fix issue 416 - merge directories from extension to task configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mricciuti committed Oct 29, 2022
1 parent ec2344f commit 46803a2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ abstract class AbstractPackagingCopyAction<T extends SystemPackagingTask> implem
addProvides(provides)
}

task.directories.each { directory ->
for (Directory directory: task.getAllDirectories()) {
logger.debug "adding directory {}", directory.path
addDirectory(directory)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ abstract class SystemPackagingTask extends AbstractArchiveTask {
}
}

@Input
@Optional
List<Directory> getAllDirectories() {
if (parentExten) {
return getDirectories() + parentExten.getDirectories()
} else {
return getDirectories()
}
}

@Override
abstract AbstractPackagingCopyAction createCopyAction()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 46803a2

Please sign in to comment.