Skip to content

Commit

Permalink
Merge pull request #114 from isaqb-org/109-update-gradle-72
Browse files Browse the repository at this point in the history
Update Gradle to 7.2
  • Loading branch information
programming-wolf authored Aug 20, 2021
2 parents 457f2ea + 1521d7c commit e0c4f6b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
88 changes: 43 additions & 45 deletions scripts/includeLearningObjectives.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,18 @@ 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)
}
}

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")
Expand All @@ -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)
}
}

0 comments on commit e0c4f6b

Please sign in to comment.