@ SuppressWarnings ( "unchecked" ) private List < String > findOptionalMojosForLifecycle ( MavenProject project , Lifecycle lifecycle ) throws LifecycleExecutionException , PluginNotFoundException { String packaging = project . getPackaging ( ) ; List < String > optionalMojos = null ; LifecycleMapping m = ( LifecycleMapping ) findExtension ( project , LifecycleMapping . ROLE , packaging , session . getSettings ( ) , session . getLocalRepository ( ) ) ; if ( m != null ) { optionalMojos = m . getOptionalMojos ( lifecycle . getId ( ) ) ; } if ( optionalMojos == null ) { try { m = ( LifecycleMapping ) session . lookup ( LifecycleMapping . ROLE , packaging ) ; optionalMojos = m . getOptionalMojos ( lifecycle . getId ( ) ) ; } catch ( ComponentLookupException e ) { log . debug ( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " + lifecycle . getId ( ) + ". Error: " + e . getMessage ( ) , e ) ; } } if ( optionalMojos == null ) { optionalMojos = Collections . emptyList ( ) ; } return optionalMojos ; }
Find optional mojos for lifecycle .