本文整理汇总了Java中org.apache.maven.model.Activation类的典型用法代码示例。如果您正苦于以下问题:Java Activation类的具体用法?Java Activation怎么用?Java Activation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Activation类属于org.apache.maven.model包,在下文中一共展示了Activation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeActivation
import org.apache.maven.model.Activation; //导入依赖的package包/类
private void writeActivation(Activation activation, String tagName, XmlSerializer serializer)
throws java.io.IOException {
serializer.startTag(NAMESPACE, tagName);
flush(serializer);
StringBuffer b = b(serializer);
int start = b.length();
if (activation.isActiveByDefault() != false) {
writeValue(serializer, "activeByDefault", String.valueOf(activation.isActiveByDefault()), activation);
}
if (activation.getJdk() != null) {
writeValue(serializer, "jdk", activation.getJdk(), activation);
}
if (activation.getOs() != null) {
writeActivationOS((ActivationOS) activation.getOs(), "os", serializer);
}
if (activation.getProperty() != null) {
writeActivationProperty((ActivationProperty) activation.getProperty(), "property", serializer);
}
if (activation.getFile() != null) {
writeActivationFile((ActivationFile) activation.getFile(), "file", serializer);
}
serializer.endTag(NAMESPACE, tagName).flush();
logLocation(activation, "", start, b.length());
}
示例2: visitProfileActivation
import org.apache.maven.model.Activation; //导入依赖的package包/类
private void visitProfileActivation( ModelVisitor visitor, Activation activation )
{
ActivationOS os = activation.getOs();
if ( os != null )
{
visitor.visitProfileActivationO( os );
os = visitor.replaceProfileActivationO( os );
activation.setOs( os );
}
ActivationProperty property = activation.getProperty();
if ( property != null )
{
visitor.visitProfileActivationProperty( property );
property = visitor.replaceProfileActivationProperty( property );
activation.setProperty( property );
}
ActivationFile file = activation.getFile();
if ( file != null )
{
visitor.visitProfileActivationFile( file );
file = visitor.replaceProfileActivationFile( file );
activation.setFile( file );
}
}
示例3: isActive
import org.apache.maven.model.Activation; //导入依赖的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;
}
示例4: addProfile
import org.apache.maven.model.Activation; //导入依赖的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 );
}
}
示例5: shouldResolveDependencyFromDefaultProfile
import org.apache.maven.model.Activation; //导入依赖的package包/类
@Test
public void shouldResolveDependencyFromDefaultProfile() {
Model bar = pom().artifactId("bar").create(repoBarDir);
Model foo = pom().artifactId("foo").create(repoFooDir);
Activation fooProfileActivation = new Activation();
fooProfileActivation.setActiveByDefault(true);
Profile fooProfile = new Profile();
fooProfile.setId("fooProfile");
fooProfile.setActivation(fooProfileActivation);
fooProfile.addDependency(dependency().to(bar).build());
foo.addProfile(fooProfile);
createArtifact(repoFooDir, foo);
validationExecutor.execute(ctx);
assertSuccess();
assertLocalRepoContains(foo);
assertLocalRepoContains(bar);
}
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:23,代码来源:TestDependenciesValidator.java
示例6: shouldResolveDependencyFromActiveProfile
import org.apache.maven.model.Activation; //导入依赖的package包/类
@Test
public void shouldResolveDependencyFromActiveProfile() {
Model bar = pom().artifactId("bar").create(repoBarDir);
Model foo = pom().artifactId("foo").create(repoFooDir);
Activation fooProfileActivation = new Activation();
fooProfileActivation.setJdk("!1.0");
Profile fooProfile = new Profile();
fooProfile.setId("fooProfile");
fooProfile.setActivation(fooProfileActivation);
fooProfile.addDependency(dependency().to(bar).build());
foo.addProfile(fooProfile);
createArtifact(repoFooDir, foo);
validationExecutor.execute(ctx);
assertSuccess();
assertLocalRepoContains(foo);
assertLocalRepoContains(bar);
}
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:23,代码来源:TestDependenciesValidator.java
示例7: shouldFindMissingDependencyFromActiveProfile
import org.apache.maven.model.Activation; //导入依赖的package包/类
@Test
public void shouldFindMissingDependencyFromActiveProfile() {
Model bar = pom().artifactId("bar").model();
Model foo = pom().artifactId("foo").create(repoFooDir);
Activation fooProfileActivation = new Activation();
fooProfileActivation.setJdk("!1.0");
Profile fooProfile = new Profile();
fooProfile.setId("fooProfile");
fooProfile.setActivation(fooProfileActivation);
fooProfile.addDependency(dependency().to(bar).build());
foo.addProfile(fooProfile);
createArtifact(repoFooDir, foo);
validationExecutor.execute(ctx);
assertExpectedException(ArtifactNotFoundException.class, "Could not find artifact com.acme:bar:jar:1.0");
}
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:21,代码来源:TestDependenciesValidator.java
示例8: activateProfilesWithProperties
import org.apache.maven.model.Activation; //导入依赖的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;
}
示例9: isBuildTimeDriven
import org.apache.maven.model.Activation; //导入依赖的package包/类
/**
* @param activation is the {@link Activation} of a {@link Profile}.
* @return <code>true</code> if the given {@link Activation} is build-time driven, <code>false</code> otherwise (if
* it is triggered by OS or JDK).
*/
protected static boolean isBuildTimeDriven( Activation activation )
{
if ( activation == null )
{
return true;
}
if ( StringUtils.isEmpty( activation.getJdk() ) && activation.getOs() == null )
{
return true;
}
return false;
}
示例10: convertActivation
import org.apache.maven.model.Activation; //导入依赖的package包/类
private static MavenActivation convertActivation(Activation activation) {
if (activation == null) {
return null;
}
MavenActivation result = new MavenActivation();
result.setActiveByDefault(activation.isActiveByDefault());
result.setFile(convertFileActivation(activation.getFile()));
result.setJdk(activation.getJdk());
result.setOs(convertOsActivation(activation.getOs()));
result.setProperty(convertPropertyActivation(activation.getProperty()));
return result;
}
示例11: convertToMavenActivation
import org.apache.maven.model.Activation; //导入依赖的package包/类
private static Activation convertToMavenActivation(MavenActivation activation) {
if (activation != null) {
Activation result = new Activation();
result.setActiveByDefault(activation.isActiveByDefault());
result.setFile(convertToMavenActivationFile(activation.getFile()));
result.setJdk(activation.getJdk());
result.setOs(convertToMavenActivationOs(activation.getOs()));
result.setProperty(convertToMavenActivationProperty(activation.getProperty()));
return result;
}
return null;
}
示例12: transformableWithDiscardActiveReference
import org.apache.maven.model.Activation; //导入依赖的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);
}
示例13: addProfile
import org.apache.maven.model.Activation; //导入依赖的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 );
}
示例14: isActive
import org.apache.maven.model.Activation; //导入依赖的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;
}
}
示例15: isActive
import org.apache.maven.model.Activation; //导入依赖的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 );
}
}