Skip to content

Commit

Permalink
use sed entirely with regex to get the java major version (#1544)
Browse files Browse the repository at this point in the history
Closes #1543
  • Loading branch information
rawilder committed Jul 21, 2022
1 parent b882d09 commit e379b33
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -33,6 +33,7 @@ The callback function provided as parameter to the format function is now called
* When a glob is specified then ensure that it matches files in the current directory and not only in subdirectories of the current directory ([#1533](https://github.com/pinterest/ktlint/issue/1533)).
* Disable/enable IndentationRule on blocks in middle of file. (`indent`) [#631](https://github.com/pinterest/ktlint/issues/631)
* Allow usage of letters with diacritics in enum values and filenames (`enum-entry-name-case`, `filename`) ([#1530](https://github.com/pinterest/ktlint/issue/1530)).
* Fix resolving of Java version when JAVA_TOOL_OPTIONS is set ([#1543](https://github.com/pinterest/ktlint/issues/1543))

### Changed

Expand Down
2 changes: 1 addition & 1 deletion ktlint/build.gradle.kts
Expand Up @@ -61,7 +61,7 @@ val shadowJarExecutable by tasks.registering(DefaultTask::class) {
// Then if that java version is >= 16, we add the --add-opens command
// X = X=$( [ "$JV" -ge "16" ] && echo "--add-opens java.base/java.lang=ALL-UNNAMED" || echo "")
// exec java $X -Xmx512m -jar "$0" "$@"
execFile.appendText("#!/bin/sh\n\nJV=\$(java -version 2>&1 | head -1 | cut -d'\"' -f2 | sed '/^1\\./s///' | cut -d'.' -f1)\n\nX=\$( [ \"\$JV\" -ge \"16\" ] && echo \"--add-opens java.base/java.lang=ALL-UNNAMED\" || echo \"\")\n\nexec java \$X -Xmx512m -jar \"\$0\" \"\$@\"\n\n")
execFile.appendText("#!/bin/sh\n\nJV=\$(java -version 2>&1 | sed -E -n 's/.* version \"([^.-]*).*\".*/\\1/p')\n\nX=\$( [ \"\$JV\" -ge \"16\" ] && echo \"--add-opens java.base/java.lang=ALL-UNNAMED\" || echo \"\")\n\nexec java \$X -Xmx512m -jar \"\$0\" \"\$@\"\n\n")
execFile.appendBytes(inputs.files.singleFile.readBytes())
execFile.setExecutable(true, false)
if (!version.toString().endsWith("SNAPSHOT")) {
Expand Down

0 comments on commit e379b33

Please sign in to comment.