private static @CheckForNull <T> T getReportPluginPropertyImpl(@NonNull MavenProject prj, @NonNull String groupId, @NonNull String artifactId, @NonNull ConfigurationBuilder<T> builder, @NullAllowed String report) { T toRet = null; for (ReportPlugin plug : getEffectiveReportPlugins(prj)) { if (artifactId.equals(plug.getArtifactId()) && groupId.equals(plug.getGroupId())) { if (plug.getReportSets() != null) { for (ReportSet exe : plug.getReportSets()) { if (exe.getReports().contains(report)) { toRet = builder.build((Xpp3Dom)exe.getConfiguration(), DUMMY_EVALUATOR); if (toRet != null) { break; } } } } if (toRet == null) { toRet = builder.build((Xpp3Dom)plug.getConfiguration(), DUMMY_EVALUATOR); } } } return toRet; }
private void visitProfileReportingPlugin( ModelVisitor visitor, ReportPlugin reportPlugin ) { List<ReportSet> reportSets = reportPlugin.getReportSets(); if ( reportSets != null ) { ListIterator<ReportSet> reportSetIterator = reportSets.listIterator(); while ( reportSetIterator.hasNext() ) { ReportSet reportSet = reportSetIterator.next(); visitor.visitProfileReportingPluginReportSet( reportSet ); visitProfileReportingPluginReportSet( visitor, reportSet ); reportSet = visitor.replaceProfileReportingPluginReportSet( reportSet ); if ( reportSet == null ) reportSetIterator.remove(); else reportSetIterator.set( reportSet ); } } }
private void visitProfileReportingPluginReportSet( ModelVisitor visitor, ReportSet reportSet ) { List<String> reports = reportSet.getReports(); if ( reports != null ) { ListIterator<String> reportIterator = reports.listIterator(); while ( reportIterator.hasNext() ) { String report = reportIterator.next(); visitor.visitProfileReportingPluginReportSetReport( report ); report = visitor.replaceProfileReportingPluginReportSetReport( report ); if ( report == null ) reportIterator.remove(); else reportIterator.set( report ); } } }
private void visitReportingPlugin( ModelVisitor visitor, ReportPlugin reportPlugin ) { List<ReportSet> reportSets = reportPlugin.getReportSets(); if ( reportSets != null ) { ListIterator<ReportSet> reportSetIterator = reportSets.listIterator(); while ( reportSetIterator.hasNext() ) { ReportSet reportSet = reportSetIterator.next(); visitor.visitReportingPluginReportSet( reportSet ); visitReportingPluginReportSet( visitor, reportSet ); reportSet = visitor.replaceReportingPluginReportSet( reportSet ); if ( reportSet == null ) reportSetIterator.remove(); else reportSetIterator.set( reportSet ); } } }
private void visitReportingPluginReportSet( ModelVisitor visitor, ReportSet reportSet ) { List<String> reports = reportSet.getReports(); if ( reports != null ) { ListIterator<String> reportIterator = reports.listIterator(); while ( reportIterator.hasNext() ) { String report = reportIterator.next(); visitor.visitReportingPluginReportSetReport( report ); report = visitor.replaceReportingPluginReportSetReport( report ); if ( report == null ) reportIterator.remove(); else reportIterator.set( report ); } } }
public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) { Reporting reporting = model.getReporting(); if ( reporting != null ) { for ( ReportPlugin reportPlugin : reporting.getPlugins() ) { Xpp3Dom parentDom = (Xpp3Dom) reportPlugin.getConfiguration(); if ( parentDom != null ) { for ( ReportSet execution : reportPlugin.getReportSets() ) { Xpp3Dom childDom = (Xpp3Dom) execution.getConfiguration(); childDom = Xpp3Dom.mergeXpp3Dom( childDom, new Xpp3Dom( parentDom ) ); execution.setConfiguration( childDom ); } } } } }
private void writeReportPlugin(ReportPlugin reportPlugin, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if ((reportPlugin.getGroupId() != null) && !reportPlugin.getGroupId().equals("org.apache.maven.plugins")) { writeValue(serializer, "groupId", reportPlugin.getGroupId(), reportPlugin); } if (reportPlugin.getArtifactId() != null) { writeValue(serializer, "artifactId", reportPlugin.getArtifactId(), reportPlugin); } if (reportPlugin.getVersion() != null) { writeValue(serializer, "version", reportPlugin.getVersion(), reportPlugin); } if ((reportPlugin.getReportSets() != null) && (reportPlugin.getReportSets().size() > 0)) { serializer.startTag(NAMESPACE, "reportSets"); for (Iterator iter = reportPlugin.getReportSets().iterator(); iter.hasNext();) { ReportSet o = (ReportSet) iter.next(); writeReportSet(o, "reportSet", serializer); } serializer.endTag(NAMESPACE, "reportSets"); } if (reportPlugin.getInherited() != null) { writeValue(serializer, "inherited", reportPlugin.getInherited(), reportPlugin); } if (reportPlugin.getConfiguration() != null) { writeXpp3DOM(serializer, (Xpp3Dom)reportPlugin.getConfiguration(), reportPlugin); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(reportPlugin, "", start, b.length()); }
private void writeReportSet(ReportSet reportSet, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if ((reportSet.getId() != null) && !reportSet.getId().equals("default")) { writeValue(serializer, "id", reportSet.getId(), reportSet); } if ((reportSet.getReports() != null) && (reportSet.getReports().size() > 0)) { serializer.startTag(NAMESPACE, "reports"); flush(serializer); int start2 = b.length(); InputLocation tracker = reportSet.getLocation("reports"); int index = 0; for (Iterator iter = reportSet.getReports().iterator(); iter.hasNext();) { String report = (String) iter.next(); writeValue(serializer, "report", report, tracker, index); index = index + 1; } serializer.endTag(NAMESPACE, "reports").flush(); logLocation(reportSet, "reports", start2, b.length()); } if (reportSet.getInherited() != null) { writeValue(serializer, "inherited", reportSet.getInherited(), reportSet); } if (reportSet.getConfiguration() != null) { writeXpp3DOM(serializer, (Xpp3Dom)reportSet.getConfiguration(), reportSet); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(reportSet, "", start, b.length()); }
/** * Method updateReportSet * * @param value * @param element * @param counter * @param xmlTag */ protected void updateReportSet( ReportSet value, String xmlTag, Counter counter, Element element ) { Element root = element; Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "id", value.getId(), "default" ); findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() ); findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null ); findAndReplaceSimpleLists( innerCount, root, value.getReports(), "reports", "report" ); }
private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent ) { List parentReports = parent.getReports(); List childReports = child.getReports(); List reports = new ArrayList(); if ( ( childReports != null ) && !childReports.isEmpty() ) { reports.addAll( childReports ); } if ( parentReports != null ) { for ( Iterator i = parentReports.iterator(); i.hasNext(); ) { String report = (String) i.next(); if ( !reports.contains( report ) ) { reports.add( report ); } } } child.setReports( reports ); Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration(); childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration ); child.setConfiguration( childConfiguration ); }
protected void mergeReportSet( ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context ) { mergeConfigurationContainer( target, source, sourceDominant, context ); mergeReportSet_Id( target, source, sourceDominant, context ); mergeReportSet_Reports( target, source, sourceDominant, context ); }
protected void mergeReportSet_Id( ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getId(); if ( src != null ) { if ( sourceDominant || target.getId() == null ) { target.setId( src ); target.setLocation( "id", source.getLocation( "id" ) ); } } }
protected void mergeReportSet_Reports( ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context ) { List<String> src = source.getReports(); if ( !src.isEmpty() ) { List<String> tgt = target.getReports(); List<String> merged = new ArrayList<String>( tgt.size() + src.size() ); merged.addAll( tgt ); merged.addAll( src ); target.setReports( merged ); } }
@Override public ReportSet replaceProfileReportingPluginReportSet( ReportSet reportSet ) { return reportSet; }
@Override public ReportSet replaceReportingPluginReportSet( ReportSet reportSet ) { return reportSet; }
@Override public void visitProfileReportingPluginReportSet( ReportSet reportSet ) { }
@Override public void visitReportingPluginReportSet( ReportSet reportSet ) { }
/** * Method iterateReportSet * * @param counter * @param childTag * @param parentTag * @param list * @param parent */ protected void iterateReportSet( Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag ) { boolean shouldExist = list != null && list.size() > 0; Element element = updateElement( counter, parent, parentTag, shouldExist ); if ( shouldExist ) { Iterator it = list.iterator(); Iterator elIt = element.getChildren( childTag, element.getNamespace() ).iterator(); if ( !elIt.hasNext() ) { elIt = null; } Counter innerCount = new Counter( counter.getDepth() + 1 ); while ( it.hasNext() ) { ReportSet value = (ReportSet) it.next(); Element el; if ( elIt != null && elIt.hasNext() ) { el = (Element) elIt.next(); if ( !elIt.hasNext() ) { elIt = null; } } else { el = factory.element( childTag, element.getNamespace() ); insertAtPreferredLocation( element, el, innerCount ); } updateReportSet( value, childTag, innerCount, el ); innerCount.increaseCount(); } if ( elIt != null ) { while ( elIt.hasNext() ) { elIt.next(); elIt.remove(); } } } }
public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent, boolean handleAsInheritance ) { if ( ( child == null ) || ( parent == null ) ) { // nothing to do. return; } if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) ) { child.setVersion( parent.getVersion() ); } // from here to the end of the method is dealing with merging of the <executions/> section. String parentInherited = parent.getInherited(); boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue(); List parentReportSets = parent.getReportSets(); if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() ) { Map assembledReportSets = new TreeMap(); Map childReportSets = child.getReportSetsAsMap(); for ( Iterator it = parentReportSets.iterator(); it.hasNext(); ) { ReportSet parentReportSet = (ReportSet) it.next(); if ( !handleAsInheritance || parentIsInherited ) { ReportSet assembledReportSet = parentReportSet; ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() ); if ( childReportSet != null ) { mergeReportSetDefinitions( childReportSet, parentReportSet ); assembledReportSet = childReportSet; } else if ( handleAsInheritance && ( parentInherited == null ) ) { parentReportSet.unsetInheritanceApplied(); } assembledReportSets.put( assembledReportSet.getId(), assembledReportSet ); } } for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); String id = (String) entry.getKey(); if ( !assembledReportSets.containsKey( id ) ) { assembledReportSets.put( id, entry.getValue() ); } } child.setReportSets( new ArrayList( assembledReportSets.values() ) ); child.flushReportSetMap(); } }
protected Object getReportSetKey( ReportSet object ) { return object; }
@Override protected Object getReportSetKey( ReportSet object ) { return object.getId(); }
ReportSet replaceProfileReportingPluginReportSet( ReportSet reportSet );
ReportSet replaceReportingPluginReportSet( ReportSet reportSet );
void visitProfileReportingPluginReportSet( ReportSet reportSet );
void visitReportingPluginReportSet( ReportSet reportSet );