diff --git a/.java-version b/.java-version new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +16 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da9702f..ffed3a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/scripts/includeLearningObjectives.gradle b/scripts/includeLearningObjectives.gradle index 76f8e23..e072584 100644 --- a/scripts/includeLearningObjectives.gradle +++ b/scripts/includeLearningObjectives.gradle @@ -6,12 +6,11 @@ class LearningObjective { int chapter int chapterIndex - LearningObjective(String id, String title, String chapter, String chapterIndex) { - this.id = id - this.title = title - this.chapter = Integer.valueOf(chapter) - this.chapterIndex = Integer.valueOf(chapterIndex) + this.id = id + this.title = title + this.chapter = Integer.valueOf(chapter) + this.chapterIndex = Integer.valueOf(chapterIndex) } } @@ -19,10 +18,6 @@ task includeLearningObjectives( description: 'collect learning objectives from source files and include them as listing', group: 'isaqb-curriculum' ) { - doFirst { - buildDir.mkdirs() - } - doLast { def contentDE = createLearningObjectivesContent("DE", ~/\[\[(LZ-\d*-\d*)\]\]\s*==== (LZ (\d*)-(\d*).*)/, "Verzeichnis der Lernziele") def contentEN = createLearningObjectivesContent("EN", ~/\[\[(LG-\d*-\d*)\]\]\s*==== (LG (\d*)-(\d*).*)/, "List of Learning Goals") @@ -41,63 +36,66 @@ task includeLearningObjectives( ext.collectLearningObjectives = { pattern -> def docsFolder = new File(projectDir, '/docs') def learningObjectives = [] + docsFolder.traverse(type: FILES) { file -> - if(file.name ==~ '.*[.](ad|adoc|asciidoc)$') { + + if (file.name ==~ '.*[.](ad|adoc|asciidoc)$') { def content = file.text def matcher = content =~ pattern - while(matcher) { - def id = matcher.group(1) - def title = matcher.group(2) - def chapter = matcher.group(3) - def chapterIndex = matcher.group(4) - learningObjectives.add( - new LearningObjective(id, title, chapter, chapterIndex)) + for (result in matcher.results()) { + + def id = result.group(1) + def title = result.group(2) + def chapter = result.group(3) + def chapterIndex = result.group(4) + learningObjectives.add(new LearningObjective(id, title, chapter, chapterIndex)) } } } return learningObjectives } +} - ext.sortLearningObjectives = { learningObjectives -> - learningObjectives.sort { a, b -> - if(a.chapter == b.chapter) { - a.chapterIndex <=> b.chapterIndex - } else { - a.chapter <=> b.chapter - } +ext.sortLearningObjectives = { learningObjectives -> + learningObjectives.sort { a, b -> + if (a.chapter == b.chapter) { + a.chapterIndex <=> b.chapterIndex + } else { + a.chapter <=> b.chapter } } +} - ext.compileLearningObjectives = { language, headline, learningObjectives -> - def content = ''<<'' +ext.compileLearningObjectives = { language, headline, learningObjectives -> + def content = '' << '' - content <<= "// tag::" + language + "[]\n" - content <<= "== " + headline + "\n\n" + content <<= "// tag::" + language + "[]\n" + content <<= "== " + headline + "\n\n" - learningObjectives.each { learningObjective -> - content <<= "- <<" + learningObjective.id + ", " + learningObjective.title + ">>\n" - } + learningObjectives.each { learningObjective -> + content <<= "- <<" + learningObjective.id + ", " + learningObjective.title + ">>\n" + } - content <<= "// end::" + language + "[]\n" + content <<= "// end::" + language + "[]\n" - return content.toString() - } + return content.toString() +} - ext.writeLearningObjectives = { contentDE, contentEN -> - def docsFolder = new File(projectDir, '/docs') - def outFile = new File(docsFolder, '/learning-objectives.adoc') +ext.writeLearningObjectives = { contentDE, contentEN -> + def docsFolder = new File(projectDir, '/docs') + def outFile = new File(docsFolder, '/learning-objectives.adoc') - println "Learning objectives file: " + outFile.getAbsolutePath() + println "Learning objectives file: " + outFile.getAbsolutePath() - final String EMPTYRemark = """// tag::REMARK[]\n// end::REMARK[]\n""" + final String EMPTYRemark = """// tag::REMARK[]\n// end::REMARK[]\n""" - outFile.withWriter('UTF-8') { writer -> - writer.writeLine("// this is autogenerated - please do not modify manually!\n") - writer.writeLine(contentDE) - writer.writeLine(contentEN) - writer.writeLine(EMPTYRemark) - } + outFile.withWriter('UTF-8') { writer -> + writer.writeLine("// this is autogenerated - please do not modify manually!\n") + writer.writeLine(contentDE) + writer.writeLine(contentEN) + writer.writeLine(EMPTYRemark) } } +