Skip to content

Commit

Permalink
Merge pull request #253 from hhpatel14/MTA-2944
Browse files Browse the repository at this point in the history
 Add cli path manually
  • Loading branch information
dymurray authored Jul 23, 2024
2 parents 045c29a + f742523 commit f2f67fa
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class KantraCliParamBuilder {

public static List<String> buildParams(WindupConfiguration config) {
public static List<String> buildParams(WindupConfiguration config, String windupHome) {
List<String> params = Lists.newArrayList();
Map<String, Object> options = config.getOptions();
params.add("analyze");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ public class RunAnalysisCommandHandler {
private WindupConsole console;

public RunAnalysisCommandHandler(Project project,
String executable,
List<String> params,
WindupConsole console,
Runnable onComplete) {
this.project = project;
this.console = console;
commandLine = new GeneralCommandLine();
commandLine.setExePath("kantra");
commandLine.setExePath(executable);
commandLine.addParameters(params);
// System.out.println("This is RunAnalysis Command handler............. constructor");
System.out.println(onComplete.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public static void run(WindupConfiguration configuration,
ProgressMonitor progressMonitor,
CliListener listener) {
String javaHome = "";
String windupCli = "kantra";
List<String> params = KantraCliParamBuilder.buildParams(configuration);
String windupCli = (String)configuration.getOptions().get("cli");
List<String> params = KantraCliParamBuilder.buildParams(configuration, windupCli);
WindupCliRunner.executeAnalysis(windupCli, javaHome, params, progressMonitor, listener);
}

private static void executeAnalysis(String cli, String javaHome, List<String> params, ProgressMonitor progressMonitor, CliListener listener) {
System.out.println("execute CLI");
CommandLine cmdLine = CommandLine.parse("kantra");
CommandLine cmdLine = CommandLine.parse(cli);
Map<String, String> env = Maps.newHashMap();
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
env.put(entry.getKey(), entry.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ public void actionPerformed(AnActionEvent anActionEvent, TreePath path, Object s
WindupConfiguration configuration = node.getValue();
ModelService modelService = node.getModelService();
if (this.validateConfiguration(configuration)) {
String executable = (String)configuration.getOptions().get("cli");
try {
List<String> params = KantraCliParamBuilder.buildParams(configuration);
String windupHome = new File(executable).getParentFile().getParent();
List<String> params = KantraCliParamBuilder.buildParams(configuration, windupHome);

RunAnalysisCommandHandler handler = new RunAnalysisCommandHandler(
anActionEvent.getProject(),
executable,
params,
console,
() ->{
Expand Down Expand Up @@ -81,24 +85,24 @@ private void loadAnalysisResults(WindupConfiguration configuration, ModelService

private boolean validateConfiguration(WindupConfiguration configuration) {
boolean valid = true;
// String cliLocation = (String)configuration.getOptions().get("cli");
String cliLocation = "trying to avoid the cli ERROR";
String cliLocation = (String)configuration.getOptions().get("cli");

if (cliLocation == null || "".equals(cliLocation)) {
valid = false;
WindupNotifier.notifyError("Path to CLI executable required.");
}
// else if (cliLocation != null) {
// cliLocation = this.resolveCliPath(cliLocation);
// configuration.getOptions().put("cli", cliLocation);
// if (!new File(cliLocation).exists()) {
// valid = false;
// WindupNotifier.notifyError("Path to CLI executable does not exist.");
// }
// else if (!Files.isExecutable(Paths.get(cliLocation))) {
// valid = false;
// WindupNotifier.notifyError("Path to CLI executable is not executable.");
// }
// }
else if (cliLocation != null) {
cliLocation = this.resolveCliPath(cliLocation);
configuration.getOptions().put("cli", cliLocation);
if (!new File(cliLocation).exists()) {
valid = false;
WindupNotifier.notifyError("Path to CLI executable does not exist.");
}
else if (!Files.isExecutable(Paths.get(cliLocation))) {
valid = false;
WindupNotifier.notifyError("Path to CLI executable is not executable.");
}
}
List<String> input = (List<String>)configuration.getOptions().get("input");
if (input == null || input.isEmpty()) {
WindupNotifier.notifyError("Path to input required.");
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/META-INF/web/webroot/help.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
"ui-type": ["single"],
"required": true
},
{
"name": "cli",
"description": "Path to migration toolkit executable.",
"type": "File",
"ui-type": ["file"],
"required": true
},
{
"name": "input",
"description": "Input file or directory (a directory is required for source mode). Note: Please select only one path at a time. To change the input entry, use the cancel button.",
Expand Down

0 comments on commit f2f67fa

Please sign in to comment.