jongyoul / gradle-slack-plugin

Slack plugin for Gradle
Apache License 2.0
10 stars 4 forks source link

Use lazy-evaluation for message properties #9

Open ysb33r opened 4 years ago

ysb33r commented 4 years ago

You should allow for the elements in Message to be lazy-evaluated. This allows evolving state to be included. For instance you can rewrite Message.channel to be

void setChannel(Object o) {
    this.channel = o
}

String getChannel() {
   StringUtils.stringize(this.channel)
}

private Object channel

IN this way plugin authors can for instance select the channel dependent on the result

slack {
   message {
      channel = { -> tasks.getByName('build').state.failure ? '#failed_build; : '#passed_build' }
   }
} 

You can get the StringUtils.stringize method from the Grolifant library (https://ysb33rOrg.gitlab.io/grolifant)

jongyoul commented 4 years ago

Sounds great for the lazy evaluation. I like this idea. I'll consider it.