Examples of PluginDescriptor


Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

    }

    public void testShouldExtractPluginArtifacts()
        throws Exception
    {
        PluginDescriptor pd = new PluginDescriptor();

        Artifact artifact = createArtifact( "testGroup", "testArtifact", "1.0" );

        pd.setArtifacts( Collections.singletonList( artifact ) );

        ExpressionEvaluator ee = createExpressionEvaluator( createDefaultProject(), pd, new Properties() );

        Object value = ee.evaluate( "${plugin.artifacts}" );
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

   
    this.mojo.workingDir = this.workingDir.getCanonicalPath();
    this.mojo.root = FitNesseHelper.DEFAULT_ROOT;
    this.mojo.project = new MavenProject();
    this.mojo.project.setFile(new File(getClass().getResource("pom.xml").getPath()));
    this.mojo.pluginDescriptor = new PluginDescriptor();
    this.mojo.pluginManager = mock(BuildPluginManager.class);
    this.mojo.session = mock(MavenSession.class);
       
    this.logStream = new ByteArrayOutputStream();
    this.mojo.setLog(new DefaultLog(new PrintStreamLogger(
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

          throws DuplicateMojoDescriptorException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException {
   
    DefaultArtifact artifact = new DefaultArtifact(groupId, artifactId, "DUMMY", "compile", type, "", null);
      MojoDescriptor mojoDescriptor = new MojoDescriptor();
    mojoDescriptor.setGoal(goal);
        PluginDescriptor pluginDescriptor = new PluginDescriptor();
    pluginDescriptor.addMojo(mojoDescriptor);
   
    Plugin plugin = new Plugin();
    plugin.setGroupId(groupId);
    plugin.setArtifactId(artifactId);
   
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

    this.mojo.project = new MavenProject();
    this.mojo.resolver = this.artifactResolver;
    this.mojo.fitNesseHelper = mock(FitNesseHelper.class);
    this.mojo.useProjectDependencies = new HashSet<String>();
   
    this.mojo.pluginDescriptor = new PluginDescriptor();
    this.mojo.pluginDescriptor.setGroupId(this.pluginArtifact.getGroupId());
    this.mojo.pluginDescriptor.setArtifactId(this.pluginArtifact.getArtifactId());
    this.mojo.pluginDescriptor.setArtifacts(Collections.singletonList(this.fitnesseArtifact));
    this.mojo.pluginDescriptor.setClassRealm(this.realm);
    this.mojo.project.setPluginArtifacts(Collections.singleton(this.pluginArtifact));
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

        logger.info( "configuring report plugin " + plugin.getId() );

        MavenSession session = mavenReportExecutorRequest.getMavenSession();
        List<RemoteRepository> remoteRepositories = session.getCurrentProject().getRemotePluginRepositories();

        PluginDescriptor pluginDescriptor =
            mavenPluginManagerHelper.getPluginDescriptor( plugin, remoteRepositories, session );

        List<GoalWithConf> goalsWithConfiguration = new ArrayList<GoalWithConf>();

        boolean userDefinedReports = true;
        if ( reportPlugin.getReportSets().isEmpty() && reportPlugin.getReports().isEmpty() )
        {
            // by default, use every goal, which will be filtered later to only keep reporting goals
            userDefinedReports = false;
            List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
            for ( MojoDescriptor mojoDescriptor : mojoDescriptors )
            {
                goalsWithConfiguration.add( new GoalWithConf( mojoDescriptor.getGoal(),
                                                              mojoDescriptor.getConfiguration() ) );
            }
        }
        else
        {
            Set<String> goals = new HashSet<String>();
            for ( String report : reportPlugin.getReports() )
            {
                if ( goals.add( report ) )
                {
                    goalsWithConfiguration.add( new GoalWithConf( report, reportPlugin.getConfiguration() ) );
                }
                else
                {
                    logger.warn( report + " report is declared twice in default reports" );
                }
            }

            for ( ReportSet reportSet : reportPlugin.getReportSets() )
            {
                goals = new HashSet<String>();
                for ( String report : reportSet.getReports() )
                {
                    if ( goals.add( report ) )
                    {
                        goalsWithConfiguration.add( new GoalWithConf( report, reportSet.getConfiguration() ) );
                    }
                    else
                    {
                        logger.warn( report + " report is declared twice in " + reportSet.getId() + " reportSet" );
                    }
                }
            }
        }

        List<MavenReportExecution> reports = new ArrayList<MavenReportExecution>();
        for ( GoalWithConf report : goalsWithConfiguration )
        {
            MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( report.getGoal() );
            if ( mojoDescriptor == null )
            {
                throw new MojoNotFoundException( report.getGoal(), pluginDescriptor );
            }

            MojoExecution mojoExecution = new MojoExecution( plugin, report.getGoal(), "report:" + report.getGoal() );

            mojoExecution.setMojoDescriptor( mojoDescriptor );

            mavenPluginManagerHelper.setupPluginRealm( pluginDescriptor, mavenReportExecutorRequest.getMavenSession(),
                                                       Thread.currentThread().getContextClassLoader(), IMPORTS,
                                                       EXCLUDES );

            if ( !isMavenReport( mojoExecution, pluginDescriptor ) )
            {
                if ( userDefinedReports )
                {
                    // reports were explicitly written in the POM
                    logger.warn( "ignoring " + mojoExecution.getPlugin().getId() + ':' + report.getGoal()
                        + " goal since it is not a report: should be removed from reporting configuration in POM" );
                }
                continue;
            }

            mojoExecution.setConfiguration( mergeConfiguration( mojoDescriptor.getMojoConfiguration(),
                                                                reportPlugin.getConfiguration(),
                                                                report.getConfiguration(),
                                                                mojoDescriptor.getParameterMap().keySet() ) );

            MavenReport mavenReport =
                            getConfiguredMavenReport( mojoExecution, pluginDescriptor, mavenReportExecutorRequest );

            MavenReportExecution mavenReportExecution =
                new MavenReportExecution( mojoExecution.getPlugin(), mavenReport, pluginDescriptor.getClassRealm() );

            lifecycleExecutor.calculateForkedExecutions( mojoExecution, mavenReportExecutorRequest.getMavenSession() );

            if ( !mojoExecution.getForkedExecutions().isEmpty() )
            {
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

                                  MavenSession session )
        throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException,
        ArtifactResolutionException
    {
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
        PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();

        Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(),
                                                      mojoExecution.getExecutionId() );
        if ( mojoExecution.getConfiguration() != null )
        {
            dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
        }
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

        throws PluginConfigurationException, ArtifactNotFoundException, PluginManagerException,
        ArtifactResolutionException
    {
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();

        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();

        PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );

        // if this is the first time this plugin has been used, the plugin's container will only
        // contain the plugin's artifact in isolation; we need to finish resolving the plugin's
        // dependencies, and add them to the container.
        ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session );

        Mojo plugin;
        try
        {
            plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
            if ( report && !( plugin instanceof MavenReport ) )
            {
                // TODO: the mojoDescriptor should actually capture this information so we don't get this far
                return null;
            }
        }
        catch ( ComponentLookupException e )
        {
            Throwable cause = e.getCause();
            while( cause != null && !(cause instanceof NoClassDefFoundError ) )
            {
                cause = cause.getCause();
            }
           
            if ( cause != null && ( cause instanceof NoClassDefFoundError ) )
            {
                throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint()
                                                  + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: "
                                                  + cause.getMessage(), e );
            }
           
            throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getGoal() +
                "' (or one of its required components) in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e );
        }
        catch ( NoClassDefFoundError e )
        {
            throw new PluginManagerException( "Unable to load the mojo '" + mojoDescriptor.getRoleHint()
                + "' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'. A required class is missing: "
                + e.getMessage(), e );
        }

        if ( plugin instanceof ContextEnabled )
        {
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

    public Object getPluginComponent( Plugin plugin,
                                      String role,
                                      String roleHint )
        throws PluginManagerException, ComponentLookupException
    {
        PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );

        PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );

        return pluginContainer.lookup( role, roleHint );
    }
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

    public Map getPluginComponents( Plugin plugin,
                                    String role )
        throws ComponentLookupException, PluginManagerException
    {
        PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );

        PlexusContainer pluginContainer = getPluginContainer( pluginDescriptor );

        return pluginContainer.lookupMap( role );
    }
View Full Code Here

Examples of org.apache.maven.plugin.descriptor.PluginDescriptor

                "Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e );
        }

        // this plugin's descriptor should have been discovered in the child creation, so we should be able to
        // circle around and set the artifacts and class realm
        PluginDescriptor addedPlugin = pluginCollector.getPluginDescriptor( plugin );

        if ( addedPlugin == null )
        {
            throw new IllegalStateException( "The plugin descriptor for the plugin " + plugin + " was not found."
                + " Please verify that the plugin JAR " + pluginArtifact.getFile() + " is intact." );
        }

        addedPlugin.setClassRealm( child.getContainerRealm() );

        // we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved
        // later when the plugin is first invoked. Retrieving this artifact will in turn allow us to
        // transitively resolve its dependencies, and add them to the plugin container...
        addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) );
        addedPlugin.setPluginArtifact( pluginArtifact );

        try
        {
            // the only Plugin instance which will have dependencies is the one specified in the project.
            // We need to look for a Plugin instance there, in case the instance we're using didn't come from
            // the project.
            Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey() );

            if ( projectPlugin == null )
            {
                projectPlugin = plugin;
            }

            Set artifacts = MavenMetadataSource.createArtifacts( artifactFactory, projectPlugin.getDependencies(), null,
                                                                 null, project );

//            Set artifacts =
//                MavenMetadataSource.createArtifacts( artifactFactory, plugin.getDependencies(), null, null, project );

            addedPlugin.setIntroducedDependencyArtifacts( artifacts );
        }
        catch ( InvalidDependencyVersionException e )
        {
            throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e );
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.