if ( profile.getActivation() != null ) writeActivation( (Activation) profile.getActivation(), "activation", serializer ); if ( ( profile.getProperties() != null ) && ( profile.getProperties().size() > 0 ) ) for ( Iterator iter = profile.getProperties().keySet().iterator(); iter.hasNext(); ) String value = (String) profile.getProperties().get( key ); serializer.startTag( NAMESPACE, "" + key + "" ).text( value ).endTag( NAMESPACE, "" + key + "" ); if ( ( profile.getRepositories() != null ) && ( profile.getRepositories().size() > 0 ) ) for ( Iterator iter = profile.getRepositories().iterator(); iter.hasNext(); ) if ( ( profile.getPluginRepositories() != null ) && ( profile.getPluginRepositories().size() > 0 ) ) for ( Iterator iter = profile.getPluginRepositories().iterator(); iter.hasNext(); ) if ( ( profile.getId() != null ) && !profile.getId().equals( "default" ) ) serializer.startTag( NAMESPACE, "id" ).text( profile.getId() ).endTag( NAMESPACE, "id" );
Profile profile = new Profile(); for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) profile.setActivation( parseActivation( parser, strict ) ); profile.addProperty( key, value ); profile.setRepositories( repositories ); while ( parser.nextTag() == XmlPullParser.START_TAG ) profile.setPluginRepositories( pluginRepositories ); while ( parser.nextTag() == XmlPullParser.START_TAG ) profile.setId( interpolatedTrimmed( parser.nextText(), "id" ) );
if ( !profileIds.add( profile.getId() ) ) "must be unique but found duplicate profile with id " + profile.getId() ); String prefix = "profiles.profile[" + profile.getId() + "]."; validateRepositories( problems, profile.getRepositories(), prefix + "repositories.repository" ); validateRepositories( problems, profile.getPluginRepositories(), prefix + "pluginRepositories.pluginRepository" );
public static List<Repository> getRepositories() { List<Repository> repositories = new LinkedList<Repository>(); Settings settings = getSettings(); Set<String> profileNames = new LinkedHashSet<String>(); profileNames.addAll(settings.getActiveProfiles()); for (Profile p : settings.getProfiles()) { if (p.getActivation() != null && p.getActivation().isActiveByDefault()) { profileNames.add(p.getId()); } } for (String profileName : profileNames) { Object obj = settings.getProfilesAsMap().get(profileName); if (Profile.class.isAssignableFrom(obj.getClass())) { Profile p = (Profile) obj; for (Repository repository : p.getRepositories()) { repositories.add(repository); } } } return repositories; }
private boolean isProfileActive( Profile profile ) { return settings.getActiveProfiles().contains( profile.getId() ) || ( profile.getActivation() != null && profile.getActivation().isActiveByDefault() ); }
/** * Method addRepository. * * @param repository */ public void addRepository( Repository repository ) { getRepositories().add( repository ); } //-- void addRepository( Repository )
public ProfileAdapter(final org.apache.maven.settings.Profile profile) { setId(profile.getId()); Activation activation = new Activation(); setActivation(activation); for (org.apache.maven.settings.Repository repository : profile.getRepositories()) { Repository mavenRepository = new Repository(); mavenRepository.setId(repository.getId()); mavenRepository.setUrl(repository.getUrl()); getRepositories().add(mavenRepository); } setProperties(profile.getProperties()); }
/** * @return a Map of profiles field with <code>Profile#getId()</code> as key * @see org.apache.maven.settings.Profile#getId() */ public java.util.Map<String, Profile> getProfilesAsMap() { if ( profileMap == null ) { profileMap = new java.util.LinkedHashMap<String, Profile>(); if ( getProfiles() != null ) { for ( Profile profile : getProfiles() ) { profileMap.put( profile.getId(), profile ); } } } return profileMap; }
if (activeMavenProfiles.size() == 0) { for (Map.Entry<String, Profile> profile : mavenProfiles.entrySet()) { if (profile.getValue().getActivation() != null && profile.getValue().getActivation().isActiveByDefault()) { activeMavenProfiles.add(profile.getKey()); for (String activeProfile : activeMavenProfiles) { Profile profile = mavenProfiles.get(activeProfile); List<Repository> profileRepositories = profile.getRepositories(); for (Repository repository : profileRepositories) { RemoteRepository remoteRepository = new RemoteRepository.Builder(repository.getId(), "default",
if (profile.getRepositories().stream().anyMatch((r) -> id.equals(r.getId()))) { List<Repository> newRepos = profile.getRepositories().stream() .filter((r) -> !id.equals(r.getId())).collect(Collectors.toList()); profile.setRepositories(newRepos); System.out.printf("Repository with ID \"%s\" was removed from profile \"%s\"\n", id, profile.getId()); break;
private Collection<RemoteRepository> initExtraRepositories() { Collection<RemoteRepository> extraRepositories = new HashSet<RemoteRepository>(); for ( Profile profile : settings.getProfiles() ) { if ( isProfileActive( profile ) ) { for ( Repository repository : profile.getRepositories() ) { extraRepositories.add( toRemoteRepositoryBuilder( settings, repository ).build() ); } for ( Repository repository : profile.getPluginRepositories() ) { extraRepositories.add( toRemoteRepositoryBuilder( settings, repository ).build() ); } } } return extraRepositories; }
if (!this.profiles.contains(profile.getId())) { continue; for (Map.Entry<Object, Object> entry : profile.getProperties().entrySet()) { this.properties.put((String) entry.getKey(), (String) entry.getValue());
private static void logSettingsProfileList( List<org.apache.maven.settings.Profile> profiles, String type ) { log.debug( String.format( "%s %s profiles.", type, profiles.size() ) ); for ( org.apache.maven.settings.Profile profile : profiles ) { log.debug( " {}", String.format("Profile {id: %s, source: %s}", profile.getId(), profile.getSourceLevel() ) ); } } }
private static void addActiveProfileRepositories(List<Profile> activeProfiles, List<RepositoryConfiguration> configurations) { for (Profile activeProfile : activeProfiles) { Interpolator interpolator = new RegexBasedInterpolator(); interpolator.addValueSource( new PropertiesBasedValueSource(activeProfile.getProperties())); for (Repository repository : activeProfile.getRepositories()) { configurations.add(getRepositoryConfiguration(interpolator, repository)); } } }
private String getPropertyValue(String propertyName) throws MojoFailureException { Map<String, Profile> profiles = settings.getProfilesAsMap(); List<String> activeProfiles = settings.getActiveProfiles(); for(String id: activeProfiles){ Profile profile = profiles.get(id); if(profile != null){ Properties properties = profile.getProperties(); if(properties != null){ String property = properties.getProperty(propertyName); if(property != null){ getLog().info("Resolve deploy repository url: " + propertyName + " => " + property); return property; } } } } for(Profile profile: settings.getProfiles()){ if(profile.getActivation() != null && profile.getActivation().isActiveByDefault()){ Properties properties = profile.getProperties(); if(properties != null){ String property = properties.getProperty(propertyName); if(property != null){ getLog().info("Resolve deploy repository url: " + propertyName + " => " + property); return property; } } } } throw new MojoFailureException("Can not resolve deploy repository url: " + propertyName); }
Profile profile = new Profile(); profile.setId( modelProfile.getId() ); profile.setActivation( activation ); profile.setProperties( modelProfile.getProperties() ); profile.addRepository( convertToSettingsRepository( repo ) ); profile.addPluginRepository( convertToSettingsRepository( pluginRepo ) );
/** * Method addProperty. * * @param key * @param value */ public void addProperty( String key, String value ) { getProperties().put( key, value ); } //-- void addProperty( String, String )
public org.apache.maven.settings.Profile getFullSampleProfile(String id, Properties profileProperties) { org.apache.maven.settings.Profile profile = new org.apache.maven.settings.Profile(); profile.setId(id); for (GlobalParameter globalParameter : globalParameters) { if (!globalParameter.valueGuessedByDefault) { String value; if (profileProperties.containsKey(globalParameter.property)) { value = profileProperties.getProperty(globalParameter.property); } else { value = "[...]"; } profile.getProperties().put(globalParameter.property, value); } } return profile; }
/** * Method addPluginRepository. * * @param repository */ public void addPluginRepository( Repository repository ) { getPluginRepositories().add( repository ); } //-- void addPluginRepository( Repository )
Profile myProfile = new Profile(); if (repoRoot != null) { myProfile.setId(PROFILE_PUBLIC);//NOI18N Repository repo = new Repository(); repo.setUrl("file://" + repoRoot.getAbsolutePath());//NOI18N repo.setSnapshots(snap); repo.setName("NetBeans IDE internal Repository hosting plugins that are executable in NetBeans IDE only.");//NOI18N myProfile.addPluginRepository(repo); Activation act = new Activation(); ActivationProperty prop = new ActivationProperty(); prop.setValue("true");//NOI18N act.setProperty(prop); myProfile.setActivation(act);