jjkester commented on a change in pull request #37:
URL: https://github.com/apache/maven-help-plugin/pull/37#discussion_r741286196
##########
File path: src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
##########
@@ -298,8 +300,49 @@ else if ( e.getTargetException() instanceof
RuntimeException )
private static String toString( InputLocation location )
{
- InputSource source = location.getSource();
+ String source = toString( location.getSource() );
+ String hierarchy = toHierarchyString( location.getSource() );
+
+ return '}' + source + ( ( location.getLineNumber() >= 0 ) ? ", line "
+ location.getLineNumber() : "" )
+ + hierarchy + ' ';
+ }
+
+ private static String toHierarchyString( InputSource source )
+ {
+ StringBuilder sb = new StringBuilder();
+
+ try
+ {
+ // InputSource#getImportedBy() added in maven-model 4.0.0-alpha-1
+ Method getImportedBy = InputSource.class.getDeclaredMethod(
"getImportedBy" );
+ InputSource importedBy = (InputSource) getImportedBy.invoke(
source );
+
+ while ( importedBy != null )
+ {
+ sb.append( " via " ).append( toString( importedBy ) );
+ importedBy = (InputSource) getImportedBy.invoke( importedBy );
+ }
+ return sb.toString();
+ }
+ catch ( NoSuchMethodException | SecurityException |
IllegalArgumentException | IllegalAccessException
+ | ClassCastException e )
+ {
+ // Just continue without hierarchy
Review comment:
Will do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]