@@ -29,6 +29,7 @@ import org.apache.commons.text.StringEscapeUtils
29
29
import org.apache.tools.ant.filters.ReplaceTokens
30
30
31
31
import javax.swing.*
32
+ import java.awt.*
32
33
33
34
sourceCompatibility = targetCompatibility = JavaVersion . VERSION_1_8
34
35
@@ -73,43 +74,49 @@ processResources {
73
74
}
74
75
}
75
76
76
- ext. readInfoFile = { String name ->
77
- // @formatter:off
78
- return file(name). text
77
+ ext {
78
+ readInfoFile = { String name ->
79
+ // @formatter:off
80
+ return file(name). text
79
81
// Remove unnecessary whitespace
80
82
.trim()
81
83
82
84
// Replace headlines
83
- .replaceAll(' (\\ n|^)##(.*)(\\ n|$)' , { matcher -> " ${ matcher[1]} <b>${ matcher[2]} </b>${ matcher[3]} " })
85
+ .replaceAll(' (\r ? \n |^)##(.*)(\r ? \n |$)' , { matcher -> " ${ matcher[1]} <b>${ matcher[2]} </b>${ matcher[3]} " })
84
86
85
87
// Replace issue links
86
88
.replaceAll(' \\ [([^\\ []+)\\ ]\\ (([^\\ )]+)\\ )' , { matcher -> " <a href=\" ${ matcher[2]} \" >${ matcher[1]} </a>" })
87
89
.replaceAll(' \\ (#([0-9]+)\\ )' , { matcher -> " (<a href=\" ${ github} /issues/${ matcher[1]} \" >#${ matcher[1]} </a>)" })
88
90
89
91
// Replace inner lists
90
- .replaceAll(" \n - (.*)" , { matcher -> " <li>${ matcher[1]} </li>" })
92
+ .replaceAll(" \r ? \ n - (.*)" , { matcher -> " <li>${ matcher[1]} </li>" })
91
93
.replaceAll(" ((?:<li>.*</li>)+)" , { matcher -> " <ul>${ matcher[1]} </ul>" })
92
94
93
95
// Replace lists
94
- .replaceAll(" \n - (.*)" , { matcher -> " <li>${ matcher[1]} </li>" })
96
+ .replaceAll(" \r ? \ n - (.*)" , { matcher -> " <li>${ matcher[1]} </li>" })
95
97
.replaceAll(" ((?:<li>.*</li>)+)" , { matcher -> " <ul>${ matcher[1]} </ul>" })
96
98
.replaceAll(' \\ s*<li>\\ s*' , ' <li>' )
97
99
.replaceAll(' \\ s*</li>\\ s*' , ' </li>' )
98
100
.replaceAll(' \\ s*<ul>\\ s*' , ' <ul>' )
99
101
.replaceAll(' \\ s*</ul>\\ s*' , ' </ul>' )
100
102
101
103
// Replace newlines
102
- .replace(' \n ' , ' <br>' )
104
+ .replace(' \r ? \ n' , ' <br>' )
103
105
// @formatter:on
104
- }
106
+ }
107
+
108
+ showHtml = { String html ->
109
+ JFrame frame = new JFrame (" Changelog" )
110
+ frame. defaultCloseOperation = JFrame . DISPOSE_ON_CLOSE
111
+ frame. contentPane = new JScrollPane (new JLabel (' <html>' + html))
112
+ Dimension screenSize = Toolkit . defaultToolkit. screenSize
113
+ frame. preferredSize = new Dimension ((screenSize. width / 2).intValue(), (screenSize.height / 2 ). intValue())
114
+ frame. location = new Point ((screenSize. width / 4).intValue(), (screenSize.height / 4 ). intValue())
115
+ frame. alwaysOnTop = true
116
+ frame. pack()
117
+ frame. visible = true
118
+ }
105
119
106
- project. ext. showHtml = { String html ->
107
- JFrame frame = new JFrame (" Changelog" )
108
- frame. defaultCloseOperation = JFrame . DISPOSE_ON_CLOSE
109
- frame. contentPane. add(new JLabel (' <html>' + html))
110
- frame. alwaysOnTop = true
111
- frame. pack()
112
- frame. visible = true
113
120
}
114
121
115
122
tasks. create(name : ' showChangelog' ) {
0 commit comments