Examples of PluginDescriptor


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

        {
            fail( "plugin descriptor not found: '" + pluginXml + "'." );
        }

        Reader reader = null;
        PluginDescriptor pd;
        try
        {
            reader = new InputStreamReader( resource.openStream() );
            pd = new PluginDescriptorBuilder().build( reader, pluginXml );
        }
        finally
        {
            IOUtil.close( reader );
        }

        Map<String, Object> config = new HashMap<String, Object>();
        config.put( "basedir", new File( "." ).getAbsoluteFile() );
        config.put( "messageLevel", "info" );

        MojoDescriptor md = pd.getMojo( "test" );

        AntMojoWrapper wrapper =
            new AntMojoWrapper( new AntScriptInvoker( md, Thread.currentThread().getContextClassLoader() ) );

        wrapper.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );

        MockControl artifactCtl = null;
        MockControl pathTranslatorCtl = null;
        if ( includeImplied )
        {
            File pluginXmlFile = new File( StringUtils.replace( resource.getPath(), "%20", " " ) );

            File jarFile = File.createTempFile( "AntMojoWrapperTest.", ".test.jar" );
            jarFile.deleteOnExit();

            JarArchiver archiver = new JarArchiver();
            archiver.enableLogging( new ConsoleLogger( Logger.LEVEL_ERROR, "archiver" ) );
            archiver.setDestFile( jarFile );
            archiver.addFile( pluginXmlFile, pluginXml );
            archiver.createArchive();

            artifactCtl = MockControl.createControl( Artifact.class );
            Artifact artifact = (Artifact) artifactCtl.getMock();

            artifact.getFile();
            artifactCtl.setReturnValue( jarFile, MockControl.ZERO_OR_MORE );

            artifact.getGroupId();
            artifactCtl.setReturnValue( "groupId", MockControl.ZERO_OR_MORE );

            artifact.getArtifactId();
            artifactCtl.setReturnValue( "artifactId", MockControl.ZERO_OR_MORE );

            artifact.getVersion();
            artifactCtl.setReturnValue( "1", MockControl.ZERO_OR_MORE );

            artifact.getId();
            artifactCtl.setReturnValue( "groupId:artifactId:jar:1", MockControl.ZERO_OR_MORE );

            artifact.getClassifier();
            artifactCtl.setReturnValue( null, MockControl.ZERO_OR_MORE );

            pathTranslatorCtl = MockControl.createControl( PathTranslator.class );
            PathTranslator pt = (PathTranslator) pathTranslatorCtl.getMock();

            Model model = new Model();

            Build build = new Build();
            build.setDirectory( "target" );

            model.setBuild( build );

            MavenProject project = new MavenProject( model );
            project.setFile( new File( "pom.xml" ).getAbsoluteFile() );

            artifactCtl.replay();
            pathTranslatorCtl.replay();

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

            config.put( "project", project );
            config.put( "session", new MavenSession( null, null, null, null, null, null, null, null, null, null ) );
            config.put( "mojoExecution", new MojoExecution( md ) );
View Full Code Here

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

        }

        mojoScanner.setActiveExtractors( extractors );

        // TODO: could use this more, eg in the writing of the plugin descriptor!
        PluginDescriptor pluginDescriptor = new PluginDescriptor();

        pluginDescriptor.setGroupId( project.getGroupId() );

        pluginDescriptor.setArtifactId( project.getArtifactId() );

        pluginDescriptor.setVersion( project.getVersion() );

        pluginDescriptor.setGoalPrefix( goalPrefix );

        pluginDescriptor.setName( project.getName() );

        pluginDescriptor.setDescription( project.getDescription() );

        if ( encoding == null || encoding.length() < 1 )
        {
            getLog().warn( "Using platform encoding (" + ReaderFactory.FILE_ENCODING
                               + " actually) to read mojo metadata, i.e. build is platform dependent!" );
        }
        else
        {
            getLog().info( "Using '" + encoding + "' encoding to read mojo metadata." );
        }

        try
        {
            pluginDescriptor.setDependencies( GeneratorUtils.toComponentDependencies( project.getRuntimeDependencies() ) );

            PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
            request.setEncoding( encoding );
            request.setSkipErrorNoDescriptorsFound( skipErrorNoDescriptorsFound );
            request.setDependencies( dependencies );
View Full Code Here

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

            getLog().warn( "\n\nGoal prefix is specified as: '" + goalPrefix + "'. Maven currently expects it to be '"
                               + defaultGoalPrefix + "'.\n" );
        }

        // TODO: could use this more, eg in the writing of the plugin descriptor!
        PluginDescriptor pluginDescriptor = new PluginDescriptor();

        pluginDescriptor.setGroupId( project.getGroupId() );

        pluginDescriptor.setArtifactId( project.getArtifactId() );

        pluginDescriptor.setVersion( project.getVersion() );

        pluginDescriptor.setGoalPrefix( goalPrefix );

        try
        {
            pluginDescriptor.setDependencies( GeneratorUtils.toComponentDependencies( project.getRuntimeDependencies() ) );

            PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
            request.setEncoding( encoding );
            request.setSkipErrorNoDescriptorsFound( true );
            request.setDependencies( dependencies );
View Full Code Here

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

                goal = goal.substring(0, pos);
            }

            MavenSession session = env.getMavenSession();

            PluginDescriptor pluginDescriptor = MavenCompatibilityHelper.loadPluginDescriptor(plugin, env, session);
            MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
            if (mojoDescriptor == null) {
                throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin "
                        + plugin.getGroupId() + ":"
                        + plugin.getArtifactId() + ":"
                        + plugin.getVersion());
