Package org.apache.maven.model

Examples of org.apache.maven.model.Reporting


        parentReport.setGroupId( "org.apache.maven.plugins" );
        parentReport.setVersion( "1.0" );

        List parentPlugins = Collections.singletonList( parentReport );

        Reporting parentBuild = new Reporting();
        parentBuild.setPlugins( parentPlugins );

        parent.setReporting( parentBuild );

        assembler.assembleModelInheritance( child, parent );
View Full Code Here


        parentPlugin.setVersion( "1.0" );
        parentPlugin.setInherited( "true" );

        List parentPlugins = Collections.singletonList( parentPlugin );

        Reporting parentBuild = new Reporting();
        parentBuild.setPlugins( parentPlugins );

        parent.setReporting( parentBuild );

        assembler.assembleModelInheritance( child, parent );
View Full Code Here

        parentPlugin.setVersion( "1.0" );
        parentPlugin.setInherited( "false" );

        List parentPlugins = Collections.singletonList( parentPlugin );

        Reporting parentBuild = new Reporting();
        parentBuild.setPlugins( parentPlugins );

        parent.setReporting( parentBuild );

        assembler.assembleModelInheritance( child, parent );
View Full Code Here

        assertNull( "test execution with inherited == false should NOT be inherited to child model.", executionMap.get( testId ) );
    }

    private void assertReports( List expectedPlugins, Model child )
    {
        Reporting childBuild = child.getReporting();

        if ( ( expectedPlugins != null ) && !expectedPlugins.isEmpty() )
        {
            assertNotNull( childBuild );

            Map childPluginsMap = childBuild.getReportPluginsAsMap();

            if ( childPluginsMap != null )
            {
                assertEquals( expectedPlugins.size(), childPluginsMap.size() );

                for ( Iterator it = expectedPlugins.iterator(); it.hasNext(); )
                {
                    ReportPlugin expectedPlugin = (ReportPlugin) it.next();

                    ReportPlugin childPlugin = (ReportPlugin) childPluginsMap.get( expectedPlugin.getKey() );

                    assertReportsEqual( expectedPlugin, childPlugin );
                }
            }
            else
            {
                fail( "child plugins collection is null, but expectations map is not." );
            }
        }
        else
        {
            assertTrue( ( childBuild == null ) || ( childBuild.getPlugins() == null ) || childBuild.getPlugins().isEmpty() );
        }
    }
View Full Code Here

    }

    private void injectReporting( Profile profile, Model model )
    {
        // Reports :: aggregate
        Reporting profileReporting = profile.getReporting();
        Reporting modelReporting = model.getReporting();

        if ( profileReporting != null )
        {
            if ( modelReporting == null )
            {
                model.setReporting( profileReporting );
            }
            else
            {
                if ( StringUtils.isEmpty( modelReporting.getOutputDirectory() ) )
                {
                    modelReporting.setOutputDirectory( profileReporting.getOutputDirectory() );
                }

                Map mergedReportPlugins = new HashMap();

                Map profileReportersByKey = profileReporting.getReportPluginsAsMap();

                List modelReportPlugins = modelReporting.getPlugins();

                if ( modelReportPlugins != null )
                {
                    for ( Iterator it = modelReportPlugins.iterator(); it.hasNext(); )
                    {
                        ReportPlugin modelReportPlugin = (ReportPlugin) it.next();

                        String inherited = modelReportPlugin.getInherited();

                        if ( StringUtils.isEmpty( inherited ) || Boolean.valueOf( inherited ).booleanValue() )
                        {
                            ReportPlugin profileReportPlugin = (ReportPlugin) profileReportersByKey
                                .get( modelReportPlugin.getKey() );

                            ReportPlugin mergedReportPlugin = modelReportPlugin;

                            if ( profileReportPlugin != null )
                            {
                                mergedReportPlugin = profileReportPlugin;

                                mergeReportPlugins( profileReportPlugin, modelReportPlugin );
                            }
                            else if ( StringUtils.isEmpty( inherited ) )
                            {
                                mergedReportPlugin.unsetInheritanceApplied();
                            }

                            mergedReportPlugins.put( mergedReportPlugin.getKey(), mergedReportPlugin );
                        }
                    }
                }

                for ( Iterator it = profileReportersByKey.entrySet().iterator(); it.hasNext(); )
                {
                    Map.Entry entry = (Map.Entry) it.next();

                    String key = (String) entry.getKey();

                    if ( !mergedReportPlugins.containsKey( key ) )
                    {
                        mergedReportPlugins.put( key, entry.getValue() );
                    }
                }

                modelReporting.setPlugins( new ArrayList( mergedReportPlugins.values() ) );

                modelReporting.flushReportPluginMap();
            }
        }
    }
