in buildSrc/src/main/groovy/org/gebish/gradle/ManualsPlugin.groovy [60:80]
private void configureIndexTask(Project project) {
project.tasks.register("generateIndex", WriteProperties) {
destinationFile = project.layout.buildDirectory.file("index.html")
doLast {
def baseExtension = project.extensions.getByType(BaseExtension)
def ext = project.extensions.getByName("manuals")
List<String> includedManuals = ext.includedManuals.get()
String currentVersion = baseExtension.isSnapshot() ? includedManuals.last() : project.version
String snapshot = baseExtension.isSnapshot() ? project.version : ''
List<String> oldManuals = includedManuals.findAll { v -> v != currentVersion }
.collect { v -> SoftwareVersion.of(v)}
.sort()
.reverse()
.collect { sv -> sv.toString()}
Map<String, String> model = [old: oldManuals, current: currentVersion, snapshot: snapshot]
String template = ext.indexTemplate.asFile.get().text
String html = new SimpleTemplateEngine().createTemplate(template).make(model).toString()
destinationFile.get().asFile.text = html
}
}
}