Permalink
Browse files

Overwrite existing profile if it exist

  • Loading branch information...
1 parent 01b261d commit ca397e3a2062dfce38db8634915473dd406cebfd @aslakknutsen committed Mar 16, 2012
@@ -27,6 +27,7 @@ public void addProfile(String profileId, Dependency... dependencies)
{
MavenCoreFacet facet = project.getFacet(MavenCoreFacet.class);
+
Profile profile = new Profile();
profile.setId(profileId);
@@ -36,8 +37,25 @@ public void addProfile(String profileId, Dependency... dependencies)
}
Model pom = facet.getPOM();
+ Profile existingProfile = findProfileById(profileId, pom);
+ if(existingProfile != null)
+ {
+ pom.removeProfile(existingProfile);
+ }
pom.addProfile(profile);
facet.setPOM(pom);
}
+
+ private Profile findProfileById(String profileId, Model pom)
+ {
+ for (Profile profile : pom.getProfiles())
+ {
+ if (profileId.equalsIgnoreCase(profile.getId()))
+ {
+ return profile;
+ }
+ }
+ return null;
+ }
}
@@ -270,6 +270,29 @@ public void installWWeblogicRemoteContainer() throws Exception
new DependencyMatcher("arquillian-wls-remote-10.3")));
}
+ @Test
+ public void installMultipleTimesShouldOverwriteProfile() throws Exception
+ {
+ Project project = initializeJavaProject();
+
+ MavenCoreFacet coreFacet = project.getFacet(MavenCoreFacet.class);
+
+ List<Profile> profiles = coreFacet.getPOM().getProfiles();
+ for (Profile profile : profiles) {
+ System.out.println(profile.getId());
+ }
+ assertThat(profiles.size(), is(0));
+
+ queueInputLines("JBOSS_AS_REMOTE_7.X", "19", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
+ getShell().execute("arquillian setup");
+
+ queueInputLines("JBOSS_AS_REMOTE_7.X", "19", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
+ getShell().execute("arquillian setup");
+
+ assertThat(coreFacet.getPOM().getProfiles().size(), is(1));
+
+ }
+
@Test
public void installContainerWithDownload() throws Exception
{

0 comments on commit ca397e3

Please sign in to comment.