task generateSpringVisualizer {
def templateFile = file("gradle/templates/SpringVisualizer.java.template")
def outputDir = file("${buildDir}/generated/sources/visualizer/java/com/yourpackage")
def outputFile = file("${outputDir}/SpringVisualizer.java")
inputs.file(templateFile)
outputs.file(outputFile)
doLast {
outputDir.mkdirs()
// 1. Read the file as raw bytes to avoid Groovy's line-ending "normalization"
byte[] bytes = templateFile.readBytes()
String rawContent = new String(bytes, "UTF-8")
// 2. Perform the replacement
// We use a literal String replacement to avoid regex engine line-wrapping
String fixedContent = rawContent.replace('${packageName}', "com.yourpackage")
// 3. Write back using a BufferedOutputStream for literal byte-for-byte output
outputFile.withOutputStream { out ->
out.write(fixedContent.getBytes("UTF-8"))
}
println ">>> Byte-for-byte generation complete. No line splitting possible."
}
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)