View Full Code Here

    {
        if ( generatedModel.getReporting() != null )
        {
            if ( model.getReporting() == null )
            {
                model.setReporting( new Reporting() );
            }

            @SuppressWarnings( "unchecked" )
            Map<String, ReportPlugin> reportPluginsByIds = model.getReporting().getReportPluginsAsMap();
            @SuppressWarnings( "unchecked" )
View Full Code Here

    }

    protected void mergeModelBase_Reporting( ModelBase target, ModelBase source, boolean sourceDominant,
                                             Map<Object, Object> context )
    {
        Reporting src = source.getReporting();
        if ( src != null )
        {
            Reporting tgt = target.getReporting();
            if ( tgt == null )
            {
                tgt = new Reporting();
                target.setReporting( tgt );
            }
            mergeReporting( tgt, src, sourceDominant, context );
        }
    }
View Full Code Here

    implements ReportingConverter
{

    public void convertReporting( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
    {
        Reporting reporting = model.getReporting();

        if ( reporting == null )
        {
            return;
        }

        Build build = model.getBuild();

        if ( build == null )
        {
            build = new Build();
            model.setBuild( build );
        }

        Plugin sitePlugin = findSitePlugin( build );

        if ( sitePlugin == null )
        {
            sitePlugin = new Plugin();
            sitePlugin.setArtifactId( "maven-site-plugin" );
            PluginManagement pluginManagement = build.getPluginManagement();
            if ( pluginManagement == null )
            {
                pluginManagement = new PluginManagement();
                build.setPluginManagement( pluginManagement );
            }
            pluginManagement.addPlugin( sitePlugin );
        }

        Xpp3Dom configuration = (Xpp3Dom) sitePlugin.getConfiguration();

        if ( configuration == null )
        {
            configuration = new Xpp3Dom( "configuration" );
            sitePlugin.setConfiguration( configuration );
        }

        Xpp3Dom reportPlugins = configuration.getChild( "reportPlugins" );

        if ( reportPlugins != null )
        {
            // new-style report configuration already present, assume user handled entire conversion
            return;
        }

        if ( configuration.getChild( "outputDirectory" ) == null )
        {
            addDom( configuration, "outputDirectory", reporting.getOutputDirectory() );
        }

        reportPlugins = new Xpp3Dom( "reportPlugins" );
        configuration.addChild( reportPlugins );

        boolean hasMavenProjectInfoReportsPlugin = false;

        /* waiting for MSITE-484 before deprecating <reporting> section
        if ( !reporting.getPlugins().isEmpty()
            && request.getValidationLevel() >= ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1 )
        {

            problems.add( new ModelProblemCollectorRequest( Severity.WARNING, Version.V31 )
                    .setMessage( "The <reporting> section is deprecated, please move the reports to the <configuration> section of the new Maven Site Plugin." )
                    .setLocation( reporting.getLocation( "" ) ) );
        }*/

        for ( ReportPlugin plugin : reporting.getPlugins() )
        {
            Xpp3Dom reportPlugin = convert( plugin );
            reportPlugins.addChild( reportPlugin );

            if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin
                && "org.apache.maven.plugins".equals( plugin.getGroupId() )
                && "maven-project-info-reports-plugin".equals( plugin.getArtifactId() ) )
            {
                hasMavenProjectInfoReportsPlugin = true;
            }
        }

        if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin )
        {
            Xpp3Dom dom = new Xpp3Dom( "reportPlugin" );

            addDom( dom, "groupId", "org.apache.maven.plugins" );
            addDom( dom, "artifactId", "maven-project-info-reports-plugin" );
View Full Code Here

        return scm;
    }

    private Reporting translateReports( List v3Reports )
    {
        Reporting reports = null;
        if ( v3Reports != null && !v3Reports.isEmpty() )
        {
            reports = new Reporting();
            for ( Iterator it = v3Reports.iterator(); it.hasNext(); )
            {
                String reportName = (String) it.next();

                Pattern pluginNamePattern = Pattern.compile( "maven-(.+)-plugin" );
                Matcher matcher = pluginNamePattern.matcher( reportName );

                if ( !matcher.matches() )
                {
                    warnings.add(
                        "Non-standard report: \'" + reportName + "\'. Skipping this one." );
                }
                else
                {
                    ReportPlugin reportPlugin = new ReportPlugin();

                    reportPlugin.setGroupId( findReportPluginGroupId( reportName ) );

                    reportPlugin.setArtifactId( reportName );

                    StringBuffer info = new StringBuffer();

                    info.append( "Using some derived information for report: \'" ).append( reportName )
                        .append( "\'.\n" )
                        .append( "\to groupId: \'" ).append( reportPlugin.getGroupId() ).append( "\'\n" )
                        .append( "\to artifactId: \'" ).append( reportName ).append( "\'\n" )
                        .append( "\to goal: \'report\'\n" )
                        .append( "\n" )
                        .append( "These values were extracted using the v3 report naming convention," )
                        .append( " but may be wrong." );

                    warnings.add( info.toString() );

                    reports.addPlugin( reportPlugin );
                }
            }
        }

        return reports;
View Full Code Here

                if ( addPlugin )
                {
                    if ( v4Model.getReporting() == null )
                    {
                        v4Model.setReporting( new Reporting() );
                    }
                    v4Model.getReporting().addPlugin( plugin );
                    sendInfoMessage( "Adding report " + plugin.getGroupId() + ":" + plugin.getArtifactId() );
                    fireAddReportEvent( plugin );
                }
View Full Code Here

TOP

Related Classes of org.apache.maven.model.Reporting

Copyright © 2018 www.massapicom. 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.