本文整理匯總了Java中org.apache.maven.settings.Settings.getActiveProfiles方法的典型用法代碼示例。如果您正苦於以下問題:Java Settings.getActiveProfiles方法的具體用法?Java Settings.getActiveProfiles怎麽用?Java Settings.getActiveProfiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.settings.Settings
的用法示例。
在下文中一共展示了Settings.getActiveProfiles方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPropertyValueInSettings
import org.apache.maven.settings.Settings; //導入方法依賴的package包/類
@SuppressWarnings("unchecked") // because of Maven poor typing
public String getPropertyValueInSettings(String propertyName, Settings settings) {
if (settings == null) {
return null;
}
List<String> activeProfiles = settings.getActiveProfiles();
for (Object _profileWithId : settings.getProfilesAsMap().entrySet()) {
Entry<String, Profile> profileWithId = (Entry<String, Profile>) _profileWithId;
if (activeProfiles.contains(profileWithId.getKey())) {
Profile profile = profileWithId.getValue();
String value = profile.getProperties().getProperty(propertyName);
if (value != null) {
return value;
}
}
}
return null;
}
示例2: getRepositoryList
import org.apache.maven.settings.Settings; //導入方法依賴的package包/類
public static List<RemoteRepository> getRepositoryList() throws SettingsBuildingException {
List<RemoteRepository> repos = new ArrayList<RemoteRepository>();
RemoteRepository central =
new RemoteRepository.Builder("central", "default",
"http://repo1.maven.org/maven2/").build();
// Without this we wouldn't be able to find SNAPSHOT builds of plugins we
// haven't built and installed locally ourselves
RemoteRepository gateRepo = new RemoteRepository.Builder("gate", "default",
"http://repo.gate.ac.uk/content/groups/public/").build();
// Add all repos from settings.xml
// http://stackoverflow.com/questions/27818659/loading-mavens-settings-xml-for-jcabi-aether-to-use
Settings effectiveSettings = loadMavenSettings();
Map<String, Profile> profilesMap = effectiveSettings.getProfilesAsMap();
for(String profileName : effectiveSettings.getActiveProfiles()) {
Profile profile = profilesMap.get(profileName);
List<Repository> repositories = profile.getRepositories();
for(Repository repo : repositories) {
RemoteRepository remoteRepo =
new RemoteRepository.Builder(repo.getId(), "default",
repo.getUrl()).build();
repos.add(remoteRepo);
}
}
repos.add(central);
repos.add(gateRepo);
return repos;
}
示例3: getActiveProfiles
import org.apache.maven.settings.Settings; //導入方法依賴的package包/類
private List<String> getActiveProfiles(Settings settings) {
if (settings == null) return null;
List<String> result = settings.getActiveProfiles();
for (org.apache.maven.settings.Profile profile : settings.getProfiles()) {
if (profile.getActivation().isActiveByDefault() && !result.contains(profile.getId())) {
result.add(profile.getId());
}
}
return result;
}
示例4: repositoriesLegacy
import org.apache.maven.settings.Settings; //導入方法依賴的package包/類
private static List<ArtifactRepository> repositoriesLegacy(LegacyRepositorySystem legacy, Settings settings)
throws InvalidRepositoryException {
boolean central;
List<ArtifactRepository> result;
List<String> actives;
ArtifactRepository artifactRepository;
central = false;
result = new ArrayList<>();
actives = settings.getActiveProfiles();
for (Profile profile : settings.getProfiles()) {
if (actives.contains(profile.getId()) || (profile.getActivation() != null && profile.getActivation().isActiveByDefault())) {
for (org.apache.maven.model.Repository repository : SettingsUtils.convertFromSettingsProfile(profile).getRepositories()) {
artifactRepository = legacy.buildArtifactRepository(repository);
if ("central".equals(artifactRepository.getId())) {
central = true;
}
result.add(artifactRepository);
}
}
}
if (!central) {
/* Maven defines the default central repository in its master parent - and not in the default settings, which I'd prefer.
As a consequent, central is not always defined when loading the settings.
I first added central to repositories only, because legacy repositories are used to load poms which ultimatly load the
master parent with it's repository definition. However, the parent might have to be loaded from central, so repositories
also need a central definition. */
result.add(legacy.createDefaultRemoteRepository());
}
return result;
}
示例5: addSettingsProfileRepositoriesTo
import org.apache.maven.settings.Settings; //導入方法依賴的package包/類
private void addSettingsProfileRepositoriesTo( final Set<Location> locs, final Settings settings,
final List<String> activeProfiles,
final MirrorSelector mirrorSelector )
throws MalformedURLException
{
if ( settings != null )
{
final Map<String, Profile> profiles = settings.getProfilesAsMap();
if ( profiles != null && activeProfiles != null && !activeProfiles.isEmpty() )
{
final LinkedHashSet<String> active = new LinkedHashSet<>( activeProfiles );
final List<String> settingsActiveProfiles = settings.getActiveProfiles();
if ( settingsActiveProfiles != null && !settingsActiveProfiles.isEmpty() )
{
active.addAll( settingsActiveProfiles );
}
for ( final String profileId : active )
{
final Profile profile = profiles.get( profileId );
if ( profile != null )
{
final List<Repository> repositories = profile.getRepositories();
if ( repositories != null )
{
final List<Mirror> mirrors = settings.getMirrors();
final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
for ( final Repository repo : repositories )
{
String id = repo.getId();
String url = repo.getUrl();
if ( mirrors != null )
{
final ArtifactRepositoryPolicy snapshots = convertPolicy( repo.getSnapshots() );
final ArtifactRepositoryPolicy releases = convertPolicy( repo.getReleases() );
final MavenArtifactRepository arepo =
new MavenArtifactRepository( id, url, layout, snapshots, releases );
final Mirror mirror =
mirrorSelector == null ? null : mirrorSelector.getMirror( arepo, mirrors );
if ( mirror != null )
{
id = mirror.getId();
url = mirror.getUrl();
}
SimpleHttpLocation addition = new SimpleHttpLocation( id, url, snapshots.isEnabled(), releases.isEnabled(), true, false, null );
addition.setAttribute(Location.CONNECTION_TIMEOUT_SECONDS, 60);
locs.add (addition);
}
}
}
}
}
}
}
}
示例6: merge
import org.apache.maven.settings.Settings; //導入方法依賴的package包/類
/**
* @param dominant
* @param recessive
* @param recessiveSourceLevel
*/
public void merge( Settings dominant, Settings recessive, String recessiveSourceLevel )
{
if ( dominant == null || recessive == null )
{
return;
}
recessive.setSourceLevel( recessiveSourceLevel );
List<String> dominantActiveProfiles = dominant.getActiveProfiles();
List<String> recessiveActiveProfiles = recessive.getActiveProfiles();
if ( recessiveActiveProfiles != null )
{
if ( dominantActiveProfiles == null )
{
dominantActiveProfiles = new ArrayList<String>();
dominant.setActiveProfiles( dominantActiveProfiles );
}
for ( String profileId : recessiveActiveProfiles )
{
if ( !dominantActiveProfiles.contains( profileId ) )
{
dominantActiveProfiles.add( profileId );
}
}
}
List<String> dominantPluginGroupIds = dominant.getPluginGroups();
List<String> recessivePluginGroupIds = recessive.getPluginGroups();
if ( recessivePluginGroupIds != null )
{
if ( dominantPluginGroupIds == null )
{
dominantPluginGroupIds = new ArrayList<String>();
dominant.setPluginGroups( dominantPluginGroupIds );
}
for ( String pluginGroupId : recessivePluginGroupIds )
{
if ( !dominantPluginGroupIds.contains( pluginGroupId ) )
{
dominantPluginGroupIds.add( pluginGroupId );
}
}
}
if ( StringUtils.isEmpty( dominant.getLocalRepository() ) )
{
dominant.setLocalRepository( recessive.getLocalRepository() );
}
shallowMergeById( dominant.getMirrors(), recessive.getMirrors(), recessiveSourceLevel );
shallowMergeById( dominant.getServers(), recessive.getServers(), recessiveSourceLevel );
shallowMergeById( dominant.getProxies(), recessive.getProxies(), recessiveSourceLevel );
shallowMergeById( dominant.getProfiles(), recessive.getProfiles(), recessiveSourceLevel );
}