Skip to content

Commit

Permalink
SHRINKRES-261 When multiple settings.xml files are merged then all
Browse files Browse the repository at this point in the history
profiles activated by default are taken; modified testcase to verify
that settings.xml files are used correctly
  • Loading branch information
MatousJobanek committed Jan 4, 2017
1 parent 47a1873 commit 2457508
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ public List<Profile> getActiveProfiles(Collection<Profile> profiles, ProfileActi
if (p.getId() != null && context.getActiveProfileIds().contains(id)
&& !context.getInactiveProfileIds().contains(id)) {
activeProfiles.add(p);
continue;
}
if (p.getActivation() != null && p.getActivation().isActiveByDefault()
&& !context.getInactiveProfileIds().contains(p.getId())) {
activeProfiles.add(p);
break;
continue;
}
for (ProfileActivator activator : activators) {
if (activator.isActive(p, context, problems)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
*/
package org.jboss.shrinkwrap.resolver.impl.maven.bootstrap;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -30,6 +26,10 @@
import org.junit.BeforeClass;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;

/**
* Verifies that default paths to maven settings.xml files are set by default.
* See https://issues.jboss.org/browse/SHRINKRES-127 for more details.
Expand Down Expand Up @@ -68,7 +68,8 @@ public void loadDefaultGlobalSettingsXmlLocation() {
Assert.assertThat(request.getGlobalSettingsFile(), is(not(nullValue())));

Assert.assertThat(request.getGlobalSettingsFile().getPath(),
is(System.getenv("M2_HOME") + "/conf/settings.xml".replace('/', File.separatorChar)));
is((System.getenv("M2_HOME") + "/conf/settings.xml".replace("/", File.separator))
.replaceAll(File.separator + File.separator, File.separator)));
}

// this is calling internal private method that handles logic of settings.xml setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
package org.jboss.shrinkwrap.resolver.impl.maven.bootstrap;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.jboss.shrinkwrap.resolver.api.NoResolvedResultException;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.jboss.shrinkwrap.resolver.impl.maven.util.ValidationUtil;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

Expand All @@ -43,6 +46,12 @@ public static void initialize() {
// will be used!
}

@Before
public void cleanLocalRepos() throws IOException {
FileUtils.deleteDirectory(new File("target/profile-repository"));
FileUtils.deleteDirectory(new File("target/syspropertyrepo"));
}

@Test
public void overrideUserSettings() {
System.setProperty(MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION, SETTINGS_XML_PATH);
Expand All @@ -58,8 +67,7 @@ public void overrideUserSettings() {

@Test
public void overrideGlobalSettings() {
System.setProperty(MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION,
"target/settings/profiles/settings.xml");
System.setProperty(MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION, SETTINGS_XML_PATH);

File[] files = Maven.resolver().resolve("org.jboss.shrinkwrap.test:test-deps-c:1.0.0").withTransitivity()
.as(File.class);
Expand Down

0 comments on commit 2457508

Please sign in to comment.