@@ -24,7 +24,17 @@ import org.kohsuke.github.GHIssueState.OPEN
2424import org.kohsuke.github.GitHub
2525import wooga.gradle.github.publish.PublishMethod.update
2626import wooga.gradle.github.publish.tasks.GithubPublish
27+ import java.awt.GraphicsEnvironment.isHeadless
28+ import java.util.concurrent.CompletableFuture
2729import javax.naming.ConfigurationException
30+ import javax.swing.JFrame
31+ import javax.swing.JOptionPane.DEFAULT_OPTION
32+ import javax.swing.JOptionPane.OK_OPTION
33+ import javax.swing.JOptionPane.QUESTION_MESSAGE
34+ import javax.swing.JOptionPane.showOptionDialog
35+ import javax.swing.JScrollPane
36+ import javax.swing.JTextArea
37+ import javax.swing.SwingUtilities
2838import kotlin.LazyThreadSafetyMode.NONE
2939
3040plugins {
@@ -236,13 +246,45 @@ val github by lazy(NONE) {
236246}
237247
238248val releaseBody by lazy(NONE ) {
239- grgit?.let {
249+ val releaseBody = grgit?.let {
240250 it.log {
241- github.getRepository(githubRepositoryName).latestRelease?.run { excludes.add(tagName) }
251+ github.getRepository(githubRepositoryName).latestRelease?.apply { excludes.add(tagName) }
252+ }.filter { commit ->
253+ ! commit.shortMessage.startsWith(" [Gradle Release Plugin] " )
254+ }.joinToString(" \n " ) { commit ->
255+ " - ${commit.shortMessage} [${commit.id} ]"
242256 }
243- .filter { ! it.shortMessage.startsWith(" [Gradle Release Plugin] " ) }
244- .joinToString(" \n " ) { " - ${it.shortMessage} [${it.id} ]" }
245257 } ? : " "
258+
259+ if (isHeadless()) {
260+ return @lazy releaseBody
261+ }
262+
263+ val result = CompletableFuture <String >()
264+
265+ SwingUtilities .invokeLater {
266+ val textArea = JTextArea (releaseBody)
267+
268+ val parentFrame = JFrame ().apply {
269+ isUndecorated = true
270+ setLocationRelativeTo(null )
271+ isVisible = true
272+ }
273+
274+ result.complete(try {
275+ when (showOptionDialog(
276+ parentFrame, JScrollPane (textArea), " Release Body" ,
277+ DEFAULT_OPTION , QUESTION_MESSAGE , null , null , null
278+ )) {
279+ OK_OPTION -> textArea.text!!
280+ else -> releaseBody
281+ }
282+ } finally {
283+ parentFrame.dispose()
284+ })
285+ }
286+
287+ result.join()!!
246288}
247289
248290tasks.withType<GithubPublish >().configureEach {
0 commit comments