All Downloads are FREE. Search and download functionalities are using the official Maven repository.

grails.doc.dropdown.CreateReleaseDropDownTask.groovy Maven / Gradle / Ivy

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