Skip to content

Commit 176fb8f

Browse files
committed
Add logging & reduce Github API calls
1 parent d03aa57 commit 176fb8f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

buildSrc/src/main/groovy/grails/doc/AddReleaseDropDown.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ abstract class AddReleaseDropDown extends DefaultTask {
8181
void addReleaseDropDown() {
8282
String projectVersion = version.get()
8383

84+
final Object result = listRepoTags("apache/grails-core")
85+
List<SoftwareVersion> softwareVersions = parseSoftwareVersions(result)
86+
logger.lifecycle("Detected Project Version: ${projectVersion} and Software Versions: ${softwareVersions*.versionText.join(',')}")
87+
8488
final String versionHtml = "<p><strong>Version:</strong> ${projectVersion}</p>"
8589
Path guideDirectory = docsDirectory.get().asFile.toPath()
8690
Path targetOutputDirectory = outputDir.get().asFile.toPath()
@@ -107,7 +111,7 @@ abstract class AddReleaseDropDown extends DefaultTask {
107111
if (filesToChange.containsKey(absolutePath)) {
108112
//Need to add the version dropdown
109113
String page = guideDirectory.toFile().relativePath(file.toFile())
110-
String selectHtml = select(options(projectVersion, page))
114+
String selectHtml = select(options(projectVersion, page, softwareVersions))
111115

112116
final String versionWithSelectHtml = "<p><strong>Version:</strong>&nbsp;<span style='width:100px;display:inline-block;'>${selectHtml}</span></p>"
113117
targetFile.toFile().text = file.text.replace(versionHtml, versionWithSelectHtml)
@@ -130,15 +134,15 @@ abstract class AddReleaseDropDown extends DefaultTask {
130134
*
131135
* @param version The current version of the documentation
132136
* @param page The page to add the dropdown to
137+
* @param softwareVersions The list of software versions to include in the dropdown
133138
* @return The list of options for the select tag
134139
*/
135-
private List<String> options(String version, String page) {
140+
private List<String> options(String version, String page, List<SoftwareVersion> softwareVersions) {
136141
List<String> options = []
137142
final String snapshotHref = GRAILS_DOC_BASE_URL + "/snapshot" + page
138143
options << option(snapshotHref, "SNAPSHOT", version.endsWith("-SNAPSHOT"))
139144

140-
final Object result = listRepoTags("apache/grails-core")
141-
parseSoftwareVersions(result)
145+
softwareVersions
142146
.forEach { softwareVersion ->
143147
final String versionName = softwareVersion.versionText
144148
final String href = GRAILS_DOC_BASE_URL + "/" + versionName + page

0 commit comments

Comments
 (0)