Skip to content

Commit

Permalink
Merge pull request #424 from mricciuti/fix/issue-#246---addParentDirs…
Browse files Browse the repository at this point in the history
…-on-ospackage-is-not-propagated-to-tasks

issue 246 - addParentDirs on ospackage is not propagated to tasks
  • Loading branch information
DanielThomas authored Feb 5, 2024
2 parents 32bf1d5 + c2afb07 commit 7dc5643
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/groovy/com/netflix/gradle/plugins/rpm/Rpm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class Rpm extends SystemPackagingTask {

// Could come from extension
mapping.map('fileType', { parentExten?.getFileType() })
mapping.map('addParentDirs', { parentExten?.getAddParentDirs()?:true })
mapping.map('addParentDirs', {
// beware the Elvis operator in Groovy ...
parentExten?.getAddParentDirs() != null ? parentExten?.getAddParentDirs() : true
})
mapping.map('archStr', {
parentExten?.getArchStr()?:Architecture.NOARCH.name()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,38 @@ task buildRpm(type: Rpm) {
[ DIR, DIR] == scanFiles*.type
}
}

@Issue("https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/246")
def 'addParentDirs 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 {
addParentDirs false
}
task buildRpm(type: Rpm) {
packageName = 'sample'
from(${GradleUtils.quotedIfPresent(bananaFile.getParentFile().path)}) {
into '/usr/share/myproduct/etc'
}
}
"""
when:
runTasksSuccessfully('buildRpm')

then:
// Evaluate response
def scanFiles = Scanner.scan(file('build/distributions/sample-1.0.0.noarch.rpm')).files

['./usr/share/myproduct/etc/banana'] == scanFiles*.name
[ FILE] == scanFiles*.type
}
}

0 comments on commit 7dc5643

Please sign in to comment.