Package org.apache.maven.model

Examples of org.apache.maven.model.Reporting


        assembler.assembleModelInheritance( child, parent );
        assertNull( child.getReporting() );

        // parent is default, and child has no reporting section
        parent = makeBaseModel( "parent" );
        parent.setReporting( new Reporting() );
        child = makeBaseModel( "child" );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is false, and child has no reporting section
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( false ) );
        child = makeBaseModel( "child" );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is true, and child has no reporting section
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( true ) );
        child = makeBaseModel( "child" );

        assembler.assembleModelInheritance( child, parent );
        assertTrue( child.getReporting().isExcludeDefaults() );

        // parent has no reporting section, child is false
        parent = makeBaseModel( "parent" );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( false ) );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is default, and child is false
        parent = makeBaseModel( "parent" );
        parent.setReporting( new Reporting() );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( false ) );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is false, and child is false
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( false ) );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( false ) );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is true, and child is false
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( true ) );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( false ) );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent has no reporting section, child is true
        parent = makeBaseModel( "parent" );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( true ) );

        assembler.assembleModelInheritance( child, parent );
        assertTrue( child.getReporting().isExcludeDefaults() );

        // parent is default, and child is true
        parent = makeBaseModel( "parent" );
        parent.setReporting( new Reporting() );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( true ) );

        assembler.assembleModelInheritance( child, parent );
        assertTrue( child.getReporting().isExcludeDefaults() );

        // parent is false, and child is true
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( false ) );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( true ) );

        assembler.assembleModelInheritance( child, parent );
        assertTrue( child.getReporting().isExcludeDefaults() );

        // parent is true, and child is true
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( true ) );
        child = makeBaseModel( "child" );
        child.setReporting( createReportingWithExcludeDefaults( true ) );

        assembler.assembleModelInheritance( child, parent );
        assertTrue( child.getReporting().isExcludeDefaults() );

        // parent has no reporting section, child is default
        parent = makeBaseModel( "parent" );
        child = makeBaseModel( "child" );
        child.setReporting( new Reporting() );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is default, and child is default
        parent = makeBaseModel( "parent" );
        parent.setReporting( new Reporting() );
        child = makeBaseModel( "child" );
        child.setReporting( new Reporting() );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is false, and child is default
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( false ) );
        child = makeBaseModel( "child" );
        child.setReporting( new Reporting() );

        assembler.assembleModelInheritance( child, parent );
        assertFalse( child.getReporting().isExcludeDefaults() );

        // parent is true, and child is default
        parent = makeBaseModel( "parent" );
        parent.setReporting( createReportingWithExcludeDefaults( true ) );
        child = makeBaseModel( "child" );
        child.setReporting( new Reporting() );

        assembler.assembleModelInheritance( child, parent );
        assertTrue( child.getReporting().isExcludeDefaults() );
    }
View Full Code Here


        assertTrue( child.getReporting().isExcludeDefaults() );
    }

    private Reporting createReportingWithExcludeDefaults( boolean excludeDefaults )
    {
        Reporting reporting = new Reporting();
        reporting.setExcludeDefaults( excludeDefaults );
        return reporting;
    }
View Full Code Here

        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

     *
     *   X -> Y -> A -> B -> C -> D -> E -> F
     */
    public void testShouldPreserveChildOrderingOfReportsAfterParentMerge()
    {
        Reporting parent = new Reporting();

        parent.addPlugin( createReportPlugin( "group", "artifact", "1.0", Collections.EMPTY_MAP ) );
        parent.addPlugin( createReportPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key", "value" ) ) );

        Reporting child = new Reporting();

        child.addPlugin( createReportPlugin( "group3", "artifact3", "1.0", Collections.EMPTY_MAP ) );
        child.addPlugin( createReportPlugin( "group2", "artifact2", "1.0", Collections.singletonMap( "key2", "value2" ) ) );

        ModelUtils.mergeReportPluginLists( child, parent, true );

        List results = child.getPlugins();

        assertEquals( 3, results.size() );

        ReportPlugin result1 = (ReportPlugin) results.get( 0 );

View Full Code Here

                                                           MavenProject project )
        throws ReleaseFailureException
    {
        List<ReportPlugin> releaseReportPlugins = null;

        Reporting reporting = project.getModel().getReporting();

        if ( reporting != null )
        {
            List<ReportPlugin> reportPlugins = reporting.getPlugins();

            if ( reportPlugins != null )
            {
                @SuppressWarnings( "unchecked" )
                Map<String, Artifact> artifactsById = project.getReportArtifactMap();
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

     * @param parser
     */
    private Reporting parseReporting(String tagName, XmlPullParser parser, boolean strict, String encoding)
        throws IOException, XmlPullParserException
    {
        Reporting reporting = new Reporting();
        reporting.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( parser.getName().equals( "excludeDefaults" )  )
            {
                if ( parsed.contains( "excludeDefaults" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "excludeDefaults" );
                reporting.setExcludeDefaults( getBooleanValue( getTrimmedValue( parser.nextText()), "excludeDefaults", parser ) );
            }
            else if ( parser.getName().equals( "outputDirectory" )  )
            {
                if ( parsed.contains( "outputDirectory" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "outputDirectory" );
                reporting.setOutputDirectory( getTrimmedValue( parser.nextText()) );
            }
            else if ( parser.getName().equals( "plugins" )  )
            {
                if ( parsed.contains( "plugins" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "plugins" );
                java.util.List plugins = new java.util.ArrayList();
                reporting.setPlugins( plugins );
                while ( parser.nextTag() == XmlPullParser.START_TAG )
                {
                    if ( parser.getName().equals( "plugin" ) )
                    {
                        plugins.add( parseReportPlugin( "plugin", parser, strict, encoding ) );
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.