after reading code, correct the argument file to comply with ECJ's parser

This commit is contained in:
Uwe Schindler 2021-12-17 12:18:28 +01:00
parent 6941701c6d
commit db9dff225c
1 changed files with 5 additions and 2 deletions

View File

@ -65,12 +65,15 @@ allprojects {
// limits. We could pass a directory but ecj seems to be buggy: when it // limits. We could pass a directory but ecj seems to be buggy: when it
// encounters a module-info.java file it no longer compiles other source files. // encounters a module-info.java file it no longer compiles other source files.
def inputsFile = file("${tmpDst}/ecj-inputs.txt") def inputsFile = file("${tmpDst}/ecj-inputs.txt")
def escapeOption = { String s -> (s =~ /[ '"]/) ? ('"' + s.replaceAll(/[\\'"]/, /\\$0/) + '"') : s } // escape filename accoring to ECJ's rules:
// https://github.com/eclipse/aspectj.eclipse.jdt.core/blob/a05312e746b9bc2b48b4b039f6e7b5e061b5b393/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java#L1533-L1537
// Basically surround all whitespace by quotes:
def escapeFileName = { String s -> s.replaceAll(/ +/, /"$0"/) }
inputsFile.setText( inputsFile.setText(
srcDirs.collectMany { dir -> srcDirs.collectMany { dir ->
project.fileTree(dir: dir, include: "**/*.java" ).files project.fileTree(dir: dir, include: "**/*.java" ).files
} }
.collect {file -> escapeOption(file.absolutePath.toString())}.join("\n"), "UTF-8") .collect {file -> escapeFileName(file.absolutePath.toString())}.join("\n"), "UTF-8")
args += [ "-d", "none" ] args += [ "-d", "none" ]