Skip to content

Commit

Permalink
Fix java.version parsing (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiiches committed Mar 23, 2021
1 parent 89a082c commit 51b08b1
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ internal class JDepsGenerator @Inject constructor(
* from reporting the version in the `1.x.y_z` format (e.g. `1.8.0_202`) in favor of `x.y.z` (e.g.
* `11.0.1`). As a result, this function checks for a major version of "1" and if it's so, use the
* minor version as the major one. Otherwise, it uses the first term as the major version.
*
* Also note that the java.version does not include trailing zero elements.
*/
private fun String.majorJavaVersion(): Int {
val (major, minor) = this.trim().split('.')
val elements = this.trim().split('.')
val major = elements[0]
val parsedMajor = Integer.parseInt(major)
return if (parsedMajor == 1) Integer.parseInt(minor) else parsedMajor
if (parsedMajor != 1)
return parsedMajor
return Integer.parseInt(elements[1])
}

0 comments on commit 51b08b1

Please sign in to comment.