ReadyTalk / gradle-projectinfo-plugin

[ARCHIVED]
3 stars 1 forks source link

Template-ize output file #3

Open sgoings opened 11 years ago

sgoings commented 11 years ago

After our conversation today on how to control the various styles of properties files people want (along with the flexibility of property naming) I realized one option might be to convert the handling of what the properties file looks like via template. That way we could have a straight Java properties file, but we could also generate other types of files (to be easily read in by other languages) as well.

We could provide a default style of properties file that could be extended, but offer users a great amount of flexibility by heading down this route.

For example:

Thoughts?

mgodwin commented 11 years ago

How would this work? You provide a template path? I really want to keep it customizable as much as humanly possible in the gradle file.

I think it'd be awesome to allow configuration via extension like so:

project-info {
  keys {
    projectName = "newProjectNameKey"
    branch = "newBranchKey"
  }
  additional-properties {
    buildOs = "OSX"
    compileDeps = configurations.compile.toString() 
    // Not really sure if we could define properties like this on a custom extension, 
    // since extensions just map the closure back to the object...
  }
}

Would something like that work? I think if this isn't doable a template is a good option, or allowing both is a good option.

Just for added clarity, the generated properties file would look like this then

REVISION=1212abcdefg
newProjectNameKey=theProjectName
newBranchKey=refs/heads/master
VERSION=1.0.0
buildOs=OSX
compileDeps=really long string...
sgoings commented 11 years ago

I like your direction.

I came across this plugin, which might give you some ideas too: https://github.com/hierynomus/license-gradle-plugin

Some things to consider with the design highlighted above: