refactor(merge,split,json): adopt streaming approach and standardize types, address gradle warnings (#5803)

Co-authored-by: Anthony Stirling <[email protected]>
Co-authored-by: Balázs <[email protected]>
This commit is contained in:
Balázs Szücs
2026-03-02 21:55:07 +00:00
committed by GitHub
co-authored by Anthony Stirling Balázs
parent 0c46f77179
commit fd1b7abc83
66 changed files with 1425 additions and 1430 deletions
+29 -38
View File
@@ -85,49 +85,40 @@ allprojects {
}
}
def writeIfChanged(File targetFile, String newContent) {
if (targetFile.getText('UTF-8') != newContent) {
targetFile.write(newContent, 'UTF-8')
}
}
def updateTauriConfigVersion(String version) {
File tauriConfig = file('frontend/src-tauri/tauri.conf.json')
def parsed = new JsonSlurper().parse(tauriConfig)
parsed.version = version
def formatted = JsonOutput.prettyPrint(JsonOutput.toJson(parsed)) + System.lineSeparator()
writeIfChanged(tauriConfig, formatted)
}
def updateSimulationVersion(File fileToUpdate, String version) {
def content = fileToUpdate.getText('UTF-8')
def matcher = content =~ /(appVersion:\s*')([^']*)(')/
if (!matcher.find()) {
throw new GradleException("Could not locate appVersion in ${fileToUpdate} for synchronization")
}
def updatedContent = matcher.replaceFirst("${matcher.group(1)}${version}${matcher.group(3)}")
writeIfChanged(fileToUpdate, updatedContent)
}
def rootProjectRef = project
def appVersionStr = project.version.toString()
def tauriConfigPath = layout.projectDirectory.file('frontend/src-tauri/tauri.conf.json').asFile.path
def sim1Path = layout.projectDirectory.file('frontend/src/core/testing/serverExperienceSimulations.ts').asFile.path
def sim2Path = layout.projectDirectory.file('frontend/src/proprietary/testing/serverExperienceSimulations.ts').asFile.path
tasks.register('syncAppVersion') {
group = 'versioning'
description = 'Synchronizes app version across desktop and simulation configs.'
doLast {
def appVersion = rootProjectRef.version.toString()
println "Synchronizing application version to ${appVersion}"
updateTauriConfigVersion(appVersion)
println "Synchronizing application version to ${appVersionStr}"
[
'frontend/src/core/testing/serverExperienceSimulations.ts',
'frontend/src/proprietary/testing/serverExperienceSimulations.ts'
].each { path ->
updateSimulationVersion(file(path), appVersion)
def tauriConfigFile = new File(tauriConfigPath)
if (tauriConfigFile.exists()) {
def parsed = new groovy.json.JsonSlurper().parse(tauriConfigFile)
parsed.version = appVersionStr
def formatted = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(parsed)) + System.lineSeparator()
if (tauriConfigFile.getText('UTF-8') != formatted) {
tauriConfigFile.write(formatted, 'UTF-8')
}
}
[new File(sim1Path), new File(sim2Path)].each { f ->
if (f.exists()) {
def content = f.getText('UTF-8')
def matcher = (content =~ /(appVersion:\s*')([^']*)(')/)
if (!matcher.find()) {
throw new GradleException("Could not locate appVersion in ${f} for synchronization")
}
def updatedContent = matcher.replaceFirst("${matcher.group(1)}${appVersionStr}${matcher.group(3)}")
if (content != updatedContent) {
f.write(updatedContent, 'UTF-8')
}
}
}
}
}
@@ -279,7 +270,7 @@ subprojects {
}
def thresholds = [
LINE : 0.16,
LINE : 0.13,
INSTRUCTION: 0.14,
BRANCH : 0.09
]
@@ -372,7 +363,7 @@ subprojects {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.16
minimum = 0.13
}
// Verzweigungen (if/else, switch) abgedeckt; misst Logik-Abdeckung
limit {