use of com.twosigma.beakerx.kernel.magic.command.MavenJarResolver in project beakerx by twosigma.
the class ClassPathAddMvnCellMagicCommand method execute.
@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
String command = param.getCommand();
String commandCodeBlock = param.getCommandCodeBlock();
if (commandCodeBlock != null) {
command += "\n" + commandCodeBlock;
}
String[] commandLines = command.split(SPLIT_LINE_REGEX);
unifyMvnLineFormat(commandLines);
if (!validateCommandLines(commandLines)) {
return new MagicCommandOutput(MagicCommandOutput.Status.ERROR, MVN_CELL_FORMAT_ERROR_MESSAGE);
}
ClasspathAddMvnMagicCommand mvnMagicCommand = MagicCommandTypesFactory.getClasspathAddMvnMagicCommand(kernel);
commandParams.setRepos(mvnMagicCommand.getRepos().get());
List<MavenJarResolver.Dependency> dependencies = getDepsFromCommand(Arrays.copyOfRange(commandLines, 1, commandLines.length));
MavenJarResolver mavenJarResolver = new MavenJarResolver(commandParams, pomFactory);
MvnLoggerWidget mvnLoggerWidget = new MvnLoggerWidget(param.getCode().getMessage());
MavenJarResolver.AddMvnCommandResult result = mavenJarResolver.retrieve(dependencies, mvnLoggerWidget);
if (result.isJarRetrieved()) {
return handleAddedJars(mavenJarResolver.getPathToMavenRepo() + "/*");
}
return new MagicCommandOutput(MagicCommandOutput.Status.ERROR, result.getErrorMessage());
}
use of com.twosigma.beakerx.kernel.magic.command.MavenJarResolver in project beakerx by twosigma.
the class ClasspathAddMvnMagicCommand method execute.
@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
String command = param.getCommand();
String[] split = MagicCommandUtils.splitPath(command);
if (!(isGradleFormat(split) || isMavenFormat(split))) {
return new MagicCommandOutput(MagicCommandOutput.Status.ERROR, ADD_MVN_FORMAT_ERROR_MESSAGE);
}
commandParams.setRepos(getRepos().get());
MavenJarResolver classpathAddMvnCommand = new MavenJarResolver(commandParams, pomFactory);
MvnLoggerWidget progress = new MvnLoggerWidget(param.getCode().getMessage());
AddMvnCommandResult result = retrieve(getDependency(split), classpathAddMvnCommand, progress);
if (result.isJarRetrieved()) {
return handleAddedJars(classpathAddMvnCommand.getPathToMavenRepo() + "/*");
}
return new MagicCommandOutput(MagicCommandOutput.Status.ERROR, result.getErrorMessage());
}
Aggregations