protected Plugin findCurrentPlugin ( Plugin plugin , MavenProject project ) { Plugin found = null ; try { Model model = project . getModel ( ) ; @ SuppressWarnings ( "unchecked" ) Map < String , Plugin > plugins = model . getBuild ( ) . getPluginsAsMap ( ) ; found = plugins . get ( plugin . getKey ( ) ) ; } catch ( NullPointerException e ) { // nothing to do here } if ( found == null ) { found = resolvePlugin ( plugin , project ) ; } return found ; }
Given a plugin this will retrieve the matching plugin artifact from the model .