sort reports alphabetically

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@312909 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-11 16:23:20 +00:00
parent 1fb6768963
commit 8cf50fbfae
3 changed files with 48 additions and 4 deletions

View File

@ -49,8 +49,8 @@ public abstract class AbstractHttpUnitReportTestCase
// NavBar
assertEquals( "index.html", links[1].getURLString() );
assertEquals( "project-info.html", links[2].getURLString() );
assertEquals( "integration.html", links[3].getURLString() );
assertEquals( "dependencies.html", links[4].getURLString() );
assertEquals( "dependencies.html", links[3].getURLString() );
assertEquals( "integration.html", links[4].getURLString() );
assertEquals( "issue-tracking.html", links[5].getURLString() );
assertEquals( "license.html", links[6].getURLString() );
assertEquals( "mail-lists.html", links[7].getURLString() );

View File

@ -0,0 +1,42 @@
package org.apache.maven.plugins.site;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.reporting.MavenReport;
import java.util.Comparator;
import java.util.Locale;
/**
* Sorts reports.
*
* @todo move to reporting API?
* @todo allow reports to define their order in some other way?
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class ReportComparator
implements Comparator
{
public int compare( Object o1, Object o2 )
{
MavenReport r1 = (MavenReport) o1;
MavenReport r2 = (MavenReport) o2;
return r1.getName( Locale.getDefault() ).compareTo( r2.getName( Locale.getDefault() ) );
}
}

View File

@ -51,6 +51,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Comparator;
/**
* Generates the project site.
@ -224,8 +225,9 @@ public class SiteMojo
Map categories = categorizeReports( reports );
List projectInfos = (List) categories.get( MavenReport.CATEGORY_PROJECT_INFORMATION );
List projectReports = (List) categories.get( MavenReport.CATEGORY_PROJECT_REPORTS );
Comparator reportComparator = new ReportComparator();
List projectInfos = Collections.sort( (List) categories.get( MavenReport.CATEGORY_PROJECT_INFORMATION ), reportComparator );
List projectReports = Collections.sort( (List) categories.get( MavenReport.CATEGORY_PROJECT_REPORTS ), reportComparator );
if ( projectInfos == null )
{