I am hitting another Scenario. So i am updating this thread…
lets say I have 3 tasks: Email_Scripts, Email_Images, Email_Songs each send different files as part of attachment.
I also got 1 task Email_Files which will send all files.
A Customer invoking
gradle Email_Scripts, Email_Images, Email_Songs
will end up in sending 3 emails.
Instead when all these tasks merge, I need to replace it with Email_Files automatically to send a single email instead of 3.
task Create_Email // create an email domain object
task Email_Scripts { // add scripts to the active email
dependsOn createEmail
finalizedBy "Email_Files"
}
task Email_Images { // add images to the active email
dependsOn createEmail
finalizedBy "Email_Files"
}
task Email_Songs { // add songs to the active email
dependsOn createEmail
finalizedBy "Email_Files"
}
task Email_Files // this task actually sends the email
Then someone who runs gradle Email_Scripts Email_Images Email_Songs would send a single email.
Tasks replacing one another would be very surprising to a user. There are probably other ways to do what you’re trying to do without causing this confusion.
Thanks Sterling for Quick reply.
I went through your code.
I see you create 2 tasks (createEmail, Email_Files) that set the Stage and are exposed to PluginUsers.
and other 3 tasks fill the body (3 actionable tasks) . I have to Tutor my plugin users to follow the workflow step by step. Don’t Execute create_email task. it does nothing but set stage. Don’t execute email_files task. it just does final activity of sending but doesn’t add files.
Instead:
In my inputs I am looking for Email_Files as an alternative to all 3 tasks.
So there are 4 only actionable tasks and no Staging tasks.
OK, I misunderstood what ‘Email_Files’ meant. You can just add another task (one that creates the email, one that sends it, one that adds everything and the others that add a subset of things).
task Create_Email // create an email domain object
task Email_Scripts { // add scripts to the active email
dependsOn createEmail
finalizedBy "Email_Files"
}
task Email_Images { // add images to the active email
dependsOn createEmail
finalizedBy "Email_Files"
}
task Email_Songs { // add songs to the active email
dependsOn createEmail
finalizedBy "Email_Files"
}
task Send_Email // this task actually sends the email
task Email_Files {
dependsOn Email_Scripts, Email_Images, Email_Songs
}
If you don’t assign a group to a task, it won’t show up in gradle tasks without someone specifically looking for it.
You don’t absolutely have to have a Create_Email and Send_Email. You could do this through some other means (e.g., always create the email domain object and send the email in buildFinished).