Skip to content

Commit

Permalink
Auto-setting JDK path if existing version is lower than the found one (
Browse files Browse the repository at this point in the history
  • Loading branch information
rat-moonshine committed Mar 10, 2021
1 parent 7fb0d5d commit 239716a
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ package actionScripts.utils
}
}

public static function updateJavaPath(path:String):void
public static function updateJavaPath(path:String, isForceUpdate:Boolean=false):void
{
// update only if ant path not set
// or the existing ant path does not exists
if (!UtilsCore.isJavaForTypeaheadAvailable())
if (!UtilsCore.isJavaForTypeaheadAvailable() || isForceUpdate)
{
var javaSettingsProvider:JavaSettingsProvider = new JavaSettingsProvider();
javaSettingsProvider.currentJavaPath = path;
Expand All @@ -238,13 +238,17 @@ package actionScripts.utils
// update local env.variable
environmentSetupUtils.updateToCurrentEnvironmentVariable();
}
else
{
checkJavaVersionAndUpdateOnlyIfRequires(path, model.javaVersionForTypeAhead, updateJavaPath);
}
}

public static function updateJava8Path(path:String):void
public static function updateJava8Path(path:String, isForceUpdate:Boolean=false):void
{
// update only if ant path not set
// or the existing ant path does not exists
if (!UtilsCore.isJava8Present())
if (!UtilsCore.isJava8Present() || isForceUpdate)
{
var javaSettingsProvider:Java8SettingsProvider = new Java8SettingsProvider();
javaSettingsProvider.currentJava8Path = path;
Expand Down Expand Up @@ -424,5 +428,22 @@ package actionScripts.utils
environmentSetupUtils.updateToCurrentEnvironmentVariable();
}
}

private static function checkJavaVersionAndUpdateOnlyIfRequires(path:String, currentVersion:String, updateFn:Function):void
{
if (!FileUtils.isPathExists(path) || !currentVersion)
return;

var javaVersionReader:JavaVersionReader = new JavaVersionReader();
javaVersionReader.readVersion(path, onJavaVersionReadCompletes);

function onJavaVersionReadCompletes(value:String):void
{
if (HelperUtils.isNewUpdateVersion(currentVersion, value) == 1)
{
updateFn(path, true);
}
}
}
}
}

0 comments on commit 239716a

Please sign in to comment.