diff --git a/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF b/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
index 02b3348420..5c42f76665 100755
--- a/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
+++ b/as/plugins/org.jboss.ide.eclipse.as.core/META-INF/MANIFEST.MF
@@ -34,7 +34,8 @@ Require-Bundle: org.apache.ant;bundle-version="1.7.1",
org.jboss.tools.foundation.core;bundle-version="1.1.0",
org.jboss.tools.jmx.core;bundle-version="1.6.0";visibility:=reexport,
org.eclipse.jdt.debug;bundle-version="3.8.100",
- org.jboss.tools.common.jdt.debug;bundle-version="3.10.2"
+ org.jboss.tools.common.jdt.debug;bundle-version="3.10.2",
+ org.eclipse.m2e.launching
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.ide.eclipse.as.core,
org.jboss.ide.eclipse.as.core.extensions.descriptors,
@@ -59,7 +60,8 @@ Export-Package: org.jboss.ide.eclipse.as.core,
org.jboss.tools.as.core.server.controllable.subsystems,
org.jboss.tools.as.core.server.controllable.subsystems.internal;x-friends:="org.jboss.tools.as.test.core,org.jboss.ide.eclipse.as.ui",
org.jboss.tools.as.core.server.controllable.systems,
- org.jboss.tools.as.core.server.controllable.util
+ org.jboss.tools.as.core.server.controllable.util,
+ org.jboss.tools.as.core.server.wildflyjar
Bundle-ClassPath: dom4j-1.6.1.jar,
jaxen-1.1-beta-6.jar,
getopt.jar,
diff --git a/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/tools/as/core/server/wildflyjar/WildflyJarLaunchConfigurationDelegate.java b/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/tools/as/core/server/wildflyjar/WildflyJarLaunchConfigurationDelegate.java
new file mode 100644
index 0000000000..2071c86767
--- /dev/null
+++ b/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/tools/as/core/server/wildflyjar/WildflyJarLaunchConfigurationDelegate.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.as.core.server.wildflyjar;
+
+import org.eclipse.m2e.internal.launch.MavenLaunchDelegate;
+
+public class WildflyJarLaunchConfigurationDelegate extends MavenLaunchDelegate {
+ public static final String ID = "org.jboss.tools.as.core.server.wildflyjar.WildflyJarLaunchConfiguration";
+ public static final String DEFAULT_GOAL = "wildfly-jar:dev-watch";
+}
diff --git a/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml b/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
index 6dd62cb830..f3a3e7b1b2 100644
--- a/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
+++ b/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
@@ -3021,4 +3021,17 @@
+
+
+
+
+
+
diff --git a/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF b/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
index f7f54a4a22..0d6b76cfcb 100755
--- a/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
+++ b/as/plugins/org.jboss.ide.eclipse.as.ui/META-INF/MANIFEST.MF
@@ -65,7 +65,10 @@ Require-Bundle: com.ibm.icu;bundle-version="4.2.1",
org.jboss.tools.foundation.ui;bundle-version="1.1.0",
org.jboss.tools.jmx.core;bundle-version="1.7.0",
org.eclipse.jst.server.ui;bundle-version="1.1.100",
- org.eclipse.swt
+ org.eclipse.swt,
+ org.eclipse.m2e.core,
+ org.eclipse.m2e.maven.runtime,
+ org.eclipse.m2e.launching
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.ide.eclipse.as.ui,
org.jboss.ide.eclipse.as.ui.actions,
diff --git a/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/RunAsWildflyJar.java b/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/RunAsWildflyJar.java
new file mode 100644
index 0000000000..b5c98b3ee8
--- /dev/null
+++ b/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/RunAsWildflyJar.java
@@ -0,0 +1,131 @@
+package org.jboss.ide.eclipse.as.ui.wildflyjar;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchGroup;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.m2e.actions.MavenLaunchConstants;
+import org.eclipse.m2e.internal.launch.LaunchingUtils;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.as.core.server.wildflyjar.WildflyJarLaunchConfigurationDelegate;
+
+public class RunAsWildflyJar implements ILaunchShortcut {
+ public static final String ID_EXTERNAL_TOOLS_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$
+
+ @Override
+ public void launch(IEditorPart editor, String mode) {
+ // Do nothing
+ }
+
+ @Override
+ public void launch(ISelection selection, String mode) {
+ IContainer basedir = getBaseDir(selection);
+ if (basedir == null)
+ return;
+
+ ILaunchConfiguration launchConfiguration = getLaunchConfiguration(basedir, mode);
+ if (launchConfiguration == null) {
+ return;
+ }
+
+ ILaunchGroup group = DebugUITools.getLaunchGroup(launchConfiguration, mode);
+ String groupId = group != null ? group.getIdentifier() : ID_EXTERNAL_TOOLS_LAUNCH_GROUP;
+ DebugUITools.openLaunchConfigurationDialog(getShell(), launchConfiguration, groupId, null);
+ }
+
+ private ILaunchConfiguration getLaunchConfiguration(IContainer basedir, String mode) {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType = launchManager
+ .getLaunchConfigurationType(WildflyJarLaunchConfigurationDelegate.ID);
+
+ try {
+ ArrayList match = findMatchingConfigs(launchManager, launchConfigurationType, basedir.getLocation());
+ if( match != null && match.size() > 0 )
+ return match.get(0);
+
+ String newName = launchManager.generateLaunchConfigurationName(basedir.getLocation().lastSegment());
+ ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName);
+ workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR,
+ LaunchingUtils.generateProjectLocationVariableExpression(basedir.getProject()));
+ workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, WildflyJarLaunchConfigurationDelegate.DEFAULT_GOAL);
+ return workingCopy.doSave();
+ } catch (Exception ex) {
+ }
+ return null;
+ }
+
+ private ArrayList findMatchingConfigs(ILaunchManager manager, ILaunchConfigurationType type,
+ IPath basedirLocation) throws CoreException {
+ ILaunchConfiguration[] launchConfigurations = manager.getLaunchConfigurations(type);
+ ArrayList matchingConfigs = new ArrayList();
+ for (ILaunchConfiguration configuration : launchConfigurations) {
+ try {
+ // substitute variables (may throw exceptions)
+ String workDir = LaunchingUtils
+ .substituteVar(configuration.getAttribute(MavenLaunchConstants.ATTR_POM_DIR, (String) null));
+ if (workDir == null) {
+ continue;
+ }
+ IPath workPath = new Path(workDir);
+ if (basedirLocation.equals(workPath)) {
+ matchingConfigs.add(configuration);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ return matchingConfigs;
+ }
+
+ private Shell getShell() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
+
+ protected IContainer getBaseDir(ISelection selection) {
+ IContainer basedir = null;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ Object object = structuredSelection.getFirstElement();
+
+ if (object instanceof IProject || object instanceof IFolder) {
+ basedir = (IContainer) object;
+ } else if (object instanceof IFile) {
+ basedir = ((IFile) object).getParent();
+ } else if (object instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) object;
+ Object adapter = adaptable.getAdapter(IProject.class);
+ if (adapter != null) {
+ basedir = (IContainer) adapter;
+ } else {
+ adapter = adaptable.getAdapter(IFolder.class);
+ if (adapter != null) {
+ basedir = (IContainer) adapter;
+ } else {
+ adapter = adaptable.getAdapter(IFile.class);
+ if (adapter != null) {
+ basedir = ((IFile) object).getParent();
+ }
+ }
+ }
+ }
+ }
+ return basedir;
+ }
+}
diff --git a/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/WildflyJarLaunchConfigurationTabGroup.java b/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/WildflyJarLaunchConfigurationTabGroup.java
new file mode 100644
index 0000000000..991b2091c8
--- /dev/null
+++ b/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/WildflyJarLaunchConfigurationTabGroup.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.ide.eclipse.as.ui.wildflyjar;
+
+import java.util.Arrays;
+
+import org.apache.maven.model.Plugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.EnvironmentTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.RefreshTab;
+import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.m2e.actions.MavenLaunchConstants;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.ui.internal.launch.MavenJRETab;
+import org.eclipse.m2e.ui.internal.launch.MavenLaunchMainTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class WildflyJarLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ public WildflyJarLaunchConfigurationTabGroup() {
+ }
+
+ @Override
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ CustomMavenLaunchMainTab main = new CustomMavenLaunchMainTab();
+ setTabs(new WildflyJarLaunchConfigurationTab(main), main, new MavenJRETab(), new RefreshTab(),
+ new SourceLookupTab(), new EnvironmentTab(), new CommonTab());
+ }
+
+ private static class CustomMavenLaunchMainTab extends MavenLaunchMainTab {
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ goalsText.setEnabled(false);
+ }
+
+ public void setGoal(String text) {
+ goalsText.setText(text);
+ }
+ }
+
+ public static class WildflyJarLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
+ private Combo combo = null;
+ private String[] opts = new String[] { "dev", "dev-watch", "run", "start", "shutdown" };
+ private CustomMavenLaunchMainTab main;
+
+ public WildflyJarLaunchConfigurationTab(CustomMavenLaunchMainTab main) {
+ this.main = main;
+ }
+
+ /*
+ * dev: To build a bootable JAR in 'dev' mode. dev-watch: To launch the bootable
+ * JAR foreground (blocking). run: To launch the bootable JAR foreground
+ * (blocking). start: To launch the bootable JAR in background (non blocking).
+ * shutdown: To kill a running bootable JAR.
+ */
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ container.setLayout(new GridLayout(2, false));
+ container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label l = new Label(container, SWT.NONE);
+ l.setText("wildfly-jar goal");
+
+ combo = new Combo(container, SWT.READ_ONLY);
+
+ combo.setItems(opts);
+ combo.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int sel = combo.getSelectionIndex();
+ if (sel == -1) {
+ main.setGoal("");
+ } else {
+ main.setGoal("wildfly-jar:" + combo.getItem(sel));
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ setControl(container);
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ IJavaElement javaElement = getContext();
+ if (javaElement != null && isWildflyJarProject(javaElement.getJavaProject())) {
+ // TODO set the defaults
+ } else {
+ // Set defaults with no known information
+ }
+ }
+
+ protected boolean isWildflyJarProject(IJavaProject jp) {
+ return WildflyJarPropertyTester.isWildflyJarProject(jp.getProject());
+ }
+
+ public static IWorkbenchPage getActivePage() {
+ IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (w != null) {
+ return w.getActivePage();
+ }
+ return null;
+ }
+
+ protected IJavaElement getContext() {
+ IWorkbenchPage page = getActivePage();
+ if (page != null) {
+ ISelection selection = page.getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ if (!ss.isEmpty()) {
+ Object obj = ss.getFirstElement();
+ if (obj instanceof IJavaElement) {
+ return (IJavaElement) obj;
+ }
+ if (obj instanceof IResource) {
+ IJavaElement je = JavaCore.create((IResource) obj);
+ if (je == null) {
+ IProject pro = ((IResource) obj).getProject();
+ je = JavaCore.create(pro);
+ }
+ if (je != null) {
+ return je;
+ }
+ }
+ }
+ }
+ IEditorPart part = page.getActiveEditor();
+ if (part != null) {
+ IEditorInput input = part.getEditorInput();
+ return input.getAdapter(IJavaElement.class);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ String goal = getAttribute(configuration, MavenLaunchConstants.ATTR_GOALS, ""); //$NON-NLS-1$
+ if( goal != null ) {
+ if( goal.startsWith("wildfly-jar:")) {
+ goal = goal.substring("wildfly-jar:".length());
+ }
+ int ind = Arrays.asList(opts).indexOf(goal);
+ combo.deselectAll();
+ if( ind != -1 ) {
+ combo.select(ind);
+ }
+ }
+ }
+
+ private String getAttribute(ILaunchConfiguration configuration, String name, String defaultValue) {
+ try {
+ return configuration.getAttribute(name, defaultValue);
+ } catch (CoreException ex) {
+ return defaultValue;
+ }
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ // We do nothing here. Woohoo
+ main.performApply(configuration);
+ }
+
+ @Override
+ public String getName() {
+ return "Wildfly-jar";
+ }
+
+ }
+}
diff --git a/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/WildflyJarPropertyTester.java b/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/WildflyJarPropertyTester.java
new file mode 100644
index 0000000000..facf6d64bb
--- /dev/null
+++ b/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wildflyjar/WildflyJarPropertyTester.java
@@ -0,0 +1,37 @@
+package org.jboss.ide.eclipse.as.ui.wildflyjar;
+
+import org.apache.maven.model.Plugin;
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+public class WildflyJarPropertyTester extends PropertyTester {
+
+ public WildflyJarPropertyTester() {
+ }
+
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ System.out.println("Here");
+ if("isWildflyJar".equals(property) && receiver instanceof IProject) {
+ boolean ret = isWildflyJarProject((IProject)receiver);
+ System.out.println(ret);
+ return ret;
+ }
+ return false;
+ }
+
+ public static boolean isWildflyJarProject(IProject jp) {
+ IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().getProject(jp);
+ if( facade == null || facade.getMavenProject() == null ) {
+ System.out.println("false stuff");
+ return false;
+ }
+ Plugin p = facade.getMavenProject().getPlugin("org.wildfly.plugins:wildfly-jar-maven-plugin");
+ if (p != null) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml b/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
index 7744107b19..4b07055218 100644
--- a/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
+++ b/as/plugins/org.jboss.ide.eclipse.as.ui/plugin.xml
@@ -762,4 +762,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+