Skip to content

Commit

Permalink
Fix the build on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
carltonwhitehead authored and evant committed Aug 24, 2023
1 parent 6c30b14 commit f64f07d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/TemplateTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ abstract class TemplateTask : DefaultTask() {

@TaskAction
fun run() {
val lineSeparator = System.lineSeparator()
val inDir = inputDir.get().asFile
val outDir = outputDir.get().asFile

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

val tokensStart = content.indexOf('$')
val tokensStop = content.indexOf("\n\n", startIndex = tokensStart)
val tokensStop = content.indexOf("$lineSeparator$lineSeparator", startIndex = tokensStart)
val tokenLine = content.substring(tokensStart until tokensStop)
val tokens = tokenLine.substringBefore('=').split(':').cleanup()
val replacements = tokenLine.substringAfter('=')
Expand Down

0 comments on commit f64f07d

Please sign in to comment.