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()); }
private void writeActivationOS(ActivationOS activationOS, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (activationOS.getName() != null) { writeValue(serializer, "name", activationOS.getName(), activationOS); } if (activationOS.getFamily() != null) { writeValue(serializer, "family", activationOS.getFamily(), activationOS); } if (activationOS.getArch() != null) { writeValue(serializer, "arch", activationOS.getArch(), activationOS); } if (activationOS.getVersion() != null) { writeValue(serializer, "version", activationOS.getVersion(), activationOS); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(activationOS, "", start, b.length()); }
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 ); } }
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; }
/** * Method updateActivationOS * * @param value * @param element * @param counter * @param xmlTag */ protected void updateActivationOS( ActivationOS value, String xmlTag, Counter counter, Element element ) { boolean shouldExist = value != null; Element root = updateElement( counter, element, xmlTag, shouldExist ); if ( shouldExist ) { Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "name", value.getName(), null ); findAndReplaceSimpleElement( innerCount, root, "family", value.getFamily(), null ); findAndReplaceSimpleElement( innerCount, root, "arch", value.getArch(), null ); findAndReplaceSimpleElement( innerCount, root, "version", value.getVersion(), null ); } }
private org.apache.maven.model.Activation createModelActivation( Activation activation) { org.apache.maven.model.Activation modelActivation = new org.apache.maven.model.Activation(); modelActivation.setActiveByDefault(activation.isActiveByDefault()); if (activation.getFile() != null) { ActivationFile activationFile = new ActivationFile(); activationFile.setExists(activation.getFile().getExists()); activationFile.setMissing(activation.getFile().getMissing()); modelActivation.setFile(activationFile); } modelActivation.setJdk(activation.getJdk()); if (activation.getOs() != null) { ActivationOS os = new ActivationOS(); os.setArch(activation.getOs().getArch()); os.setFamily(activation.getOs().getFamily()); os.setName(activation.getOs().getName()); os.setVersion(activation.getOs().getVersion()); modelActivation.setOs(os); } if (activation.getProperty() != null) { ActivationProperty property = new ActivationProperty(); property.setName(activation.getProperty().getName()); property.setValue(activation.getProperty().getValue()); modelActivation.setProperty(property); } return modelActivation; }
private static MavenActivationOS convertOsActivation(ActivationOS os) { if (os == null) { return null; } return new MavenActivationOS(os.getName(), os.getFamily(), os.getArch(), os.getVersion()); }
private static ActivationOS convertToMavenActivationOs(MavenActivationOS os) { if (os != null) { ActivationOS result = new ActivationOS(); result.setArch(os.getArch()); result.setFamily(os.getFamily()); result.setName(os.getName()); result.setVersion(os.getVersion()); return result; } return null; }
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; }
@Override public ActivationOS replaceProfileActivationO( ActivationOS os ) { return os; }
@Override public void visitProfileActivationO( ActivationOS os ) { }
private boolean ensureAtLeastOneNonNull( ActivationOS os ) { return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null; }
ActivationOS replaceProfileActivationO( ActivationOS os );
void visitProfileActivationO( ActivationOS os );