private String getRequiredMavenVersion( MavenProject mavenProject, String defaultValue ) { ArtifactVersion requiredMavenVersion = null; while ( mavenProject != null ) { final Prerequisites prerequisites = mavenProject.getPrerequisites(); final String mavenVersion = prerequisites == null ? null : prerequisites.getMaven(); if ( mavenVersion != null ) { final ArtifactVersion v = new DefaultArtifactVersion( mavenVersion ); if ( requiredMavenVersion == null || requiredMavenVersion.compareTo( v ) < 0 ) { requiredMavenVersion = v; } } mavenProject = mavenProject.getParent(); } return requiredMavenVersion == null ? defaultValue : requiredMavenVersion.toString(); }
private void writePrerequisites(Prerequisites prerequisites, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if ((prerequisites.getMaven() != null) && !prerequisites.getMaven().equals("2.0")) { writeValue(serializer, "maven", prerequisites.getMaven(), prerequisites); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(prerequisites, "", start, b.length()); }
/** * Method updatePrerequisites * * @param value * @param element * @param counter * @param xmlTag */ protected void updatePrerequisites( Prerequisites 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, "maven", value.getMaven(), "2.0" ); } }
protected void mergePrerequisites_Maven( Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getMaven(); if ( src != null ) { if ( sourceDominant || target.getMaven() == null ) { target.setMaven( src ); target.setLocation( "maven", source.getLocation( "maven" ) ); } } }
private File guessBestMaven(RunConfig clonedConfig, InputOutput ioput) { MavenProject mp = clonedConfig.getMavenProject(); if (mp != null) { if (mp.getPrerequisites() != null) { Prerequisites pp = mp.getPrerequisites(); String ver = pp.getMaven(); if (ver != null) { return checkAvailability(ver, null, ioput); } } String value = PluginPropertyUtils.getPluginPropertyBuildable(clonedConfig.getMavenProject(), Constants.GROUP_APACHE_PLUGINS, "maven-enforcer-plugin", "enforce", new PluginPropertyUtils.ConfigurationBuilder<String>() { @Override public String build(Xpp3Dom configRoot, ExpressionEvaluator eval) { if(configRoot != null) { Xpp3Dom rules = configRoot.getChild("rules"); if (rules != null) { Xpp3Dom rmv = rules.getChild("requireMavenVersion"); if (rmv != null) { Xpp3Dom v = rmv.getChild("version"); if (v != null) { return v.getValue(); } } } } return null; } }); if (value != null) { if (value.contains("[") || value.contains("(")) { try { VersionRange vr = VersionRange.createFromVersionSpec(value); return checkAvailability(null, vr, ioput); } catch (InvalidVersionSpecificationException ex) { Exceptions.printStackTrace(ex); } } else { return checkAvailability(value, null, ioput); } } } return null; }
public Prerequisites getPrerequisites() { return null; }
@Override public Prerequisites replacePrerequisite( Prerequisites prerequisites ) { return prerequisites; }
@Override public void visitPrerequisite( Prerequisites prerequisites ) { }
@Override public Prerequisites get( Model model ) { return model.getPrerequisites(); }
@Override public void set( Model model, Prerequisites value ) { model.setPrerequisites( value ); }
public Prerequisites getPrerequisites() { return getModel().getPrerequisites(); }
protected void mergePrerequisites( Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context ) { mergePrerequisites_Maven( target, source, sourceDominant, context ); }
@Override public Prerequisites getPrerequisites() { return getDelegate().getPrerequisites(); }
Prerequisites replacePrerequisite( Prerequisites prerequisites );
void visitPrerequisite( Prerequisites prerequisites );