// Stop running container
@Override
    public Object onExecute(ExecutionEvent event) throws ExecutionException {
        project = PluginUtil.getSelectedProject();
        try {
            if (project == null) {
                throw new Exception(Constant.ERROR_NO_SELECTED_PROJECT);
            }
            basePath = project.getLocation().toString();
            if (MavenUtils.isMavenProject(project)) {
                destinationPath = MavenUtils.getTargetPath(project);
            } else {
                destinationPath = Paths.get(basePath, Constant.DOCKERFILE_FOLDER, project.getName() + ".war")
                        .normalize().toString();
            }
            // Stop running container
            String runningContainerId = DockerRuntime.getInstance().getRunningContainerId(basePath);
            if (runningContainerId != null) {
                boolean stop = MessageDialog.openConfirm(PluginUtil.getParentShell(), "Confirmation",
                        Constant.MESSAGE_CONFIRM_STOP_CONTAINER);
                if (stop) {
                    DockerRuntime.getInstance().cleanRuningContainer(basePath);
                } else {
                    return null;
                }
            }
            // Build artifact
            ConsoleLogger.info(String.format(Constant.MESSAGE_EXPORTING_PROJECT, destinationPath));
            if (MavenUtils.isMavenProject(project)) {
                MavenExecuteAction action = new MavenExecuteAction(MAVEN_GOALS);
                IContainer container;
                container = MavenUtils.getPomFile(project).getParent();
                action.launch(container, () -> {
                    // TODO: callback after mvn package done. IMPORTANT
                    buildAndRun(event);
                    return null;
                });
            } else {
                WarUtil.export(project, destinationPath);
                buildAndRun(event);
            }
        } catch (Exception e) {
            e.printStackTrace();
            ConsoleLogger.error(String.format(Constant.ERROR_RUNNING_DOCKER, e.getMessage()));
            sendTelemetryOnException(event, e);
        }
        return null;
    }
.normalize().toString();
}
// Stop running container
String runningContainerId = DockerRuntime.getInstance().getRunningContainerId(basePath);
if (runningContainerId != null) {
if (project == null) {
throw new Exception(Constant.ERROR_NO_SELECTED_PROJECT);
}
basePath = project.getLocation().toString();
if (MavenUtils.isMavenProject(project)) {
destinationPath = MavenUtils.getTargetPath(project);
} else {
destinationPath = Paths.get(basePath, Constant.DOCKERFILE_FOLDER, project.getName() + ".war")
.normalize().toString();
}
// Stop running container
String runningContainerId = DockerRuntime.getInstance().getRunningContainerId(basePath);
if (runningContainerId != null) {
boolean stop = MessageDialog.openConfirm(PluginUtil.getParentShell(), "Confirmation",
Constant.MESSAGE_CONFIRM_STOP_CONTAINER);
if (stop) {
DockerRuntime.getInstance().cleanRuningContainer(basePath);
} else {
return null;
}
}
@Override
public Object onExecute(ExecutionEvent event) throws ExecutionException {
project = PluginUtil.getSelectedProject();
try {
if (project == null) {
throw new Exception(Constant.ERROR_NO_SELECTED_PROJECT);
}
basePath = project.getLocation().toString();
if (MavenUtils.isMavenProject(project)) {
destinationPath = MavenUtils.getTargetPath(project);
} else {
destinationPath = Paths.get(basePath, Constant.DOCKERFILE_FOLDER, project.getName() + ".war")
.normalize().toString();
}
// Stop running container
String runningContainerId = DockerRuntime.getInstance().getRunningContainerId(basePath);
if (runningContainerId != null) {
boolean stop = MessageDialog.openConfirm(PluginUtil.getParentShell(), "Confirmation",
Constant.MESSAGE_CONFIRM_STOP_CONTAINER);
if (stop) {
DockerRuntime.getInstance().cleanRuningContainer(basePath);
} else {
return null;
}
}
// Build artifact
ConsoleLogger.info(String.format(Constant.MESSAGE_EXPORTING_PROJECT, destinationPath));
if (MavenUtils.isMavenProject(project)) {
MavenExecuteAction action = new MavenExecuteAction(MAVEN_GOALS);
IContainer container;
container = MavenUtils.getPomFile(project).getParent();
action.launch(container, () -> {
// TODO: callback after mvn package done. IMPORTANT
buildAndRun(event);
return null;