jonnybot0 commented on code in PR #256:
URL: https://github.com/apache/groovy-geb/pull/256#discussion_r1943666692
##########
buildSrc/src/main/groovy/org/gebish/gradle/ManualsPlugin.groovy:
##########
@@ -56,21 +60,25 @@ class ManualsPlugin implements Plugin<Project> {
}
}
- private void configureGenerateConfigPropertiesTask(
- Project project, BaseExtension baseExtension, ManualsExtension
manualsExtension
- ) {
- def currentVersion = manualsExtension.includedManuals.map {
- baseExtension.isSnapshot() ? it.last() : project.version
+ 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 }
+ Map<String, String> model = [old: oldManuals, current:
currentVersion, snapshot: snapshot]
+ String template =
readFileContent(ext.indexTemplate.asFile.get())
+ String html = new
SimpleTemplateEngine().createTemplate(template).make(model).toString()
+ destinationFile.get().asFile.text = html
+ }
}
+ }
- project.tasks.register("generateConfigProperties", WriteProperties) {
- destinationFile =
project.layout.buildDirectory.file("config-properties/ratpack.properties")
-
- property("manuals.old", manualsExtension.includedManuals.map {
- (it - currentVersion.get()).reverse().join(",")
- })
- property("manuals.current", currentVersion)
- property("manuals.snapshot", baseExtension.isSnapshot() ?
project.version : '')
- }
+ private String readFileContent(File file) {
Review Comment:
Nit. Don't think this method is required? See commit
f843dbe406186813fcf57ac7c5a497e9f5b793a0 on my jonny-static-website-feedback
branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]