@Test public void testGlobalSettingsProgramArguments() throws Exception { IMavenConfiguration mavenConfig = MavenPlugin.getMavenConfiguration(); MockLaunchConfiguration configuration = getLaunchConfiguration("projects/444262_settings"); try { performDummyLaunch(configuration); assertArrayEquals(new String[] {"-B"}, runner.getConfiguration().getProgramArguments()); // relative preference path to global settings is relative to eclipse home mavenConfig.setGlobalSettingsFile("settings_empty.xml"); performDummyLaunch(configuration); assertArrayEquals( new String[] {"-B", "-gs", new File("settings_empty.xml").getAbsolutePath()}, runner.getConfiguration().getProgramArguments()); // specifying -gs within goals overrides global settings from configuration configuration .getAttributes() .put(MavenLaunchConstants.ATTR_GOALS, "clean -gs other_settings.xml"); performDummyLaunch(configuration); assertArrayEquals( new String[] {"-B", "clean", "-gs", "other_settings.xml"}, runner.getConfiguration().getProgramArguments()); } finally { mavenConfig.setGlobalSettingsFile(null); } }
@Test public void testUserSettingsProgramArguments() throws Exception { IMavenConfiguration mavenConfig = MavenPlugin.getMavenConfiguration(); MockLaunchConfiguration configuration = getLaunchConfiguration("projects/444262_settings"); try { mavenConfig.setUserSettingsFile(new File("settings_empty.xml").getAbsolutePath()); performDummyLaunch(configuration); assertArrayEquals( new String[] {"-B", "-s", mavenConfig.getUserSettingsFile()}, runner.getConfiguration().getProgramArguments()); configuration.getAttributes().put(MavenLaunchConstants.ATTR_USER_SETTINGS, "settings.xml"); performDummyLaunch(configuration); assertArrayEquals( new String[] {"-B", "-s", "settings.xml"}, runner.getConfiguration().getProgramArguments()); } finally { mavenConfig.setUserSettingsFile(null); } }