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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tofi86 committed Mar 10, 2018
2 parents 46b1f67 + ff6a649 commit fd36409
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ChangeLog
---------

### v3.0.1 (2018-03-10)
* Bugfix: remove build number from JVM version number when creating comparable version number or extracting major version (fixes #61)

### v3.0.0 (2018-02-25)
* Completeley overhauled algorithm for JVM detection (JRE and JDK)
* JDK has no longer precedence over JRE
Expand Down
10 changes: 5 additions & 5 deletions src/universalJavaApplicationStub
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# #
# @author Tobias Fischer #
# @url https://github.com/tofi86/universalJavaApplicationStub #
# @date 2018-02-25 #
# @version 3.0.0 #
# @date 2018-03-10 #
# @version 3.0.1 #
# #
##################################################################################
# #
Expand Down Expand Up @@ -399,7 +399,7 @@ function get_java_version_from_cmd() {
# @return the major version (e.g. '7', '8' or '9', etc.)
################################################################################
function extract_java_major_version() {
echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)[+*]?$/\1/')
echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)(-b[0-9]+-[0-9]+)?[+*]?$/\1/')
}


Expand All @@ -411,8 +411,8 @@ function extract_java_major_version() {
# @return an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013')
################################################################################
function get_comparable_java_version() {
# cleaning: 1) remove leading '1.'; 2) remove 'a-Z' and '-*+' (e.g. '-ea'); 3) replace '_' with '.'
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/[a-zA-Z+*\-]//g;s/_/./g')
# cleaning: 1) remove leading '1.'; 2) remove build string (e.g. '-b14-468'); 3) remove 'a-Z' and '-*+' (e.g. '-ea'); 4) replace '_' with '.'
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/-b[0-9]+-[0-9]+$//g;s/[a-zA-Z+*\-]//g;s/_/./g')
# splitting at '.' into an array
local arr=( ${cleaned//./ } )
# echo a string with left padded version numbers
Expand Down
10 changes: 6 additions & 4 deletions test/java-version-tester.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

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



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


Expand All @@ -39,8 +39,8 @@ function extract_java_major_version() {
# @return an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013')
################################################################################
function get_comparable_java_version() {
# cleaning: 1) remove leading '1.'; 2) remove 'a-Z' and '-*+' (e.g. '-ea'); 3) replace '_' with '.'
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/[a-zA-Z+*\-]//g;s/_/./g')
# cleaning: 1) remove leading '1.'; 2) remove build string (e.g. '-b14-468'); 3) remove 'a-Z' and '-*+' (e.g. '-ea'); 4) replace '_' with '.'
local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/-b[0-9]+-[0-9]+$//g;s/[a-zA-Z+*\-]//g;s/_/./g')
# splitting at '.' into an array
local arr=( ${cleaned//./ } )
# echo a string with left padded version numbers
Expand Down Expand Up @@ -181,6 +181,7 @@ testExtractMajor "1.6+" "6"
testExtractMajor "1.6.0" "6"
testExtractMajor "1.6.0_07" "6"
testExtractMajor "1.6.0_45" "6"
testExtractMajor "1.6.0_65-b14-468" "6"
echo ""
echo "Tests with Java 1.7:"
testExtractMajor "1.7" "7"
Expand Down Expand Up @@ -245,6 +246,7 @@ echo "Tests with Java 1.6:"
testComparable "1.6" "06000000"
testComparable "1.6+" "06000000"
testComparable "1.6.0_45" "06000045"
testComparable "1.6.0_65-b14-468" "06000065"
testComparable "1.6.0_100" "06000100"
testComparable "1.6.1_87" "06001087"
echo ""
Expand Down

0 comments on commit fd36409

Please sign in to comment.