Search for the script file, doesn't bother if it is named precisely. Tries in this order: - actual supplied name - name.groovy - name.gvy - name.gy - name.gsh @since 2.3.0
(String input)
| 530 | * @since 2.3.0 |
| 531 | */ |
| 532 | public static File searchForGroovyScriptFile(String input) { |
| 533 | String scriptFileName = input.trim(); |
| 534 | File scriptFile = new File(scriptFileName); |
| 535 | // TODO: Shouldn't these extensions be kept elsewhere? What about CompilerConfiguration? |
| 536 | // This method probably shouldn't be in GroovyMain either. |
| 537 | String[] standardExtensions = {".groovy",".gvy",".gy",".gsh"}; |
| 538 | int i = 0; |
| 539 | while (i < standardExtensions.length && !scriptFile.exists()) { |
| 540 | scriptFile = new File(scriptFileName + standardExtensions[i]); |
| 541 | i++; |
| 542 | } |
| 543 | // if we still haven't found the file, point back to the originally specified filename |
| 544 | if (!scriptFile.exists()) { |
| 545 | scriptFile = new File(scriptFileName); |
| 546 | } |
| 547 | return scriptFile; |
| 548 | } |
| 549 | |
| 550 | /** |
| 551 | * Hunt for the script file by calling searchForGroovyScriptFile(String). |
no test coverage detected