View Full Code Here

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

    private MojoDescriptor copyDependenciesMojoDescriptor;

    @Before
    public void setUpMocks() throws Exception {
        PluginDescriptor mavenDependencyPluginDescriptor = new PluginDescriptor();

        copyDependenciesMojoDescriptor = new MojoDescriptor();
        copyDependenciesMojoDescriptor.setGoal("copy-dependencies");
        copyDependenciesMojoDescriptor.setConfiguration(new XmlPlexusConfiguration("configuration"));
        copyDependenciesMojoDescriptor.setPluginDescriptor(mavenDependencyPluginDescriptor);

        mavenDependencyPluginDescriptor.addMojo(copyDependenciesMojoDescriptor);

        when(session.getRepositorySession()).thenReturn(repositorySession);
        when(pluginManager.loadPlugin(
                eq(plugin(
                        groupId("org.apache.maven.plugins"),
View Full Code Here

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

                    logger.info( "configuring reportPlugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion() );
                }
               
                List<String> goals = new ArrayList<String>();

                PluginDescriptor pluginDescriptor = mavenPluginManager.getPluginDescriptor( plugin, repositoryRequest );
               
                if ( reportPlugin.getReportSets().isEmpty() )
                {
                    List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
                    for ( MojoDescriptor mojoDescriptor : mojoDescriptors )
                    {
                        goals.add( mojoDescriptor.getGoal() );
                    }
                }
                else
                {
                    for ( ReportSet reportSet : reportPlugin.getReportSets() )
                    {
                        goals.addAll( reportSet.getReports() );
                    }
                }

                for ( String goal : goals )
                {
                    MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
                    if ( mojoDescriptor == null )
                    {
                        throw new MojoNotFoundException( goal, pluginDescriptor );
                    }

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

                    mojoExecution.setConfiguration( convert( mojoDescriptor ) );

                    mojoExecution.setMojoDescriptor( mojoDescriptor );


                   
                    mavenPluginManager.setupPluginRealm( pluginDescriptor,
                                                         mavenReportExecutorRequest.getMavenSession(),
                                                         Thread.currentThread().getContextClassLoader(), imports, exclusionSetFilter );

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

                    if ( mavenReport == null )
                    {
                        continue;
                    }

                    if ( reportPlugin.getConfiguration() != null )
                    {

                        Xpp3Dom mergedConfiguration =
                            Xpp3DomUtils.mergeXpp3Dom( (Xpp3Dom) reportPlugin.getConfiguration(),
                                                       convert( mojoDescriptor ) );
                       
                        Xpp3Dom cleanedConfiguration = new Xpp3Dom( "configuration" );
                        if ( mergedConfiguration.getChildren() != null )
                        {
                            for ( int i = 0, size = mergedConfiguration.getChildren().length; i < size; i++ )
                            {
                                if ( mojoDescriptor.getParameterMap().containsKey(
                                                                                   mergedConfiguration.getChildren()[i].getName() ) )
                                {
                                    cleanedConfiguration.addChild( mergedConfiguration.getChildren()[i] );
                                }
                            }
                        }
                        if ( getLog().isDebugEnabled() )
                        {
                            getLog().debug( "mojoExecution mergedConfiguration " + mergedConfiguration );
                            getLog().debug( "mojoExecution cleanedConfiguration " + cleanedConfiguration );
                        }
                      
                        mojoExecution.setConfiguration( cleanedConfiguration );
                    }

                    mavenReport =
                        getConfiguredMavenReport( mojoExecution, pluginDescriptor, mavenReportExecutorRequest );
                    if ( mavenReport != null )
                    {

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

                        lifecycleExecutor.calculateForkedExecutions( mojoExecution,
                                                                     mavenReportExecutorRequest.getMavenSession() );
                        if ( !mojoExecution.getForkedExecutions().isEmpty() )
                        {
View Full Code Here

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

    public synchronized PluginDescriptor getPluginDescriptor( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
        throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
    {
        PluginDescriptorCache.Key cacheKey = pluginDescriptorCache.createKey( plugin, repositories, session );

        PluginDescriptor pluginDescriptor = pluginDescriptorCache.get( cacheKey );

        if ( pluginDescriptor == null )
        {
            Artifact pluginArtifact =
                RepositoryUtils.toArtifact( pluginDependenciesResolver.resolve( plugin, repositories, session ) );

            pluginDescriptor = extractPluginDescriptor( pluginArtifact, plugin );

            pluginDescriptorCache.put( cacheKey, pluginDescriptor );
        }

        pluginDescriptor.setPlugin( plugin );

        return pluginDescriptor;
    }
View Full Code Here

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

    }

    private PluginDescriptor extractPluginDescriptor( Artifact pluginArtifact, Plugin plugin )
        throws PluginDescriptorParsingException, InvalidPluginDescriptorException
    {
        PluginDescriptor pluginDescriptor = null;

        File pluginFile = pluginArtifact.getFile();

        try
        {
            if ( pluginFile.isFile() )
            {
                JarFile pluginJar = new JarFile( pluginFile, false );
                try
                {
                    ZipEntry pluginDescriptorEntry = pluginJar.getEntry( getPluginDescriptorLocation() );

                    if ( pluginDescriptorEntry != null )
                    {
                        InputStream is = pluginJar.getInputStream( pluginDescriptorEntry );

                        pluginDescriptor = parsePluginDescriptor( is, plugin, pluginFile.getAbsolutePath() );
                    }
                }
                finally
                {
                    pluginJar.close();
                }
            }
            else
            {
                File pluginXml = new File( pluginFile, getPluginDescriptorLocation() );

                if ( pluginXml.isFile() )
                {
                    InputStream is = new BufferedInputStream( new FileInputStream( pluginXml ) );
                    try
                    {
                        pluginDescriptor = parsePluginDescriptor( is, plugin, pluginXml.getAbsolutePath() );
                    }
                    finally
                    {
                        IOUtil.close( is );
                    }
                }
            }

            if ( pluginDescriptor == null )
            {
                throw new IOException( "No plugin descriptor found at " + getPluginDescriptorLocation() );
            }
        }
        catch ( IOException e )
        {
            throw new PluginDescriptorParsingException( plugin, pluginFile.getAbsolutePath(), e );
        }

        MavenPluginValidator validator = new MavenPluginValidator( pluginArtifact );

        validator.validate( pluginDescriptor );

        if ( validator.hasErrors() )
        {
            throw new InvalidPluginDescriptorException( "Invalid plugin descriptor for " + plugin.getId() + " ("
                + pluginFile + ")", validator.getErrors() );
        }

        pluginDescriptor.setPluginArtifact( pluginArtifact );

        return pluginDescriptor;
    }
View Full Code Here

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

    {
        try
        {
            Reader reader = ReaderFactory.newXmlReader( is );

            PluginDescriptor pluginDescriptor = builder.build( reader, descriptorLocation );

            return pluginDescriptor;
        }
        catch ( IOException e )
        {
View Full Code Here

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

    public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
                                             RepositorySystemSession session )
        throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
        InvalidPluginDescriptorException
    {
        PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin, repositories, session );

        MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );

        if ( mojoDescriptor == null )
        {
            throw new MojoNotFoundException( goal, pluginDescriptor );
        }
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.