Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2022 18:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A confirmation Dialog From WIthin Gradle.
import javax.swing.JOptionPane
tasks.register("askConfirmation") {
doLast {
if (confirmation("Do you want to answer me?")) {
logger.lifecycle("😃 You Answered Yes!!!!")
} else {
logger.lifecycle("😒 You Answered No 🤷")
fun confirmation(msg: String = "Continue?"): Boolean {
return if (System.console() != null) {
"y".equals(System.console().readLine("$msg [y/n] : "), ignoreCase = true)
} else {
JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, msg, "Confirm operation", JOptionPane.YES_NO_OPTION)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment