本文整理汇总了Java中org.apache.maven.model.Profile.getActivation方法的典型用法代码示例。如果您正苦于以下问题:Java Profile.getActivation方法的具体用法?Java Profile.getActivation怎么用?Java Profile.getActivation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.Profile
的用法示例。
在下文中一共展示了Profile.getActivation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isActive
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile )
{
Activation activation = profile.getActivation();
ActivationOS os = activation.getOs();
boolean result = ensureAtLeastOneNonNull( os );
if ( result && os.getFamily() != null )
{
result = determineFamilyMatch( os.getFamily() );
}
if ( result && os.getName() != null )
{
result = determineNameMatch( os.getName() );
}
if ( result && os.getArch() != null )
{
result = determineArchMatch( os.getArch() );
}
if ( result && os.getVersion() != null )
{
result = determineVersionMatch( os.getVersion() );
}
return result;
}
示例2: addProfile
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public void addProfile( Profile profile )
{
String profileId = profile.getId();
Profile existing = (Profile) profilesById.get( profileId );
if ( existing != null )
{
logger.warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource()
+ ") with new instance from source: " + profile.getSource() );
}
profilesById.put( profile.getId(), profile );
Activation activation = profile.getActivation();
if ( activation != null && activation.isActiveByDefault() )
{
activateAsDefault( profileId );
}
}
示例3: activateProfilesWithProperties
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
private List<String> activateProfilesWithProperties(MavenProject mavenProject, List<String> activeProfileIds) {
if (mavenProject == null) return activeProfileIds;
List<String> result = new ArrayList<String>();
if (activeProfileIds != null) {
result.addAll(activeProfileIds);
}
for (Profile profile : mavenProject.getModel().getProfiles()) {
Activation activation = profile.getActivation();
if (activation != null) {
ActivationProperty property = activation.getProperty();
if (property != null) {
String name = property.getName();
if (name != null) {
String value;
if (name.startsWith("!")) {
value = propertiesManager.getPropertyValue(name.substring(1));
} else {
value = propertiesManager.getPropertyValue(name);
}
if (value != null) {
if (!name.startsWith("!") && value.equals(property.getValue()) || name.startsWith("!") && !value.equals(property.getValue())) {
result.add(profile.getId());
}
}
}
}
}
}
return result;
}
示例4: transformableWithDiscardActiveReference
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
public void transformableWithDiscardActiveReference() throws IOException {
PomTransformer pomTransformer = new PomTransformer(transformablePomAsString,
PomCleanupPolicy.discard_active_reference);
String transformedPom = pomTransformer.transform();
Model pom = MavenModelUtils.stringToMavenModel(transformedPom);
List repositoriesList = pom.getRepositories();
List pluginsRepositoriesList = pom.getPluginRepositories();
assertEmptyList(repositoriesList, pluginsRepositoriesList);
List<Profile> pomProfiles = pom.getProfiles();
for (Profile profile : pomProfiles) {
boolean activeByDefault = false;
Activation activation = profile.getActivation();
if (activation != null) {
activeByDefault = activation.isActiveByDefault();
}
List profileRepositories = profile.getRepositories();
List profilePluginsRepositories = profile.getPluginRepositories();
if (activeByDefault) {
assertEmptyList(profileRepositories, profilePluginsRepositories);
} else {
assertNotEmptyList(profileRepositories, profilePluginsRepositories);
}
}
assertTrue(transformablePomAsString.contains("This is a comment"));
compareChecksums(transformablePomAsString, transformedPom, false);
}
示例5: addProfile
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
/**
* Add the profile to the list of profiles. If an existing profile has the same
* id it is removed first.
*
* @param profiles Existing profiles
* @param profile Target profile to add
*/
void addProfile( final List<Profile> profiles, final Profile profile )
{
final Iterator<Profile> i = profiles.iterator();
while ( i.hasNext() )
{
final Profile p = i.next();
if ( profile.getId()
.equals( p.getId() ) )
{
logger.debug( "Removing local profile {} ", p );
i.remove();
// Don't break out of the loop so we can check for active profiles
}
// If we have injected profiles and one of the current profiles is using
// activeByDefault it will get mistakingly deactivated due to the semantics
// of activeByDefault. Therefore replace the activation.
if (p.getActivation() != null && p.getActivation().isActiveByDefault())
{
logger.warn( "Profile {} is activeByDefault", p );
final Activation replacement = new Activation();
final ActivationProperty replacementProp = new ActivationProperty();
replacementProp.setName( "!disableProfileActivation" );
replacement.setProperty( replacementProp );
p.setActivation( replacement );
}
}
logger.debug( "Adding profile {}", profile );
profiles.add( profile );
}
示例6: isActive
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile )
throws ProfileActivationException
{
Activation activation = profile.getActivation();
String jdk = activation.getJdk();
// null case is covered by canDetermineActivation(), so we can do a straight startsWith() here.
if ( jdk.startsWith( "[" ) || jdk.startsWith( "(" ) )
{
try
{
return matchJdkVersionRange( jdk );
}
catch ( InvalidVersionSpecificationException e )
{
throw new ProfileActivationException( "Invalid JDK version in profile '" + profile.getId() + "': "
+ e.getMessage() );
}
}
boolean reverse = false;
if ( jdk.startsWith( "!" ) )
{
reverse = true;
jdk = jdk.substring( 1 );
}
if ( getJdkVersion().startsWith( jdk ) )
{
return !reverse;
}
else
{
return reverse;
}
}
示例7: isActive
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
Activation activation = profile.getActivation();
if ( activation == null )
{
return false;
}
String jdk = activation.getJdk();
if ( jdk == null )
{
return false;
}
String version = context.getSystemProperties().get( "java.version" );
if ( version == null || version.length() <= 0 )
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Failed to determine Java version for profile " + profile.getId() )
.setLocation(activation.getLocation( "jdk" ) ) );
return false;
}
if ( jdk.startsWith( "!" ) )
{
return !version.startsWith( jdk.substring( 1 ) );
}
else if ( isRange( jdk ) )
{
return isInRange( version, getRange( jdk ) );
}
else
{
return version.startsWith( jdk );
}
}
示例8: isActive
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
{
Activation activation = profile.getActivation();
if ( activation == null )
{
return false;
}
ActivationOS os = activation.getOs();
if ( os == null )
{
return false;
}
boolean active = ensureAtLeastOneNonNull( os );
if ( active && os.getFamily() != null )
{
active = determineFamilyMatch( os.getFamily() );
}
if ( active && os.getName() != null )
{
active = determineNameMatch( os.getName() );
}
if ( active && os.getArch() != null )
{
active = determineArchMatch( os.getArch() );
}
if ( active && os.getVersion() != null )
{
active = determineVersionMatch( os.getVersion() );
}
return active;
}
示例9: canDetectActivation
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
protected boolean canDetectActivation( Profile profile )
{
return profile.getActivation() != null && profile.getActivation().getFile() != null;
}
示例10: applyProfiles
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
File basedir,
MavenExplicitProfiles explicitProfiles,
Collection<String> alwaysOnProfiles) throws RemoteException {
Model nativeModel = MavenModelConverter.toNativeModel(model);
Collection<String> enabledProfiles = explicitProfiles.getEnabledProfiles();
Collection<String> disabledProfiles = explicitProfiles.getDisabledProfiles();
List<Profile> activatedPom = new ArrayList<Profile>();
List<Profile> activatedExternal = new ArrayList<Profile>();
List<Profile> activeByDefault = new ArrayList<Profile>();
List<Profile> rawProfiles = nativeModel.getProfiles();
List<Profile> expandedProfilesCache = null;
List<Profile> deactivatedProfiles = new ArrayList<Profile>();
for (int i = 0; i < rawProfiles.size(); i++) {
Profile eachRawProfile = rawProfiles.get(i);
if (disabledProfiles.contains(eachRawProfile.getId())) {
deactivatedProfiles.add(eachRawProfile);
continue;
}
boolean shouldAdd = enabledProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());
Activation activation = eachRawProfile.getActivation();
if (activation != null) {
if (activation.isActiveByDefault()) {
activeByDefault.add(eachRawProfile);
}
// expand only if necessary
if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
Profile eachExpandedProfile = expandedProfilesCache.get(i);
for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
try {
if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
shouldAdd = true;
break;
}
}
catch (ProfileActivationException e) {
Maven3ServerGlobals.getLogger().warn(e);
}
}
}
if (shouldAdd) {
if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
activatedPom.add(eachRawProfile);
}
else {
activatedExternal.add(eachRawProfile);
}
}
}
List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
activatedProfiles.addAll(activatedExternal);
for (Profile each : activatedProfiles) {
new DefaultProfileInjector().injectProfile(nativeModel, each, null, null);
}
return new ProfileApplicationResult(MavenModelConverter.convertModel(nativeModel, null),
new MavenExplicitProfiles(collectProfilesIds(activatedProfiles),
collectProfilesIds(deactivatedProfiles))
);
}
示例11: applyProfiles
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
File basedir,
MavenExplicitProfiles explicitProfiles,
Collection<String> alwaysOnProfiles) throws RemoteException {
Model nativeModel = Maven2ModelConverter.toNativeModel(model);
Collection<String> enabledProfiles = explicitProfiles.getEnabledProfiles();
Collection<String> disabledProfiles = explicitProfiles.getDisabledProfiles();
List<Profile> activatedPom = new ArrayList<Profile>();
List<Profile> activatedExternal = new ArrayList<Profile>();
List<Profile> activeByDefault = new ArrayList<Profile>();
List<Profile> rawProfiles = nativeModel.getProfiles();
List<Profile> expandedProfilesCache = null;
List<Profile> deactivatedProfiles = new ArrayList<Profile>();
for (int i = 0; i < rawProfiles.size(); i++) {
Profile eachRawProfile = rawProfiles.get(i);
if (disabledProfiles.contains(eachRawProfile.getId())) {
deactivatedProfiles.add(eachRawProfile);
continue;
}
boolean shouldAdd = enabledProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());
Activation activation = eachRawProfile.getActivation();
if (activation != null) {
if (activation.isActiveByDefault()) {
activeByDefault.add(eachRawProfile);
}
// expand only if necessary
if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
Profile eachExpandedProfile = expandedProfilesCache.get(i);
for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
try {
if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
shouldAdd = true;
break;
}
}
catch (ProfileActivationException e) {
Maven2ServerGlobals.getLogger().warn(e);
}
}
}
if (shouldAdd) {
if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
activatedPom.add(eachRawProfile);
}
else {
activatedExternal.add(eachRawProfile);
}
}
}
List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
activatedProfiles.addAll(activatedExternal);
for (Profile each : activatedProfiles) {
new DefaultProfileInjector().inject(each, nativeModel);
}
return new ProfileApplicationResult(Maven2ModelConverter.convertModel(nativeModel, null),
new MavenExplicitProfiles(collectProfilesIds(activatedProfiles),
collectProfilesIds(deactivatedProfiles))
);
}
示例12: canDetectActivation
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
protected boolean canDetectActivation(Profile profile) {
return profile.getActivation() != null && profile.getActivation().getFile() != null;
}
示例13: applyProfiles
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
File basedir,
Collection<String> explicitProfiles,
Collection<String> alwaysOnProfiles) throws RemoteException {
Model nativeModel = MavenModelConverter.toNativeModel(model);
List<Profile> activatedPom = new ArrayList<Profile>();
List<Profile> activatedExternal = new ArrayList<Profile>();
List<Profile> activeByDefault = new ArrayList<Profile>();
List<Profile> rawProfiles = nativeModel.getProfiles();
List<Profile> expandedProfilesCache = null;
for (int i = 0; i < rawProfiles.size(); i++) {
Profile eachRawProfile = rawProfiles.get(i);
boolean shouldAdd = explicitProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());
Activation activation = eachRawProfile.getActivation();
if (activation != null) {
if (activation.isActiveByDefault()) {
activeByDefault.add(eachRawProfile);
}
// expand only if necessary
if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
Profile eachExpandedProfile = expandedProfilesCache.get(i);
for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
try {
if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
shouldAdd = true;
break;
}
}
catch (ProfileActivationException e) {
Maven3ServerGlobals.getLogger().warn(e);
}
}
}
if (shouldAdd) {
if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
activatedPom.add(eachRawProfile);
}
else {
activatedExternal.add(eachRawProfile);
}
}
}
List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
activatedProfiles.addAll(activatedExternal);
for (Profile each : activatedProfiles) {
new DefaultProfileInjector().injectProfile(nativeModel, each, null, null);
}
return new ProfileApplicationResult(MavenModelConverter.convertModel(nativeModel, null),
collectProfilesIds(activatedProfiles));
}
示例14: applyProfiles
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
public static ProfileApplicationResult applyProfiles(MavenModel model,
File basedir,
Collection<String> explicitProfiles,
Collection<String> alwaysOnProfiles) throws RemoteException {
Model nativeModel = Maven2ModelConverter.toNativeModel(model);
List<Profile> activatedPom = new ArrayList<Profile>();
List<Profile> activatedExternal = new ArrayList<Profile>();
List<Profile> activeByDefault = new ArrayList<Profile>();
List<Profile> rawProfiles = nativeModel.getProfiles();
List<Profile> expandedProfilesCache = null;
for (int i = 0; i < rawProfiles.size(); i++) {
Profile eachRawProfile = rawProfiles.get(i);
boolean shouldAdd = explicitProfiles.contains(eachRawProfile.getId()) || alwaysOnProfiles.contains(eachRawProfile.getId());
Activation activation = eachRawProfile.getActivation();
if (activation != null) {
if (activation.isActiveByDefault()) {
activeByDefault.add(eachRawProfile);
}
// expand only if necessary
if (expandedProfilesCache == null) expandedProfilesCache = doInterpolate(nativeModel, basedir).getProfiles();
Profile eachExpandedProfile = expandedProfilesCache.get(i);
for (ProfileActivator eachActivator : getProfileActivators(basedir)) {
try {
if (eachActivator.canDetermineActivation(eachExpandedProfile) && eachActivator.isActive(eachExpandedProfile)) {
shouldAdd = true;
break;
}
}
catch (ProfileActivationException e) {
Maven2ServerGlobals.getLogger().warn(e);
}
}
}
if (shouldAdd) {
if (MavenConstants.PROFILE_FROM_POM.equals(eachRawProfile.getSource())) {
activatedPom.add(eachRawProfile);
}
else {
activatedExternal.add(eachRawProfile);
}
}
}
List<Profile> activatedProfiles = new ArrayList<Profile>(activatedPom.isEmpty() ? activeByDefault : activatedPom);
activatedProfiles.addAll(activatedExternal);
for (Profile each : activatedProfiles) {
new DefaultProfileInjector().inject(each, nativeModel);
}
return new ProfileApplicationResult(Maven2ModelConverter.convertModel(nativeModel, null),
collectProfilesIds(activatedProfiles));
}
示例15: canDetectActivation
import org.apache.maven.model.Profile; //导入方法依赖的package包/类
protected boolean canDetectActivation( Profile profile )
{
return profile.getActivation() != null && profile.getActivation().getProperty() != null;
}