2323import java .util .Optional ;
2424
2525import org .apache .maven .artifact .versioning .InvalidVersionSpecificationException ;
26+ import org .apache .maven .cli .CLIManager ;
2627import org .eclipse .core .resources .IProject ;
2728import org .eclipse .core .runtime .CoreException ;
2829import org .eclipse .core .runtime .NullProgressMonitor ;
@@ -93,7 +94,7 @@ public void testGetBestMatchingVM_1XversionRange() throws InvalidVersionSpecific
9394 */
9495 @ Test
9596 public void testGlobalSettings () throws Exception {
96- assertMavenLaunchFileSetting (IMavenConfiguration ::setGlobalSettingsFile , "-gs" , "./resources/settings/empty_settings/settings_empty.xml" );
97+ assertMavenLaunchFileSetting (IMavenConfiguration ::setGlobalSettingsFile , CLIManager . ALTERNATE_GLOBAL_SETTINGS , "./resources/settings/empty_settings/settings_empty.xml" );
9798 }
9899
99100 /**
@@ -103,7 +104,7 @@ public void testGlobalSettings() throws Exception {
103104 */
104105 @ Test
105106 public void testGlobalSettings_GoalOverride () throws Exception {
106- assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setGlobalSettingsFile , "-gs" , "./resources/settings/empty_settings/settings_empty.xml" );
107+ assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setGlobalSettingsFile , CLIManager . ALTERNATE_GLOBAL_SETTINGS , "./resources/settings/empty_settings/settings_empty.xml" );
107108 }
108109
109110 /**
@@ -122,7 +123,7 @@ public void testGlobalSettings_Invalid() throws Exception {
122123 */
123124 @ Test
124125 public void testGlobalToolchains () throws Exception {
125- assertMavenLaunchFileSetting (IMavenConfiguration ::setGlobalToolchainsFile , "-gt" , "./resources/settings/empty_settings/toolchains_empty.xml" );
126+ assertMavenLaunchFileSetting (IMavenConfiguration ::setGlobalToolchainsFile , CLIManager . ALTERNATE_GLOBAL_TOOLCHAINS , "./resources/settings/empty_settings/toolchains_empty.xml" );
126127 }
127128
128129 /**
@@ -132,7 +133,7 @@ public void testGlobalToolchains() throws Exception {
132133 */
133134 @ Test
134135 public void testGlobalToolchains_GoalOverride () throws Exception {
135- assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setGlobalToolchainsFile , "-gt" , "./resources/settings/empty_settings/toolchains_empty.xml" );
136+ assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setGlobalToolchainsFile , CLIManager . ALTERNATE_GLOBAL_TOOLCHAINS , "./resources/settings/empty_settings/toolchains_empty.xml" );
136137 }
137138
138139 /**
@@ -168,7 +169,7 @@ public void testRequiredJavaVersionFromEnforcerRule_NoVersionRange() throws Exce
168169 */
169170 @ Test
170171 public void testUserSettings () throws Exception {
171- assertMavenLaunchFileSetting (IMavenConfiguration ::setUserSettingsFile , "-s" , "./resources/settings/empty_settings/settings_empty.xml" );
172+ assertMavenLaunchFileSetting (IMavenConfiguration ::setUserSettingsFile , String . valueOf ( CLIManager . ALTERNATE_USER_SETTINGS ) , "./resources/settings/empty_settings/settings_empty.xml" );
172173 }
173174
174175 /**
@@ -178,7 +179,7 @@ public void testUserSettings() throws Exception {
178179 */
179180 @ Test
180181 public void testUserSettings_GoalOverride () throws Exception {
181- assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setUserSettingsFile , "-s" , "./resources/settings/empty_settings/settings_empty.xml" );
182+ assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setUserSettingsFile , String . valueOf ( CLIManager . ALTERNATE_USER_SETTINGS ) , "./resources/settings/empty_settings/settings_empty.xml" );
182183 }
183184
184185 /**
@@ -198,7 +199,7 @@ public void testUserSettings_Invalid() throws Exception {
198199 */
199200 @ Test
200201 public void testUserToolchains () throws Exception {
201- assertMavenLaunchFileSetting (IMavenConfiguration ::setUserToolchainsFile , "-t" , "./resources/settings/empty_settings/toolchains_empty.xml" );
202+ assertMavenLaunchFileSetting (IMavenConfiguration ::setUserToolchainsFile , String . valueOf ( CLIManager . ALTERNATE_USER_TOOLCHAINS ) , "./resources/settings/empty_settings/toolchains_empty.xml" );
202203 }
203204
204205 /**
@@ -208,7 +209,7 @@ public void testUserToolchains() throws Exception {
208209 */
209210 @ Test
210211 public void testUserToolchains_GoalOverride () throws Exception {
211- assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setUserToolchainsFile , "-t" , "./resources/settings/empty_settings/toolchains_empty.xml" );
212+ assertMavenLaunchFileSettingGoalOverride (IMavenConfiguration ::setUserToolchainsFile , String . valueOf ( CLIManager . ALTERNATE_USER_TOOLCHAINS ) , "./resources/settings/empty_settings/toolchains_empty.xml" );
212213 }
213214
214215 /**
@@ -275,12 +276,13 @@ private void assertMavenLaunchConfig(CoreBiConsumer<IMavenConfiguration, String>
275276 */
276277 private void assertMavenLaunchFileSetting (CoreBiConsumer <IMavenConfiguration , String > configSetter , String key , String relativePath )
277278 throws Exception {
279+ final String param = "-" + key ;
278280 this .assertMavenLaunchConfig (configSetter , null , (launcher , config ) -> {
279281 String programArguments = launcher .getProgramArguments (config );
280282
281283 // prepare assert
282284 Matcher <String > allSettings = CoreMatchers .allOf (
283- CoreMatchers .containsString (key ),
285+ CoreMatchers .containsString (param ),
284286 CoreMatchers .containsString (new File (relativePath ).getAbsolutePath ())
285287 );
286288
@@ -299,14 +301,15 @@ private void assertMavenLaunchFileSetting(CoreBiConsumer<IMavenConfiguration, St
299301 private void assertMavenLaunchFileSettingGoalOverride (CoreBiConsumer <IMavenConfiguration , String > configSetter , String key , String relativePath )
300302 throws Exception {
301303 final String userDerivedPath = "./resources/settings/empty_settings/this_do_not_exists.xml" ;
302- final String goalConfig = "clean " + key + " " + userDerivedPath ;
304+ final String param = "-" + key ;
305+ final String goalConfig = "clean " + param + " " + userDerivedPath ;
303306
304307 this .assertMavenLaunchConfig (configSetter , goalConfig , (launcher , config ) -> {
305308 String programArguments = launcher .getProgramArguments (config );
306309
307310 // prepare assert
308311 Matcher <String > allSettings = CoreMatchers .allOf (
309- CoreMatchers .containsString (key ),
312+ CoreMatchers .containsString (param ),
310313 CoreMatchers .containsString (userDerivedPath ),
311314 CoreMatchers .not (CoreMatchers .containsString (relativePath ))
312315 );
0 commit comments