messageBuffer.append( mojo.getPluginDescriptor().getArtifactId() ); messageBuffer.append( "\', specify the following:\n\n<configuration>\n ...\n" ); messageBuffer.append( " <" ).append( param.getName() ).append( '>' ); if ( StringUtils.isNotEmpty( alias ) && !alias.equals( param.getName() ) ) if ( StringUtils.isEmpty( expression ) )
protected PluginManagerException( MojoDescriptor mojoDescriptor, String message, Throwable cause ) { super( message, cause ); pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId(); pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId(); pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion(); goal = mojoDescriptor.getGoal(); }
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); ClassRealm pluginRealm = pluginDescriptor.getClassRealm(); logger.debug( "Configuring mojo " + mojoDescriptor.getId() + " from plugin realm " + pluginRealm ); mojo = container.lookup( mojoInterface, mojoDescriptor.getRoleHint() ); ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '" + pluginDescriptor.getId() + "'. A required class is missing: " + cause.getMessage() ); pluginRealm.display( ps ); ps.println( "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' in the plugin '" + pluginDescriptor.getId() + "' due to an API incompatibility: " + e.getClass().getName() + ": " + cause.getMessage() ); pluginRealm.display( ps ); "Unable to load the mojo '" + mojoDescriptor.getGoal() + "' (or one of its required components) from the plugin '" + pluginDescriptor.getId() + "'", e ); MavenProject project = session.getCurrentProject(); Logger mojoLogger = loggerManager.getLoggerForComponent( mojoDescriptor.getImplementation() ); ( (Mojo) mojo ).setLog( new DefaultLog( mojoLogger ) );
/** * @return the id of the mojo, based on the goal name */ public String getId() { return getPluginDescriptor().getId() + ":" + getGoal(); }
/** * @return the full goal name * @see PluginDescriptor#getGoalPrefix() * @see #getGoal() */ public String getFullGoalName() { return getPluginDescriptor().getGoalPrefix() + ":" + getGoal(); }
/** * @return {@code true} if this mojo forks either a goal or the lifecycle, {@code false} otherwise. */ public boolean isForking() { return ( getExecuteGoal() != null && getExecuteGoal().length() > 0 ) || ( getExecutePhase() != null && getExecutePhase().length() > 0 ); }
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); Xpp3Dom executionConfiguration = mojoExecution.getConfiguration(); if ( executionConfiguration == null ) if ( mojoDescriptor.getParameters() != null ) for ( Parameter parameter : mojoDescriptor.getParameters() ) if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) && StringUtils.isNotEmpty( parameter.getImplementation() ) ) mojoExecution.setConfiguration( finalConfiguration );
MojoDescriptor descriptor = new MojoDescriptor(); descriptor.setPluginDescriptor( pluginDescriptor ); descriptor.setLanguage( "java" ); descriptor.setGoal( HELP_GOAL ); descriptor.setImplementation( packageName + '.' + HELP_MOJO_CLASS_NAME ); descriptor.setImplementation( HELP_MOJO_CLASS_NAME ); descriptor.setDescription( "Display help information on " + pluginDescriptor.getArtifactId() + ".<br/> Call <pre> mvn " + descriptor.getFullGoalName() + " -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details." ); param.setDefaultValue( "false" ); param.setExpression( "${detail}" ); descriptor.addParameter( param ); + " If unspecified, all goals will be displayed." ); param.setExpression( "${goal}" ); descriptor.addParameter( param ); param.setDefaultValue( "80" ); param.setExpression( "${lineLength}" ); descriptor.addParameter( param ); param.setDefaultValue( "2" );
private void unpackFileBasedResources() throws MojoExecutionException { if ( mojoExecution == null || mavenProject == null ) { unconstructedParts.add( "Unpacked Ant build scripts (in Maven build directory)." ); return; } // What we need to write out any resources in the plugin to the target directory of the // mavenProject using the Ant-based plugin: // // 1. Need a reference to the plugin JAR itself // 2. Need a reference to the ${basedir} of the mavenProject PluginDescriptor pluginDescriptor = mojoExecution.getMojoDescriptor().getPluginDescriptor(); File pluginJar = pluginDescriptor.getPluginArtifact().getFile(); String resourcesPath = pluginDescriptor.getArtifactId(); File outputDirectory = new File( mavenProject.getBuild().getDirectory() ); try { UnArchiver ua = new ZipUnArchiver( pluginJar ); ua.extract( resourcesPath, outputDirectory ); } catch ( ArchiverException e ) { throw new MojoExecutionException( "Error extracting resources from your Ant-based plugin.", e ); } }
private MojoDescriptor asDescriptor( File metadataFile, Mojo mojo ) throws PluginMetadataParseException MojoDescriptor descriptor = new MojoDescriptor(); descriptor.setGoal( mojo.getGoal() ); descriptor.setPhase( mojo.getPhase() ); descriptor.setDependencyResolutionRequired( mojo.getRequiresDependencyResolution() ); descriptor.setAggregator( mojo.isAggregator() ); descriptor.setInheritedByDefault( mojo.isInheritByDefault() ); descriptor.setDirectInvocationOnly( mojo.isRequiresDirectInvocation() ); descriptor.setOnlineRequired( mojo.isRequiresOnline() ); descriptor.setProjectRequired( mojo.isRequiresProject() ); descriptor.setRequiresReports( mojo.isRequiresReports() ); descriptor.setDescription( mojo.getDescription() ); descriptor.setDeprecated( mojo.getDeprecation() ); descriptor.setExecuteLifecycle( le.getLifecycle() ); descriptor.setExecutePhase( le.getPhase() ); if ( StringUtils.isNotEmpty( property ) ) if ( StringUtils.isEmpty( dParam.getName() ) ) descriptor.addParameter( dParam );
InvalidPluginDescriptorException, PluginVersionResolutionException MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); String forkedLifecycle = mojoDescriptor.getExecuteLifecycle(); if ( StringUtils.isEmpty( forkedLifecycle ) ) lifecycleOverlay = pluginDescriptor.getLifecycleMapping( forkedLifecycle ); throw new PluginDescriptorParsingException( pluginDescriptor.getPlugin(), pluginDescriptor.getSource(), e ); new MojoExecution( forkedMojoDescriptor, mojoExecution.getExecutionId() );
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); value = session.getLocalRepository(); value = session.getProjects(); value = project.getExecutionProject(); value = session.getRepositorySession(); value = mojoDescriptor.getPluginDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); if ( ( value == null ) && ( ( project != null ) && ( project.getProperties() != null ) ) ) value = project.getProperties().getProperty( expression );
/** * We use a specific status directory for each Mojo execution to store state * which is needed during the next build invocation run. * @return the directory for storing status information of the current Mojo execution. */ public File getMojoStatusDirectory() throws MojoExecutionException { if ( mojoExecution == null ) { throw new MojoExecutionException( "MojoExecution could not get resolved" ); } File buildOutputDirectory = new File( mavenProject.getBuild().getDirectory() ); //X TODO the executionId contains -cli and -mojoname //X we should remove those postfixes as it should not make //X any difference whether being run on the cli or via build String mojoStatusPath = MAVEN_STATUS_ROOT + File.separator + mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId() + File.separator + mojoExecution.getMojoDescriptor().getGoal() + File.separator + mojoExecution.getExecutionId(); File mojoStatusDir = new File( buildOutputDirectory, mojoStatusPath ); if ( !mojoStatusDir.exists() ) { mojoStatusDir.mkdirs(); } return mojoStatusDir; }
if ( mojoDescriptor.isProjectRequired() ) if ( mojoDescriptor.isRequiresReports() ) if ( mojoDescriptor.isAggregator() ) if ( mojoDescriptor.isDirectInvocationOnly() ) value = mojoDescriptor.isDependencyResolutionRequired(); if ( StringUtils.isNotEmpty( value ) ) value = mojoDescriptor.getSince(); if ( StringUtils.isNotEmpty( value ) ) value = mojoDescriptor.getPhase(); if ( StringUtils.isNotEmpty( value ) ) value = mojoDescriptor.getExecutePhase(); if ( StringUtils.isNotEmpty( value ) ) value = mojoDescriptor.getExecuteGoal(); if ( StringUtils.isNotEmpty( value ) ) value = mojoDescriptor.getExecuteLifecycle(); if ( StringUtils.isNotEmpty( value ) ) if ( mojoDescriptor.isOnlineRequired() ) if ( !mojoDescriptor.isInheritedByDefault() )
String configuratorId = mojoDescriptor.getComponentConfigurator(); if ( StringUtils.isEmpty( configuratorId ) ) "Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId + " configurator -->" ); String message = "Unable to parse configuration of mojo " + mojoDescriptor.getId(); if ( e.getFailedConfiguration() != null ) throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), message, e ); throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), "Unable to retrieve component configurator " + configuratorId + " for configuration of mojo " + mojoDescriptor.getId(), e ); ps.println( "A required class was missing during configuration of mojo " + mojoDescriptor.getId() + ": " + e.getMessage() ); pluginRealm.display( ps ); throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e ); PrintStream ps = new PrintStream( os ); ps.println( "An API incompatibility was encountered during configuration of mojo " + mojoDescriptor.getId() + ": " + e.getClass().getName() + ": " + e.getMessage() ); pluginRealm.display( ps ); throw new PluginConfigurationException( mojoDescriptor.getPluginDescriptor(), os.toString(), e );
private void appendForkInfo( MessageBuilder buffer, MojoDescriptor md ) { StringBuilder buff = new StringBuilder(); if ( StringUtils.isNotEmpty( md.getExecutePhase() ) ) { // forked phase if ( StringUtils.isNotEmpty( md.getExecuteLifecycle() ) ) { buff.append( '[' ); buff.append( md.getExecuteLifecycle() ); buff.append( ']' ); } buff.append( md.getExecutePhase() ); } else { // forked goal buff.append( ':' ); buff.append( md.getExecuteGoal() ); } buffer.strong( buff.toString() ); }
MojoDescriptor mojo = new MojoDescriptor(); mojo.setPluginDescriptor( pluginDescriptor ); mojo.setGoal( c.getChild( "goal" ).getValue() ); mojo.setImplementation( c.getChild( "implementation" ).getValue() ); mojo.setLanguage( langConfig.getValue() ); mojo.setComponentConfigurator( configuratorConfig.getValue() ); mojo.setComponentComposer( composerConfig.getValue() ); mojo.setSince( since ); mojo.setDeprecated( deprecated.getValue() ); mojo.setPhase( phase ); mojo.setExecutePhase( executePhase ); mojo.setExecuteGoal( executeMojo ); mojo.setExecuteLifecycle( executeLifecycle ); mojo.setInstantiationStrategy( c.getChild( "instantiationStrategy" ).getValue() ); mojo.setDescription( c.getChild( "description" ).getValue() );
if ( !StringUtils.isEmpty( property ) ) if ( !StringUtils.isEmpty( alias ) ) mojoDescriptor.setRequiresReports( true ); mojoDescriptor.addParameter( pd );
String value = descriptor.getDeprecated(); if (descriptor.isProjectRequired()) { w.printBullet("Requires a Maven 2.0 project to execute."); if (descriptor.isAggregator()) { w.printBullet("Executes as an aggregator plugin."); if (descriptor.isDirectInvocationOnly()) { w.printBullet("Executes by direct invocation only."); value = descriptor.getDependencyResolutionRequired(); value = descriptor.getSince(); if (StringUtils.isNotEmpty(value)) { w.printBullet("Since version: {{" + value + "}}"); value = descriptor.getPhase(); value = descriptor.getExecutePhase(); value = descriptor.getExecuteGoal(); value = descriptor.getExecuteLifecycle(); if (descriptor.isOnlineRequired()) { w.printBullet("Requires that mvn runs in online mode."); if (!descriptor.isInheritedByDefault()) {
plugin.setVersion(DATANUCLEUS_VERSION); plugin.addDependency(enhancer_api.equals("JDO") ? JDO_DEPENDENCY : JPA_DEPENDENCY); for (Dependency transitiveDep : project.getDependencies()) { plugin.addDependency(transitiveDep); project.getRemotePluginRepositories(), session.getRepositorySession()); } catch (PluginNotFoundException | PluginResolutionException | PluginDescriptorParsingException | InvalidPluginDescriptorException e) { MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("enhance"); convertPlexusConfiguration(mojoDescriptor.getMojoConfiguration())); MojoExecution exec = new MojoExecution(mojoDescriptor, configuration);