Skip to content

Commit f64f07d

Browse files
carltonwhiteheadevant
authored andcommitted
Fix the build on Windows
The project had been failing to build on my Windows PC with the following rather cryptic exception: Caused by: java.lang.StringIndexOutOfBoundsException: begin 324, end -1, length 5122 I tracked this down to use of hard-coded Unix-style line separator "\n" in TemplateTask.kt. Using the system's line separator corrected the problem. I don't think this is likely to have any impact on non-Windows builds, as these templates are evidently dependent on the build platform, but releases already work on Windows, and clearly the build infrastructure is not Windows.
1 parent 6c30b14 commit f64f07d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

buildSrc/src/main/kotlin/TemplateTask.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ abstract class TemplateTask : DefaultTask() {
6161

6262
@TaskAction
6363
fun run() {
64+
val lineSeparator = System.lineSeparator()
6465
val inDir = inputDir.get().asFile
6566
val outDir = outputDir.get().asFile
6667

@@ -72,7 +73,7 @@ abstract class TemplateTask : DefaultTask() {
7273
val content = template.readText()
7374

7475
val tokensStart = content.indexOf('$')
75-
val tokensStop = content.indexOf("\n\n", startIndex = tokensStart)
76+
val tokensStop = content.indexOf("$lineSeparator$lineSeparator", startIndex = tokensStart)
7677
val tokenLine = content.substring(tokensStart until tokensStop)
7778
val tokens = tokenLine.substringBefore('=').split(':').cleanup()
7879
val replacements = tokenLine.substringAfter('=')

0 commit comments

Comments
 (0)