public static void executeMojo ( Plugin plugin , String goal , Xpp3Dom configuration , ExecutionEnvironment env ) throws MojoExecutionException { if ( configuration == null ) { throw new NullPointerException ( "configuration may not be null" ) ; } try { String executionId = null ; if ( goal != null && goal . length ( ) > 0 && goal . indexOf ( ' ' ) > - 1 ) { int pos = goal . indexOf ( ' ' ) ; executionId = goal . substring ( pos + 1 ) ; goal = goal . substring ( 0 , pos ) ; } MavenSession session = env . getMavenSession ( ) ; PluginDescriptor pluginDescriptor = env . getPluginManager ( ) . loadPlugin ( plugin , env . getMavenProject ( ) . getRemotePluginRepositories ( ) , session . getRepositorySession ( ) ) ; MojoDescriptor mojoDescriptor = pluginDescriptor . getMojo ( goal ) ; if ( mojoDescriptor == null ) { throw new MojoExecutionException ( "Could not find goal '" + goal + "' in plugin " + plugin . getGroupId ( ) + ":" + plugin . getArtifactId ( ) + ":" + plugin . getVersion ( ) ) ; } MojoExecution exec = mojoExecution ( mojoDescriptor , executionId , configuration ) ; env . getPluginManager ( ) . executeMojo ( session , exec ) ; } catch ( PluginNotFoundException | PluginResolutionException | PluginDescriptorParsingException | InvalidPluginDescriptorException | MojoExecutionException | MojoFailureException | PluginConfigurationException | PluginManagerException e ) { throw new MojoExecutionException ( "Unable to execute mojo" , e ) ; } }
Entry point for executing a mojo