Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit fd36409

Browse files
committed
Merge branch 'develop'
2 parents 46b1f67 + ff6a649 commit fd36409

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
ChangeLog
22
---------
33

4+
### v3.0.1 (2018-03-10)
5+
* Bugfix: remove build number from JVM version number when creating comparable version number or extracting major version (fixes #61)
6+
47
### v3.0.0 (2018-02-25)
58
* Completeley overhauled algorithm for JVM detection (JRE and JDK)
69
* JDK has no longer precedence over JRE

src/universalJavaApplicationStub

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# #
1212
# @author Tobias Fischer #
1313
# @url https://github.com/tofi86/universalJavaApplicationStub #
14-
# @date 2018-02-25 #
15-
# @version 3.0.0 #
14+
# @date 2018-03-10 #
15+
# @version 3.0.1 #
1616
# #
1717
##################################################################################
1818
# #
@@ -399,7 +399,7 @@ function get_java_version_from_cmd() {
399399
# @return the major version (e.g. '7', '8' or '9', etc.)
400400
################################################################################
401401
function extract_java_major_version() {
402-
echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)[+*]?$/\1/')
402+
echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)(-b[0-9]+-[0-9]+)?[+*]?$/\1/')
403403
}
404404

405405

@@ -411,8 +411,8 @@ function extract_java_major_version() {
411411
# @return an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013')
412412
################################################################################
413413
function get_comparable_java_version() {
414-
# cleaning: 1) remove leading '1.'; 2) remove 'a-Z' and '-*+' (e.g. '-ea'); 3) replace '_' with '.'
415-
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/[a-zA-Z+*\-]//g;s/_/./g')
414+
# cleaning: 1) remove leading '1.'; 2) remove build string (e.g. '-b14-468'); 3) remove 'a-Z' and '-*+' (e.g. '-ea'); 4) replace '_' with '.'
415+
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/-b[0-9]+-[0-9]+$//g;s/[a-zA-Z+*\-]//g;s/_/./g')
416416
# splitting at '.' into an array
417417
local arr=( ${cleaned//./ } )
418418
# echo a string with left padded version numbers

test/java-version-tester.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Tests for the functions used in universalJavaApplicationStub script
4-
# tofi86 @ 2018-02-12
4+
# tofi86 @ 2018-03-10
55

66

77

@@ -27,7 +27,7 @@ function get_java_version_from_cmd() {
2727
# @return the major version (e.g. '7', '8' or '9', etc.)
2828
################################################################################
2929
function extract_java_major_version() {
30-
echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)[+*]?$/\1/')
30+
echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)(-b[0-9]+-[0-9]+)?[+*]?$/\1/')
3131
}
3232

3333

@@ -39,8 +39,8 @@ function extract_java_major_version() {
3939
# @return an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013')
4040
################################################################################
4141
function get_comparable_java_version() {
42-
# cleaning: 1) remove leading '1.'; 2) remove 'a-Z' and '-*+' (e.g. '-ea'); 3) replace '_' with '.'
43-
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/[a-zA-Z+*\-]//g;s/_/./g')
42+
# cleaning: 1) remove leading '1.'; 2) remove build string (e.g. '-b14-468'); 3) remove 'a-Z' and '-*+' (e.g. '-ea'); 4) replace '_' with '.'
43+
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/-b[0-9]+-[0-9]+$//g;s/[a-zA-Z+*\-]//g;s/_/./g')
4444
# splitting at '.' into an array
4545
local arr=( ${cleaned//./ } )
4646
# echo a string with left padded version numbers
@@ -181,6 +181,7 @@ testExtractMajor "1.6+" "6"
181181
testExtractMajor "1.6.0" "6"
182182
testExtractMajor "1.6.0_07" "6"
183183
testExtractMajor "1.6.0_45" "6"
184+
testExtractMajor "1.6.0_65-b14-468" "6"
184185
echo ""
185186
echo "Tests with Java 1.7:"
186187
testExtractMajor "1.7" "7"
@@ -245,6 +246,7 @@ echo "Tests with Java 1.6:"
245246
testComparable "1.6" "06000000"
246247
testComparable "1.6+" "06000000"
247248
testComparable "1.6.0_45" "06000045"
249+
testComparable "1.6.0_65-b14-468" "06000065"
248250
testComparable "1.6.0_100" "06000100"
249251
testComparable "1.6.1_87" "06001087"
250252
echo ""

0 commit comments

Comments
 (0)