grails.doc.dropdown.CreateReleaseDropDownTask.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grails-docs Show documentation
Show all versions of grails-docs Show documentation
Grails Web Application Framework
The newest version!
package grails.doc.dropdown
import groovy.json.JsonSlurper
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
@CompileStatic
class CreateReleasesDropdownTask extends DefaultTask {
@Input
String slug
@Input
String version
@OutputFile
File guide
@OutputFile
File index
@TaskAction
void modifyHtmlAndAddReleasesDropdown() {
String selectHtml = composeSelectHtml()
String versionHtml = "Version: ${version}
"
String versionWithSelectHtml = "Version: ${selectHtml}
"
guide.text = guide.text.replace(versionHtml, versionWithSelectHtml)
index.text = index.text.replace(versionHtml, versionWithSelectHtml)
}
String composeSelectHtml() {
String repo = slug.split('/')[1]
String org = slug.split('/')[0]
JsonSlurper slurper = new JsonSlurper()
String json = new URL("https://api.github.com/repos/${slug}/tags").text
def result = slurper.parseText(json)
String selectHtml = "'
selectHtml
}
@CompileDynamic
List parseSoftwareVersions(Object result) {
result.findAll { it.name.startsWith('v') }.collect { SoftwareVersion.build(it.name.replace('v', '')) }.sort().unique().reverse()
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy