Skip to content

Commit d357c52

Browse files
committed
launch User defined Maven goals
1 parent 50044db commit d357c52

File tree

11 files changed

+324
-3
lines changed

11 files changed

+324
-3
lines changed

org.nodeclipse.enide.maven/plugin.xml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,126 @@
6060
</shortcut>
6161
</extension>
6262

63+
<!-- goal2 -->
64+
<extension
65+
point="org.eclipse.debug.core.launchConfigurationTypes">
66+
<launchConfigurationType
67+
delegate="org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationDelegate"
68+
id="org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType"
69+
modes="run"
70+
name="Maven goal2">
71+
</launchConfigurationType>
72+
</extension>
73+
<extension
74+
point= "org.eclipse.debug.ui.launchConfigurationTypeImages" >
75+
<launchConfigurationTypeImage
76+
configTypeID= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType"
77+
icon= "icons/feather-ma16_bottom_right_corner_run_half_size.png"
78+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationTypeImage" >
79+
</launchConfigurationTypeImage>
80+
</extension>
81+
<extension
82+
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
83+
<launchConfigurationTabGroup
84+
class= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationTabGroup"
85+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationTabGroup"
86+
type= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType" >
87+
</launchConfigurationTabGroup>
88+
</extension>
89+
<!-- pom.xml run as goal2 -->
90+
<extension
91+
point= "org.eclipse.debug.ui.launchShortcuts" >
92+
<shortcut
93+
class= "org.nodeclipse.enide.maven.launch.goal2.LaunchShortcut"
94+
icon= "icons/feather-ma16_bottom_right_corner_run_half_size.png"
95+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchShortcut"
96+
label= "mvn goal2 Maven goal"
97+
modes= "run" >
98+
<configurationType
99+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType" >
100+
</configurationType>
101+
<contextualLaunch>
102+
<enablement>
103+
<with
104+
variable= "selection" >
105+
<count
106+
value= "1" >
107+
</count>
108+
<iterate>
109+
<or>
110+
<test
111+
property= "org.eclipse.debug.ui.matchesPattern"
112+
value= "pom*.xml" >
113+
</test>
114+
</or>
115+
</iterate>
116+
</with>
117+
</enablement>
118+
</contextualLaunch>
119+
</shortcut>
120+
</extension>
121+
122+
123+
<!-- goal2 -->
124+
<extension
125+
point="org.eclipse.debug.core.launchConfigurationTypes">
126+
<launchConfigurationType
127+
delegate="org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationDelegate"
128+
id="org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType"
129+
modes="run"
130+
name="Maven goal2">
131+
</launchConfigurationType>
132+
</extension>
133+
<extension
134+
point= "org.eclipse.debug.ui.launchConfigurationTypeImages" >
135+
<launchConfigurationTypeImage
136+
configTypeID= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType"
137+
icon= "icons/feather-ma16_bottom_right_corner_run_half_size.png"
138+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationTypeImage" >
139+
</launchConfigurationTypeImage>
140+
</extension>
141+
<extension
142+
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
143+
<launchConfigurationTabGroup
144+
class= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationTabGroup"
145+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationTabGroup"
146+
type= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType" >
147+
</launchConfigurationTabGroup>
148+
</extension>
149+
<!-- pom.xml run as goal2 -->
150+
<extension
151+
point= "org.eclipse.debug.ui.launchShortcuts" >
152+
<shortcut
153+
class= "org.nodeclipse.enide.maven.launch.goal2.LaunchShortcut"
154+
icon= "icons/feather-ma16_bottom_right_corner_run_half_size.png"
155+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchShortcut"
156+
label= "mvn goal2 Maven goal"
157+
modes= "run" >
158+
<configurationType
159+
id= "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType" >
160+
</configurationType>
161+
<contextualLaunch>
162+
<enablement>
163+
<with
164+
variable= "selection" >
165+
<count
166+
value= "1" >
167+
</count>
168+
<iterate>
169+
<or>
170+
<test
171+
property= "org.eclipse.debug.ui.matchesPattern"
172+
value= "pom*.xml" >
173+
</test>
174+
</or>
175+
</iterate>
176+
</with>
177+
</enablement>
178+
</contextualLaunch>
179+
</shortcut>
180+
</extension>
181+
182+
63183
<!-- jetty:run -->
64184
<extension
65185
point="org.eclipse.debug.core.launchConfigurationTypes">
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.nodeclipse.enide.maven.launch.goal1;
2+
3+
import java.io.File;
4+
import java.util.List;
5+
6+
import org.eclipse.core.resources.ResourcesPlugin;
7+
import org.eclipse.core.runtime.CoreException;
8+
import org.eclipse.debug.core.ILaunchConfiguration;
9+
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
10+
import org.eclipse.jface.preference.IPreferenceStore;
11+
import org.nodeclipse.enide.maven.preferences.MavenConstants;
12+
13+
/**
14+
* mvn goal1</br>
15+
*
16+
* @since 0.15
17+
* @author Paul Verest
18+
*/
19+
public class LaunchConfigurationDelegate
20+
extends org.nodeclipse.enide.maven.launch.LaunchConfigurationDelegate
21+
implements ILaunchConfigurationDelegate {
22+
23+
@Override
24+
protected void specialOptions(ILaunchConfiguration configuration,
25+
IPreferenceStore preferenceStore, List<String> cmdLine) throws CoreException {
26+
27+
String mavenOptions= preferenceStore.getString(MavenConstants.MAVEN_OPTIONS);
28+
if(!mavenOptions.equals("")) {
29+
String[] sa = mavenOptions.split(" ");
30+
for(String s : sa) {
31+
cmdLine.add(s);
32+
}
33+
}
34+
35+
String file = configuration.getAttribute(MavenConstants.KEY_FILE_PATH, "");
36+
String filePath = ResourcesPlugin.getWorkspace().getRoot().findMember(file).getLocation().toOSString();
37+
// path is relative, so cannot find it, unless get absolute path
38+
cmdLine.add("-f"); // -f,--file <arg> Force the use of an alternate POM
39+
cmdLine.add(filePath);
40+
41+
String mavenGoal1= preferenceStore.getString(MavenConstants.MAVEN_GOAL1);
42+
cmdLine.add(mavenGoal1); //TODO only this changed
43+
44+
//workingPath = (new File(filePath)).getParentFile();
45+
//setWorkingDirectoryDefault(filePath);
46+
workingDirectoryDefault = (new File(filePath)).getParentFile();
47+
}
48+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.nodeclipse.enide.maven.launch.goal1;
2+
3+
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
4+
import org.eclipse.debug.ui.CommonTab;
5+
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
6+
import org.eclipse.debug.ui.ILaunchConfigurationTab;
7+
//import org.nodeclipse.debug.launch.LaunchConfigurationEnvironmentTab;
8+
9+
10+
/**
11+
* Using "Run"-->"Run Configurations"--> "New Configuration"-- > "Run" will lead
12+
* here.
13+
* @author Paul Verest
14+
**/
15+
public class LaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
16+
17+
@Override
18+
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
19+
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
20+
// new LaunchConfigurationMainTab(),
21+
// new NodeArgumentsTab(),
22+
// new LaunchConfigurationEnvironmentTab(),
23+
new CommonTab()
24+
};
25+
setTabs(tabs);
26+
}
27+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.nodeclipse.enide.maven.launch.goal1;
2+
3+
public class LaunchConfigurationType {
4+
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.nodeclipse.enide.maven.launch.goal1;
2+
3+
import org.eclipse.debug.ui.ILaunchShortcut;
4+
import org.nodeclipse.enide.maven.preferences.MavenConstants;
5+
6+
/**
7+
* Using "Run As" --> "mvn tomcat6:start Maven start" will lead here</br>
8+
* http://tomcat.apache.org/maven-plugin-2.2/context-goals.html
9+
**/
10+
public class LaunchShortcut extends org.nodeclipse.enide.maven.launchexec.LaunchShortcut implements ILaunchShortcut {
11+
12+
@Override
13+
protected String getLaunchConfigurationTypeConstant() {
14+
return MavenConstants.LAUNCH_GOAL1_CONFIGURATION_TYPE_ID;
15+
}
16+
17+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.nodeclipse.enide.maven.launch.goal2;
2+
3+
import java.io.File;
4+
import java.util.List;
5+
6+
import org.eclipse.core.resources.ResourcesPlugin;
7+
import org.eclipse.core.runtime.CoreException;
8+
import org.eclipse.debug.core.ILaunchConfiguration;
9+
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
10+
import org.eclipse.jface.preference.IPreferenceStore;
11+
import org.nodeclipse.enide.maven.preferences.MavenConstants;
12+
13+
/**
14+
* mvn goal2</br>
15+
*
16+
* @since 0.15
17+
* @author Paul Verest
18+
*/
19+
public class LaunchConfigurationDelegate
20+
extends org.nodeclipse.enide.maven.launch.LaunchConfigurationDelegate
21+
implements ILaunchConfigurationDelegate {
22+
23+
@Override
24+
protected void specialOptions(ILaunchConfiguration configuration,
25+
IPreferenceStore preferenceStore, List<String> cmdLine) throws CoreException {
26+
27+
String mavenOptions= preferenceStore.getString(MavenConstants.MAVEN_OPTIONS);
28+
if(!mavenOptions.equals("")) {
29+
String[] sa = mavenOptions.split(" ");
30+
for(String s : sa) {
31+
cmdLine.add(s);
32+
}
33+
}
34+
35+
String file = configuration.getAttribute(MavenConstants.KEY_FILE_PATH, "");
36+
String filePath = ResourcesPlugin.getWorkspace().getRoot().findMember(file).getLocation().toOSString();
37+
// path is relative, so cannot find it, unless get absolute path
38+
cmdLine.add("-f"); // -f,--file <arg> Force the use of an alternate POM
39+
cmdLine.add(filePath);
40+
41+
String mavenGoal1= preferenceStore.getString(MavenConstants.MAVEN_GOAL2);
42+
cmdLine.add(mavenGoal1); //TODO only this changed
43+
44+
//workingPath = (new File(filePath)).getParentFile();
45+
//setWorkingDirectoryDefault(filePath);
46+
workingDirectoryDefault = (new File(filePath)).getParentFile();
47+
}
48+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.nodeclipse.enide.maven.launch.goal2;
2+
3+
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
4+
import org.eclipse.debug.ui.CommonTab;
5+
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
6+
import org.eclipse.debug.ui.ILaunchConfigurationTab;
7+
//import org.nodeclipse.debug.launch.LaunchConfigurationEnvironmentTab;
8+
9+
10+
/**
11+
* Using "Run"-->"Run Configurations"--> "New Configuration"-- > "Run" will lead
12+
* here.
13+
* @author Paul Verest
14+
**/
15+
public class LaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
16+
17+
@Override
18+
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
19+
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
20+
// new LaunchConfigurationMainTab(),
21+
// new NodeArgumentsTab(),
22+
// new LaunchConfigurationEnvironmentTab(),
23+
new CommonTab()
24+
};
25+
setTabs(tabs);
26+
}
27+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.nodeclipse.enide.maven.launch.goal2;
2+
3+
public class LaunchConfigurationType {
4+
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.nodeclipse.enide.maven.launch.goal2;
2+
3+
import org.eclipse.debug.ui.ILaunchShortcut;
4+
import org.nodeclipse.enide.maven.preferences.MavenConstants;
5+
6+
/**
7+
* Using "Run As" --> "mvn tomcat6:start Maven start" will lead here</br>
8+
* http://tomcat.apache.org/maven-plugin-2.2/context-goals.html
9+
**/
10+
public class LaunchShortcut extends org.nodeclipse.enide.maven.launchexec.LaunchShortcut implements ILaunchShortcut {
11+
12+
@Override
13+
protected String getLaunchConfigurationTypeConstant() {
14+
return MavenConstants.LAUNCH_GOAL2_CONFIGURATION_TYPE_ID;
15+
}
16+
17+
}

org.nodeclipse.enide.maven/src/org/nodeclipse/enide/maven/preferences/MavenConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ public class MavenConstants {
44

55
public static final String PLUGIN_ID = "org.nodeclipse.enide.maven";
66
public static final String LAUNCH_CONFIGURATION_TYPE_ID = "org.nodeclipse.enide.maven.launch.LaunchConfigurationType";
7+
public static final String LAUNCH_GOAL1_CONFIGURATION_TYPE_ID = "org.nodeclipse.enide.maven.launch.goal1.LaunchConfigurationType";
8+
public static final String LAUNCH_GOAL2_CONFIGURATION_TYPE_ID = "org.nodeclipse.enide.maven.launch.goal2.LaunchConfigurationType";
79
public static final String LAUNCH_EXEC_CONFIGURATION_TYPE_ID = "org.nodeclipse.enide.maven.launchexec.LaunchConfigurationType";
810
public static final String LAUNCH_JETTY_CONFIGURATION_TYPE_ID = "org.nodeclipse.enide.maven.launch.jetty.LaunchConfigurationType";
911
public static final String LAUNCH_TOMCAT_CONFIGURATION_TYPE_ID = "org.nodeclipse.enide.maven.launch.tomcat.LaunchConfigurationType";
@@ -24,6 +26,8 @@ public class MavenConstants {
2426
public static final String MAVEN_PATH = "maven_path"; //@deprecated
2527
public static final String MAVEN_OPTS = "maven_opts";
2628
public static final String MAVEN_OPTIONS = "maven_options";
29+
public static final String MAVEN_GOAL1 = "maven_goal1";
30+
public static final String MAVEN_GOAL2 = "maven_goal2";
2731
public static final String MAVEN_OPTION_SHOW_VERSION = "maven_option_show_version";
2832
public static final String MAVEN_OPTION_DEBUG = "maven_option_debug";
2933
public static final String MAVEN_OPTION_QUIET = "maven_option_quite";

0 commit comments

Comments
 (0)