@ SuppressWarnings ( "checkstyle:nestedifdepth" ) protected synchronized String replaceProp ( File sourceFile , int sourceLine , String text , MavenProject project , ReplacementType replacementType ) throws MojoExecutionException { String result = text ; final Pattern p = buildMacroPatternWithGroup ( Macros . MACRO_PROP ) ; final Matcher m = p . matcher ( text ) ; boolean hasResult = m . find ( ) ; Properties props = null ; if ( project != null ) { props = project . getProperties ( ) ; } if ( hasResult ) { final StringBuffer sb = new StringBuffer ( ) ; final StringBuilder replacement = new StringBuilder ( ) ; String propName ; do { propName = m . group ( 1 ) ; if ( propName != null ) { propName = propName . trim ( ) ; if ( propName . length ( ) > 0 ) { replacement . setLength ( 0 ) ; if ( props != null ) { final String value = props . getProperty ( propName ) ; if ( value != null && ! value . isEmpty ( ) ) { replacement . append ( value ) ; } } if ( replacement . length ( ) != 0 ) { m . appendReplacement ( sb , Matcher . quoteReplacement ( replacement . toString ( ) ) ) ; } } else { getBuildContext ( ) . addMessage ( sourceFile , sourceLine , 1 , "no property name for Prop tag: " + m . group ( 0 ) , //$NON-NLS-1$ BuildContext . SEVERITY_WARNING , null ) ; } } else { getBuildContext ( ) . addMessage ( sourceFile , sourceLine , 1 , "no property name for Prop tag: " + m . group ( 0 ) , //$NON-NLS-1$ BuildContext . SEVERITY_WARNING , null ) ; } hasResult = m . find ( ) ; } while ( hasResult ) ; m . appendTail ( sb ) ; result = sb . toString ( ) ; } return result ; }
Replace the property information tags in the given text .