Skip to content

Commit

Permalink
- Added auto-detection and auto-setup of Gradle
Browse files Browse the repository at this point in the history
- Added GRADLE_HOME addition to local environment setup procedure
(reference Moonshine-IDE/Moonshine-SDK-Installer#9)
  • Loading branch information
rat-moonshine committed May 15, 2019
1 parent fd0dd84 commit e212a89
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ package actionScripts.impls
return UtilsCore.isMavenAvailable();
}

public function isGradlePresent():Boolean
{
return UtilsCore.isGradleAvailable();
}

public function isSVNPresent():Boolean
{
return UtilsCore.isSVNPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ package actionScripts.languageServer
_shellInfo = new NativeProcessStartupInfo();
_shellInfo.arguments = processArgs;
_shellInfo.executable = cmdFile;
_shellInfo.workingDirectory = new File(_project.folderLocation.fileBridge.nativePath);
_shellInfo.workingDirectory = _project.folderLocation.fileBridge.getFile as File;

_nativeProcess = new NativeProcess();
_nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, shellDataOnGradleClasspath);
Expand Down Expand Up @@ -344,7 +344,7 @@ package actionScripts.languageServer
processArgs.push(getWorkspaceNativePath());
_shellInfo.arguments = processArgs;
_shellInfo.executable = cmdFile;
_shellInfo.workingDirectory = new File(_project.folderLocation.fileBridge.nativePath);
_shellInfo.workingDirectory = _project.folderLocation.fileBridge.getFile as File;

_nativeProcess = new NativeProcess();
_nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, shellError);
Expand Down Expand Up @@ -450,20 +450,22 @@ package actionScripts.languageServer
var data:String = output.readUTFBytes(output.bytesAvailable);
ConsoleUtil.print("shellError " + data + ".");
ConsoleOutputter.formatOutput(HtmlFormatter.sprintfa(data, null), 'weak');
trace(data);
}

private function shellErrorOnGradleClasspath(e:ProgressEvent):void
{
var output:IDataInput = _nativeProcess.standardError;
var data:String = output.readUTFBytes(output.bytesAvailable);
ConsoleUtil.print("shellError while updating Gradle classpath" + data + ".");
ConsoleOutputter.formatOutput(HtmlFormatter.sprintfa(data, null), 'weak');

data = "shellError while updating Gradle classpath" + data + ".";
GlobalEventDispatcher.getInstance().dispatchEvent(new ConsoleOutputEvent(
ConsoleOutputEvent.CONSOLE_OUTPUT,
HtmlFormatter.sprintfa(data, null), false, false,
ConsoleOutputEvent.TYPE_ERROR));

GlobalEventDispatcher.getInstance().dispatchEvent(new StatusBarEvent(
StatusBarEvent.LANGUAGE_SERVER_STATUS
));
trace(data);
}

private function shellDataOnGradleClasspath(e:ProgressEvent):void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ package actionScripts.utils
import flash.events.ProgressEvent;
import flash.events.TimerEvent;
import flash.filesystem.File;
import flash.utils.IDataInput;
import flash.utils.Timer;
import flash.utils.clearTimeout;
import flash.utils.setTimeout;
Expand Down Expand Up @@ -186,6 +185,12 @@ package actionScripts.utils
setPathCommand += (ConstantsCoreVO.IS_MACOS ? "$MAVEN_HOME/bin:" : "%MAVEN_HOME%\\bin;");
isValidToExecute = true;
}
if (UtilsCore.isGradleAvailable())
{
setCommand += getSetExportCommand("GRADLE_HOME", model.gradlePath);
setPathCommand += (ConstantsCoreVO.IS_MACOS ? "$GRADLE_HOME/bin:" : "%GRADLE_HOME%\\bin;");
isValidToExecute = true;
}
if (!ConstantsCoreVO.IS_MACOS && UtilsCore.isGitPresent())
{
// moonshine stores gir path with 'bin\git.exe' format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ package actionScripts.utils
case SDKTypes.MAVEN:
pluginClass = "actionScripts.plugins.maven::MavenBuildPlugin";
break;
case SDKTypes.GRADLE:
pluginClass = "actionScripts.plugins.gradle::GradleBuildPlugin";
break;
case SDKTypes.SVN:
pluginClass = "actionScripts.plugins.svn::SVNPlugin";
break;
Expand Down Expand Up @@ -93,6 +96,9 @@ package actionScripts.utils
case SDKTypes.MAVEN:
updateMavenPath(path);
break;
case SDKTypes.GRADLE:
updateGradlePath(path);
break;
case SDKTypes.SVN:
updateSVNPath(path);
break;
Expand Down Expand Up @@ -136,6 +142,23 @@ package actionScripts.utils
}
}

public static function updateGradlePath(path:String):void
{
// update only if ant path not set
// or the existing ant path does not exists
if (!model.gradlePath)
{
model.gradlePath = path;
var settings:Vector.<ISetting> = Vector.<ISetting>([
new PathSetting({gradlePath: path}, 'gradlePath', 'Gradle Home', true, path)
]);

// save as moonshine settings
dispatcher.dispatchEvent(new SetSettingsEvent(SetSettingsEvent.SAVE_SPECIFIC_PLUGIN_SETTING,
null, "actionScripts.plugins.gradle::GradleBuildPlugin", settings));
}
}

public static function updateJavaPath(path:String):void
{
// update only if ant path not set
Expand Down
11 changes: 11 additions & 0 deletions ide/MoonshineSharedCore/src/actionScripts/utils/UtilsCore.as
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,17 @@ package actionScripts.utils
var mavenLocation:FileLocation = new FileLocation(model.mavenPath);
return mavenLocation.resolvePath("bin/"+ (ConstantsCoreVO.IS_MACOS ? "mvn" : "mvn.cmd")).fileBridge.exists;
}

public static function isGradleAvailable():Boolean
{
if (!model.gradlePath || model.gradlePath == "")
{
return false;
}

var gradleLocation:FileLocation = new FileLocation(model.gradlePath);
return gradleLocation.resolvePath("bin/"+ (ConstantsCoreVO.IS_MACOS ? "gradle" : "gradle.bat")).fileBridge.exists;
}

public static function getMavenBinPath():String
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ package actionScripts.valueObjects
public static const SVN:String = "svn";
public static const GIT:String = "git";
public static const MAVEN:String = "maven";
public static const GRADLE:String = "gradle";
public static const OPENJAVA:String = "openjava";
}
}

0 comments on commit e212a89

Please sign in to comment.