if ( project.getActiveProfiles() != null ) setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) );
if ( project.getActiveProfiles() != null ) setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) );
List activeProfiles = project.getActiveProfiles();
public List<Profile> getActiveProfiles() { return wrapped.getActiveProfiles(); }
public List getActiveProfiles() { return getDelegate().getActiveProfiles(); }
private List<String> profilesToActivate() { final List<String> profiles = new ArrayList<String>(); if (getReleaseProfilesOrNull() != null) { profiles.addAll(getReleaseProfilesOrNull()); } for (final Object activatedProfile : project.getActiveProfiles()) { profiles.add(((org.apache.maven.model.Profile) activatedProfile).getId()); } return profiles; }
protected Artifact getSwfArtifact() throws MojoExecutionException { if ((project.getActiveProfiles() != null) && SWF.equals(project.getArtifact().getType())) { return project.getArtifact(); } for (Artifact attachedArtifact : project.getAttachedArtifacts()) { if (SWF.equalsIgnoreCase(attachedArtifact.getType())) { return attachedArtifact; } } Set<Artifact> swfArtifacts = getDependencies(type(SWF), scope("compile")); if (swfArtifacts.size() == 1) { return swfArtifacts.iterator().next(); } else if (swfArtifacts.size() > 1) { throw new MojoExecutionException("More than one SWF artifact with scope compile added as dependency."); } return null; }
/** * (Darren) this code lifted from mvn help:active-profiles plugin Recurses * into the project's parent poms to find the active profiles of the * specified project and all its parents. * * @param project * The project to start with * @return A list of active profiles */ static List collectActiveProfiles(final MavenProject project) { final List profiles = project.getActiveProfiles(); if (project.hasParent()) { profiles.addAll(collectActiveProfiles(project.getParent())); } return profiles; }
public List<String> getMergedActiveProfiles(boolean shared) { Set<String> prifileides = new HashSet<String>(); MavenProject mavenProject = nmp.getOriginalMavenProject(); List<Profile> profiles = mavenProject.getActiveProfiles(); for (Profile profile : profiles) { prifileides.add(profile.getId()); } //read from Settings.xml List<String> profileStrings = MavenSettingsSingleton.getInstance().createUserSettingsModel().getActiveProfiles(); for (String profile : profileStrings) { prifileides.add(profile); } File basedir = FileUtil.normalizeFile(mavenProject.getBasedir()); FileObject fileObject = FileUtil.toFileObject(basedir); //read from profiles.xml Iterator it2 = MavenSettingsSingleton.createProfilesModel(fileObject).getActiveProfiles().iterator(); while (it2.hasNext()) { prifileides.add((String) it2.next()); } prifileides.addAll(getActiveProfiles(shared)); return new ArrayList<String>(prifileides); }
@Test public void testNoActiveProfilesInProjectAndNoProfilesExpectedToBeActivated() throws EnforcerRuleException { when( project.getActiveProfiles() ).thenReturn( Collections.<Profile> emptyList() ); rule.execute( helper ); assertTrue( true ); }
@Test( expected = EnforcerRuleException.class ) public void testNoActiveProfileButTheRuleRequestedAnActiveProfile() throws EnforcerRuleException { when( project.getActiveProfiles() ).thenReturn( Collections.<Profile> emptyList() ); rule.setProfiles( "profile-2" ); rule.execute( helper ); // intentionally no assertTrue(...) }
private static void interpolate(Map<String, String> dict, MavenProject p) { if (p == null) { return; } interpolate(dict, p.getParent()); interpolate(dict, p.getModel()); for (ModelBase model: p.getActiveProfiles()) { interpolate(dict, model); } }
private static void interpolate(Map<String, String> dict, MavenProject p) { if (p == null) { return; } interpolate(dict, p.getParent()); interpolate(dict, p.getModel()); for (ModelBase model: p.getActiveProfiles()) { interpolate(dict, model); } }
@Test( expected = EnforcerRuleException.class ) public void testNoActiveProfileButWeExpectToGetAnExceptionWithAll() throws EnforcerRuleException { when( project.getActiveProfiles() ).thenReturn( Collections.<Profile> emptyList() ); rule.setProfiles( "profile-2" ); rule.setAll( true ); rule.execute( helper ); // intentionally no assertTrue(...) }
@Test( expected = EnforcerRuleException.class ) public void testOneActiveProfilesWithTwoRequiredProfiles() throws EnforcerRuleException, ExpressionEvaluationException { List<Profile> profiles = Collections.singletonList( createProfile( "profile-X" ) ); when( project.getActiveProfiles() ).thenReturn( profiles ); rule.setProfiles( "profile-X,profile-Y" ); rule.setAll( true ); rule.execute( helper ); // intentionally no assertTrue(..) }
@Test public void testOneActiveProfileWithTwoProfilesButNotAll() throws EnforcerRuleException, ExpressionEvaluationException { List<Profile> profiles = Collections.singletonList( createProfile( "profile-X" ) ); when( project.getActiveProfiles() ).thenReturn( profiles ); rule.setProfiles( "profile-X,profile-Y" ); rule.setAll( false ); rule.execute( helper ); // intentionally no assertTrue(..) }
@Test public void testActiveProfileAndExpectedActiveProfile() throws EnforcerRuleException { List<Profile> profiles = Collections.<Profile> singletonList( createProfile( "profile-2" ) ); when( project.getActiveProfiles() ).thenReturn( profiles ); rule.setProfiles( "profile-2" ); rule.execute( helper ); assertTrue( true ); }
@Test public void testTwoActiveProfilesWithOneRequiredProfile() throws EnforcerRuleException { List<Profile> profiles = Arrays.asList( createProfile( "profile-1" ), createProfile( "profile-2" ) ); when( project.getActiveProfiles() ).thenReturn( profiles ); rule.setProfiles( "profile-2" ); rule.execute( helper ); assertTrue( true ); }
@Test( expected = EnforcerRuleException.class ) public void testTwoActiveProfilesWithTwoRequiredProfilesWhereOneOfThemIsNotPartOfTheActiveProfiles() throws EnforcerRuleException, ExpressionEvaluationException { List<Profile> profiles = Arrays.asList( createProfile( "profile-X" ), createProfile( "profile-Y" ) ); when( project.getActiveProfiles() ).thenReturn( profiles ); rule.setProfiles( "profile-Z,profile-X" ); rule.setAll( true ); rule.execute( helper ); // intentionally no assertTrue(..) }
@Test public void testTwoActiveProfilesWhereOneProfileIsRequiredToBeActivated() throws EnforcerRuleException { List<Profile> profiles = Arrays.asList( createProfile( "profile-1" ), createProfile( "profile-2" ) ); when( project.getActiveProfiles() ).thenReturn( profiles ); rule.setProfiles( "profile-2" ); rule.setAll( true ); rule.execute( helper ); assertTrue( true ); }