As I’ve been overloading the forum all week with my hopefully decreasingly “newbie” questions, I am trying to implement plugin extensions for the nebula rpm plugin, via composition, as I’ve been urged to do.
I have a Task class in my plugin that extends com.netflix.gradle.plugins.rpm.Rpm
. Rpm IS-A Task.
I want this class to set certain default values.
After writing some debug code, I see that all these values reside under Task.inputs.properties
with a prefix of “exten”.:
exten.addParentDirs:null
exten.buildHost:null
exten.class:com.netflix.gradle.plugins.packaging.SystemPackagingExtension
exten.createDirectoryEntry:null
exten.distribution:null
exten.epoch:null
exten.fileType:null
exten.gid:null
exten.license:null
exten.maintainer:null
exten.multiArch:null
exten.os:null
exten.packageDescription:my app - file installer.
exten.packageGroup:null
exten.packageName:myapp
exten.packager:null
exten.permissionGroup:null
exten.priority:null
exten.release:null
The only values that are non-null are the ones I set in the build script that uses this plugin. Many of ones that are null, I want to set in my plugin.
So the question is, how?
Looking at the DSL documentation for Task I find that the inputs are read-only.
TaskInputs inputs (read-only)
the inputs of this task.
So again - what method allows me to set these in my Task-derived class?
The only example I have, from the rpm plugin itself, is, from what I have learned, something of an anti-pattern because it uses internal methods.
import org.gradle.api.internal.ConventionMapping
import org.gradle.api.internal.IConventionAware
...
ConventionMapping mapping = ((IConventionAware) this).getConventionMapping()
// Could come from extension
mapping.map('fileType', { parentExten?.getFileType() })
mapping.map('addParentDirs', { parentExten?.getAddParentDirs()?:true })
mapping.map('archStr', {
parentExten?.getArchStr()?:Architecture.NOARCH.name()
})
mapping.map('os', { parentExten?.getOs()?:Os.UNKNOWN})
mapping.map('type', { parentExten?.getType()?:RpmType.BINARY })
What is the right way for me to set these values in my class?
Update: I thought that maybe the Map might possible be read-only in terms of keys that could be added/removed but that value changes might be allowed, but this does not appear to be the case:
inputs.properties["exten.release"] = 'as'
and extern.release still shows up as null.