Author: vsiveton Date: Sun Dec 12 21:27:50 2010 New Revision: 1044930 URL: http://svn.apache.org/viewvc?rev=1044930&view=rev Log: MDOAP-30: Update requirement to Maven 2.2 and Java 5
o jump code to java5 o renamed some methods Modified: maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java maven/plugins/trunk/maven-doap-plugin/src/main/mdo/asfextOptions.mdo maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java Modified: maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java?rev=1044930&r1=1044929&r2=1044930&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java (original) +++ maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapMojo.java Sun Dec 12 21:27:50 2010 @@ -30,10 +30,9 @@ import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Comparator; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Locale; -import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.TimeZone; @@ -178,7 +177,7 @@ public class DoapMojo * @readonly * @since 1.0 */ - private List remoteRepositories; + private List<ArtifactRepository> remoteRepositories; // ---------------------------------------------------------------------- // Doap options @@ -293,6 +292,7 @@ public class DoapMojo // ---------------------------------------------------------------------- /** {...@inheritdoc} */ + @SuppressWarnings( "unchecked" ) public void execute() throws MojoExecutionException { @@ -410,10 +410,10 @@ public class DoapMojo writeReleases( writer ); // Developers - writeDevelopersOrContributors( writer, project.getDevelopers() ); + writeContributors( writer, project.getDevelopers() ); // Contributors - writeDevelopersOrContributors( writer, project.getContributors() ); + writeContributors( writer, project.getContributors() ); // ASFext if ( asfExtOptions.isIncluded() ) @@ -438,7 +438,7 @@ public class DoapMojo if ( validate ) { - List errors = DoapUtil.validate( doapFile ); + List<String> errors = DoapUtil.validate( doapFile ); if ( !errors.isEmpty() ) { for ( int i = 0; i < errors.size(); i++ ) @@ -770,10 +770,10 @@ public class DoapMojo XmlWriterUtil.writeCommentText( writer, "The URI of the license the software is distributed under.", 2 ); // TODO: how to map to usefulinc site, or if this is necessary, the OSI page might // be more appropriate. - for ( Iterator it = project.getLicenses().iterator(); it.hasNext(); ) + @SuppressWarnings( "unchecked" ) + List<License> licenses = project.getLicenses(); + for ( License license : licenses ) { - License license = (License) it.next(); - if ( StringUtils.isNotEmpty( license.getUrl() ) ) { DoapUtil.writeRdfResourceElement( writer, "license", license.getUrl() ); @@ -824,11 +824,11 @@ public class DoapMojo } XmlWriterUtil.writeLineBreak( writer ); - XmlWriterUtil.writeCommentText( writer, "Mailing list.", 2 ); - for ( Iterator it = project.getMailingLists().iterator(); it.hasNext(); ) + XmlWriterUtil.writeCommentText( writer, "Mailing lists.", 2 ); + @SuppressWarnings( "unchecked" ) + List<MailingList> mailingLists = project.getMailingLists(); + for ( MailingList mailingList : mailingLists ) { - MailingList mailingList = (MailingList) it.next(); - if ( StringUtils.isNotEmpty( mailingList.getArchive() ) ) { DoapUtil.writeRdfResourceElement( writer, "mailing-list", mailingList.getArchive() ); @@ -840,10 +840,8 @@ public class DoapMojo if ( mailingList.getOtherArchives() != null ) { - for ( Iterator it2 = mailingList.getOtherArchives().iterator(); it2.hasNext(); ) + for ( String otherArchive : mailingList.getOtherArchives() ) { - String otherArchive = (String) it2.next(); - if ( StringUtils.isNotEmpty( otherArchive ) ) { DoapUtil.writeRdfResourceElement( writer, "mailing-list", otherArchive ); @@ -873,10 +871,8 @@ public class DoapMojo project.getPackaging() ); RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - for ( Iterator it = remoteRepositories.iterator(); it.hasNext(); ) + for ( ArtifactRepository repo : remoteRepositories ) { - ArtifactRepository repo = (ArtifactRepository) it.next(); - if ( repo.isBlacklisted() ) { continue; @@ -906,16 +902,14 @@ public class DoapMojo return; } - List versions = metadata.getMetadata().getVersioning().getVersions(); + List<String> versions = metadata.getMetadata().getVersioning().getVersions(); // Recent releases in first Collections.reverse( versions ); boolean addComment = false; int i = 0; - for ( Iterator it = versions.iterator(); it.hasNext(); ) + for ( String version : versions ) { - String version = (String) it.next(); - if ( !addComment ) { XmlWriterUtil.writeLineBreak( writer ); @@ -942,10 +936,8 @@ public class DoapMojo writer.endElement(); // revision // list all file release from all remote repos - for ( Iterator it2 = remoteRepositories.iterator(); it2.hasNext(); ) + for ( ArtifactRepository repo : remoteRepositories ) { - ArtifactRepository repo = (ArtifactRepository) it2.next(); - Artifact artifactRelease = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(), version, null, project.getPackaging() ); @@ -1108,16 +1100,16 @@ public class DoapMojo * Write all DOAP persons. * * @param writer not null - * @param developersOrContributors list of developers or contributors + * @param contributors list of developers or contributors */ - private void writeDevelopersOrContributors( XMLWriter writer, List developersOrContributors ) + private void writeContributors( XMLWriter writer, List<Contributor> contributors ) { - if ( developersOrContributors == null || developersOrContributors.isEmpty() ) + if ( contributors == null || contributors.isEmpty() ) { return; } - boolean isDeveloper = Developer.class.isAssignableFrom( developersOrContributors.get( 0 ).getClass() ); + boolean isDeveloper = Developer.class.isAssignableFrom( contributors.get( 0 ).getClass() ); if ( isDeveloper ) { XmlWriterUtil.writeLineBreak( writer ); @@ -1129,13 +1121,13 @@ public class DoapMojo XmlWriterUtil.writeCommentText( writer, "Contributed persons", 2 ); } - List maintainers = DoapUtil.getDevelopersOrContributorsWithMaintainerRole( i18n, developersOrContributors ); - List developers = DoapUtil.getDevelopersOrContributorsWithDeveloperRole( i18n, developersOrContributors ); - List documenters = DoapUtil.getDevelopersOrContributorsWithDocumenterRole( i18n, developersOrContributors ); - List translators = DoapUtil.getDevelopersOrContributorsWithTranslatorRole( i18n, developersOrContributors ); - List testers = DoapUtil.getDevelopersOrContributorsWithTesterRole( i18n, developersOrContributors ); - List helpers = DoapUtil.getDevelopersOrContributorsWithHelperRole( i18n, developersOrContributors ); - List unknowns = DoapUtil.getDevelopersOrContributorsWithUnknownRole( i18n, developersOrContributors ); + List<Contributor> maintainers = DoapUtil.getContributorsWithMaintainerRole( i18n, contributors ); + List<Contributor> developers = DoapUtil.getContributorsWithDeveloperRole( i18n, contributors ); + List<Contributor> documenters = DoapUtil.getContributorsWithDocumenterRole( i18n, contributors ); + List<Contributor> translators = DoapUtil.getContributorsWithTranslatorRole( i18n, contributors ); + List<Contributor> testers = DoapUtil.getContributorsWithTesterRole( i18n, contributors ); + List<Contributor> helpers = DoapUtil.getContributorsWithHelperRole( i18n, contributors ); + List<Contributor> unknowns = DoapUtil.getContributorsWithUnknownRole( i18n, contributors ); // By default, all developers are maintainers and contributors are helpers if ( isDeveloper ) @@ -1150,27 +1142,27 @@ public class DoapMojo // all alphabetical if ( developers.size() != 0 ) { - writeDeveloperOrContributor( writer, developers, "developer" ); + writeContributor( writer, developers, "developer" ); } if ( documenters.size() != 0 ) { - writeDeveloperOrContributor( writer, documenters, "documenter" ); + writeContributor( writer, documenters, "documenter" ); } if ( helpers.size() != 0 ) { - writeDeveloperOrContributor( writer, helpers, "helper" ); + writeContributor( writer, helpers, "helper" ); } if ( maintainers.size() != 0 ) { - writeDeveloperOrContributor( writer, maintainers, "maintainer" ); + writeContributor( writer, maintainers, "maintainer" ); } if ( testers.size() != 0 ) { - writeDeveloperOrContributor( writer, testers, "tester" ); + writeContributor( writer, testers, "tester" ); } if ( translators.size() != 0 ) { - writeDeveloperOrContributor( writer, translators, "translator" ); + writeContributor( writer, translators, "translator" ); } } @@ -1189,9 +1181,9 @@ public class DoapMojo * @param writer not null * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @param doapType not null - * @see #writeDeveloperOrContributor(XMLWriter, Object, String) + * @see #writeContributor(XMLWriter, Object, String) */ - private void writeDeveloperOrContributor( XMLWriter writer, List developersOrContributors, String doapType ) + private void writeContributor( XMLWriter writer, List<Contributor> developersOrContributors, String doapType ) { if ( developersOrContributors == null || developersOrContributors.isEmpty() ) { @@ -1199,12 +1191,10 @@ public class DoapMojo } // Sort list by names - Collections.sort( developersOrContributors, new Comparator() + Collections.sort( developersOrContributors, new Comparator<Contributor>() { - /** - * {...@inheritdoc} - */ - public int compare( Object arg0, Object arg1 ) + /** {...@inheritdoc} */ + public int compare( Contributor arg0, Contributor arg1 ) { if ( Developer.class.isAssignableFrom( arg0.getClass() ) ) { @@ -1223,8 +1213,8 @@ public class DoapMojo return developer0.getName().compareTo( developer1.getName() ); } - Contributor contributor0 = (Contributor) arg0; - Contributor contributor1 = (Contributor) arg1; + Contributor contributor0 = arg0; + Contributor contributor1 = arg1; if ( contributor0.getName() == null ) { @@ -1239,10 +1229,9 @@ public class DoapMojo } } ); - for ( Iterator it = developersOrContributors.iterator(); it.hasNext(); ) + for ( Contributor developersOrContributor : developersOrContributors ) { - Object obj = it.next(); - writeDeveloperOrContributor( writer, obj, doapType ); + writeContributor( writer, developersOrContributor, doapType ); } } @@ -1264,7 +1253,7 @@ public class DoapMojo * @see <a href="http://xmlns.com/foaf/0.1/Organization">http://xmlns.com/foaf/0.1/Organization</a> * @see <a href="http://xmlns.com/foaf/0.1/homepage">http://xmlns.com/foaf/0.1/homepage</a> */ - private void writeDeveloperOrContributor( XMLWriter writer, Object developerOrContributor, String doapType ) + private void writeContributor( XMLWriter writer, Contributor developerOrContributor, String doapType ) { if ( developerOrContributor == null ) { @@ -1276,32 +1265,13 @@ public class DoapMojo throw new IllegalArgumentException( "doapType is required." ); } - String name; - String email; - String organization; - String organizationUrl; - String homepage; + String name = developerOrContributor.getName(); + String email = developerOrContributor.getEmail(); + String organization = developerOrContributor.getOrganization(); + String organizationUrl = developerOrContributor.getOrganizationUrl(); + String homepage = developerOrContributor.getUrl(); String nodeId = null; - if ( Developer.class.isAssignableFrom( developerOrContributor.getClass() ) ) - { - Developer d = (Developer) developerOrContributor; - name = d.getName(); - email = d.getEmail(); - organization = d.getOrganization(); - organizationUrl = d.getOrganizationUrl(); - homepage = d.getUrl(); - } - else - { - Contributor c = (Contributor) developerOrContributor; - name = c.getName(); - email = c.getEmail(); - organization = c.getOrganization(); - organizationUrl = c.getOrganizationUrl(); - homepage = c.getUrl(); - } - // Name is required to write doap if ( StringUtils.isEmpty( name ) ) { @@ -1443,7 +1413,8 @@ public class DoapMojo } // asfext:chair - List developers = project.getDevelopers(); + @SuppressWarnings( "unchecked" ) + List<Developer> developers = project.getDevelopers(); if ( StringUtils.isNotEmpty( asfExtOptions.getChair() ) ) { @@ -1460,7 +1431,7 @@ public class DoapMojo Developer chair = ASFExtOptions.findChair( developers ); if ( chair != null ) { - writeDeveloperOrContributor( writer, chair, "asfext:chair" ); + writeContributor( writer, chair, "asfext:chair" ); } else { @@ -1472,12 +1443,10 @@ public class DoapMojo // asfext:member if ( developers != null && developers.size() > 0 ) { - List pmcMember = ASFExtOptions.findPMCMembers( developers ); - for ( Iterator it = pmcMember.iterator(); it.hasNext(); ) + List<Developer> pmcMembers = ASFExtOptions.findPMCMembers( developers ); + for ( Developer pmcMember : pmcMembers ) { - Developer developer = (Developer) it.next(); - - writeDeveloperOrContributor( writer, developer, "asfext:member" ); + writeContributor( writer, pmcMember, "asfext:member" ); } } @@ -1499,10 +1468,8 @@ public class DoapMojo return; } - for ( Iterator it = asfExtOptions.getStandards().iterator(); it.hasNext(); ) + for ( Standard standard : asfExtOptions.getStandards() ) { - Standard standard = (Standard) it.next(); - writer.startElement( "asfext:implements" ); writer.startElement( "asfext:Standard" ); @@ -1568,15 +1535,16 @@ public class DoapMojo * @param writer not null * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @param doapType not null - * @see #writeDeveloperOrContributor(XMLWriter, Object, String) + * @see #writeContributor(XMLWriter, Object, String) */ private void writeOrganizations( XMLWriter writer ) { - Set organizations = DoapUtil.getOrganizations(); + Set<Entry<String, DoapUtil.Organization>> organizations = DoapUtil.getOrganizations(); - for ( Iterator it = organizations.iterator(); it.hasNext(); ) + for (Entry<String, DoapUtil.Organization> organizationEntry : organizations ) { - DoapUtil.Organization organization = (DoapUtil.Organization) ( (Map.Entry) it.next() ).getValue(); + DoapUtil.Organization organization = organizationEntry.getValue(); + writer.startElement( "foaf:Organization" ); if ( !StringUtils.isEmpty( organization.getName() ) ) { @@ -1586,10 +1554,10 @@ public class DoapMojo { DoapUtil.writeRdfResourceElement( writer, "foaf:homepage", organization.getUrl() ); } - List members = organization.getMembers(); - for ( Iterator memberIterator = members.iterator(); memberIterator.hasNext(); ) + List<String> members = organization.getMembers(); + for ( String member : members ) { - DoapUtil.writeRdfNodeIdElement( writer, "foaf:member", (String) memberIterator.next() ); + DoapUtil.writeRdfNodeIdElement( writer, "foaf:member", member ); } writer.endElement(); // foaf:Organization } Modified: maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java?rev=1044930&r1=1044929&r2=1044930&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java (original) +++ maven/plugins/trunk/maven-doap-plugin/src/main/java/org/apache/maven/plugin/doap/DoapUtil.java Sun Dec 12 21:27:50 2010 @@ -27,11 +27,11 @@ import java.text.DateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.Properties; @@ -67,7 +67,7 @@ public class DoapUtil protected static final String RDF_NODE_ID = "rdf:nodeID"; /** DoaP Organizations stored by name */ - private static Map organizations = new HashMap(); + private static Map<String,DoapUtil.Organization> organizations = new HashMap<String,DoapUtil.Organization>(); /** * Write comments in the DOAP file header @@ -196,9 +196,9 @@ public class DoapUtil * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @return a none null list of developers or contributors which have a <code>developer</code> DOAP role. */ - public static List getDevelopersOrContributorsWithDeveloperRole( I18N i18n, List developersOrContributors ) + public static List<Contributor> getContributorsWithDeveloperRole( I18N i18n, List<Contributor> developersOrContributors ) { - return (List) filterDevelopersOrContributorsByDoapRoles( i18n, developersOrContributors ).get( "developers" ); + return filterContributorsByDoapRoles( i18n, developersOrContributors ).get( "developers" ); } /** @@ -206,9 +206,9 @@ public class DoapUtil * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @return a none null list of developers or contributors which have a <code>documenter</code> DOAP role. */ - public static List getDevelopersOrContributorsWithDocumenterRole( I18N i18n, List developersOrContributors ) + public static List<Contributor> getContributorsWithDocumenterRole( I18N i18n, List<Contributor> developersOrContributors ) { - return (List) filterDevelopersOrContributorsByDoapRoles( i18n, developersOrContributors ).get( "documenters" ); + return filterContributorsByDoapRoles( i18n, developersOrContributors ).get( "documenters" ); } /** @@ -216,9 +216,9 @@ public class DoapUtil * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @return a none null list of developers or contributors which have an <code>helper</code> DOAP role. */ - public static List getDevelopersOrContributorsWithHelperRole( I18N i18n, List developersOrContributors ) + public static List<Contributor> getContributorsWithHelperRole( I18N i18n, List<Contributor> developersOrContributors ) { - return (List) filterDevelopersOrContributorsByDoapRoles( i18n, developersOrContributors ).get( "helpers" ); + return filterContributorsByDoapRoles( i18n, developersOrContributors ).get( "helpers" ); } /** @@ -226,9 +226,9 @@ public class DoapUtil * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @return a none null list of developers or contributors which have a <code>maintainer</code> DOAP role. */ - public static List getDevelopersOrContributorsWithMaintainerRole( I18N i18n, List developersOrContributors ) + public static List<Contributor> getContributorsWithMaintainerRole( I18N i18n, List<Contributor> developersOrContributors ) { - return (List) filterDevelopersOrContributorsByDoapRoles( i18n, developersOrContributors ).get( "maintainers" ); + return filterContributorsByDoapRoles( i18n, developersOrContributors ).get( "maintainers" ); } /** @@ -236,9 +236,9 @@ public class DoapUtil * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @return a none null list of developers or contributors which have a <code>tester</code> DOAP role. */ - public static List getDevelopersOrContributorsWithTesterRole( I18N i18n, List developersOrContributors ) + public static List<Contributor> getContributorsWithTesterRole( I18N i18n, List<Contributor> developersOrContributors ) { - return (List) filterDevelopersOrContributorsByDoapRoles( i18n, developersOrContributors ).get( "testers" ); + return filterContributorsByDoapRoles( i18n, developersOrContributors ).get( "testers" ); } /** @@ -246,9 +246,9 @@ public class DoapUtil * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @return a none null list of developers or contributors which have a <code>translator</code> DOAP role. */ - public static List getDevelopersOrContributorsWithTranslatorRole( I18N i18n, List developersOrContributors ) + public static List<Contributor> getContributorsWithTranslatorRole( I18N i18n, List<Contributor> developersOrContributors ) { - return (List) filterDevelopersOrContributorsByDoapRoles( i18n, developersOrContributors ).get( "translators" ); + return filterContributorsByDoapRoles( i18n, developersOrContributors ).get( "translators" ); } /** @@ -256,9 +256,9 @@ public class DoapUtil * @param developersOrContributors list of <code>{...@link Developer}/{...@link Contributor}</code> * @return a none null list of developers or contributors which have an <code>unknown</code> DOAP role. */ - public static List getDevelopersOrContributorsWithUnknownRole( I18N i18n, List developersOrContributors ) + public static List<Contributor> getContributorsWithUnknownRole( I18N i18n, List<Contributor> developersOrContributors ) { - return (List) filterDevelopersOrContributorsByDoapRoles( i18n, developersOrContributors ).get( "unknowns" ); + return filterContributorsByDoapRoles( i18n, developersOrContributors ).get( "unknowns" ); } /** @@ -274,7 +274,7 @@ public class DoapUtil private String url; - private List members = new LinkedList(); + private List<String> members = new LinkedList<String>(); public Organization( String name, String url ) { @@ -307,11 +307,11 @@ public class DoapUtil members.add( nodeId ); } - public List getMembers() + public List<String> getMembers() { return members; } - }; + } /** * put an organization from the pom file in the organization list. @@ -320,9 +320,9 @@ public class DoapUtil * @param url from the pom file (e.g. http://yoyodyne.example.org/about) * @return the existing organization if a duplicate, or a new one. */ - public static Organization addOrganization( String name, String url ) + public static DoapUtil.Organization addOrganization( String name, String url ) { - Organization organization = (Organization) organizations.get( name ); + Organization organization = organizations.get( name ); if ( organization == null ) { @@ -330,6 +330,7 @@ public class DoapUtil } organizations.put( name, organization ); + return organization; } @@ -353,7 +354,7 @@ public class DoapUtil * * @return Map.EntrySet of DoapUtil.Organization */ - public static Set getOrganizations() + public static Set<Entry<String, DoapUtil.Organization>> getOrganizations() { return organizations.entrySet(); } @@ -365,7 +366,7 @@ public class DoapUtil * @return an empty list if the DOAP file is valid, otherwise a list of errors. * @since 1.1 */ - public static List validate( File doapFile ) + public static List<String> validate( File doapFile ) { if ( doapFile == null || !doapFile.isFile() ) { @@ -375,10 +376,10 @@ public class DoapUtil Model model = ModelFactory.createDefaultModel(); RDFReader r = model.getReader( "RDF/XML" ); r.setProperty( "error-mode", "strict-error" ); - final List errors = new ArrayList(); + final List<String> errors = new ArrayList<String>(); r.setErrorHandler( new RDFDefaultErrorHandler() { - /** {...@inheritdoc} */ + @Override public void error( Exception e ) { errors.add( e.getMessage() ); @@ -413,82 +414,68 @@ public class DoapUtil * <code>translators</code>, <code>testers</code>, <code>helpers</code>, <code>unknowns</code> as keys and * list of <code>{...@link Developer}/{...@link Contributor}</code> as value. */ - private static Map filterDevelopersOrContributorsByDoapRoles( I18N i18n, List developersOrContributors ) + private static Map<String, List<Contributor>> filterContributorsByDoapRoles( I18N i18n, List<Contributor> developersOrContributors ) { - Map returnMap = new HashMap( 7 ); - returnMap.put( "maintainers", new ArrayList() ); - returnMap.put( "developers", new ArrayList() ); - returnMap.put( "documenters", new ArrayList() ); - returnMap.put( "translators", new ArrayList() ); - returnMap.put( "testers", new ArrayList() ); - returnMap.put( "helpers", new ArrayList() ); - returnMap.put( "unknowns", new ArrayList() ); + Map<String, List<Contributor>> returnMap = new HashMap<String, List<Contributor>>( 7 ); + returnMap.put( "maintainers", new ArrayList<Contributor>() ); + returnMap.put( "developers", new ArrayList<Contributor>() ); + returnMap.put( "documenters", new ArrayList<Contributor>() ); + returnMap.put( "translators", new ArrayList<Contributor>() ); + returnMap.put( "testers", new ArrayList<Contributor>() ); + returnMap.put( "helpers", new ArrayList<Contributor>() ); + returnMap.put( "unknowns", new ArrayList<Contributor>() ); if ( developersOrContributors == null || developersOrContributors.isEmpty() ) { return returnMap; } - for ( Iterator it = developersOrContributors.iterator(); it.hasNext(); ) + for ( Contributor contributor : developersOrContributors ) { - Object obj = it.next(); - - List roles; - if ( Developer.class.isAssignableFrom( obj.getClass() ) ) - { - Developer developer = (Developer) obj; - roles = developer.getRoles(); - } - else - { - Contributor contributor = (Contributor) obj; - roles = contributor.getRoles(); - } + List<String> roles = contributor.getRoles(); if ( roles != null && roles.size() != 0 ) { - for ( Iterator it2 = roles.iterator(); it2.hasNext(); ) + for ( String role : roles ) { - String role = (String) it2.next(); - role = role.toLowerCase( Locale.ENGLISH ); - if ( role.indexOf( getLowerCaseString( i18n, "doap.maintainer" ) ) != -1 ) + if ( role.contains( getLowerCaseString( i18n, "doap.maintainer" ) ) ) { - ( (List) returnMap.get( "maintainers" ) ).add( obj ); + returnMap.get( "maintainers" ).add( contributor ); } - else if ( role.indexOf( getLowerCaseString( i18n, "doap.developer" ) ) != -1 ) + else if ( role.contains( getLowerCaseString( i18n, "doap.developer" ) ) ) { - ( (List) returnMap.get( "developers" ) ).add( obj ); + returnMap.get( "developers" ).add( contributor ); } - else if ( role.indexOf( getLowerCaseString( i18n, "doap.documenter" ) ) != -1 ) + else if ( role.contains( getLowerCaseString( i18n, "doap.documenter" ) ) ) { - ( (List) returnMap.get( "documenters" ) ).add( obj ); + returnMap.get( "documenters" ).add( contributor ); } - else if ( role.indexOf( getLowerCaseString( i18n, "doap.translator" ) ) != -1 ) + else if ( role.contains( getLowerCaseString( i18n, "doap.translator" ) ) ) { - ( (List) returnMap.get( "translators" ) ).add( obj ); + returnMap.get( "translators" ).add( contributor ); } - else if ( role.indexOf( getLowerCaseString( i18n, "doap.tester" ) ) != -1 ) + else if ( role.contains( getLowerCaseString( i18n, "doap.tester" ) ) ) { - ( (List) returnMap.get( "testers" ) ).add( obj ); + returnMap.get( "testers" ).add( contributor ); } - else if ( role.indexOf( getLowerCaseString( i18n, "doap.helper" ) ) != -1 ) + else if ( role.contains( getLowerCaseString( i18n, "doap.helper" ) ) ) { - ( (List) returnMap.get( "helpers" ) ).add( obj ); + returnMap.get( "helpers" ).add( contributor ); } - else if ( role.indexOf( getLowerCaseString( i18n, "doap.emeritus" ) ) != -1 ) + else if ( role.contains( getLowerCaseString( i18n, "doap.emeritus" ) ) ) { // Don't add as developer nor as contributor as the person is no longer involved } else { - ( (List) returnMap.get( "unknowns" ) ).add( obj ); + returnMap.get( "unknowns" ).add( contributor ); } } } else { - ( (List) returnMap.get( "unknowns" ) ).add( obj ); + returnMap.get( "unknowns" ).add( contributor ); } } Modified: maven/plugins/trunk/maven-doap-plugin/src/main/mdo/asfextOptions.mdo URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/main/mdo/asfextOptions.mdo?rev=1044930&r1=1044929&r2=1044930&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/main/mdo/asfextOptions.mdo (original) +++ maven/plugins/trunk/maven-doap-plugin/src/main/mdo/asfextOptions.mdo Sun Dec 12 21:27:50 2010 @@ -229,23 +229,20 @@ http://svn.apache.org/repos/asf/infrastr * @param developers list of <code>{...@link org.apache.maven.model.Developer}</code> * @return a Developer or null if not found. */ - public static org.apache.maven.model.Developer findChair( java.util.List developers ) + public static org.apache.maven.model.Developer findChair( java.util.List<org.apache.maven.model.Developer> developers ) { if ( developers == null || developers.isEmpty() ) { return null; } - for ( java.util.Iterator it = developers.iterator(); it.hasNext(); ) + for ( org.apache.maven.model.Developer developer : developers ) { - org.apache.maven.model.Developer developer = (org.apache.maven.model.Developer) it.next(); - java.util.List roles = developer.getRoles(); + java.util.List<String> roles = developer.getRoles(); - for ( java.util.Iterator it2 = roles.iterator(); it2.hasNext(); ) + for ( String role : roles ) { - String role = (String) it2.next(); - - if ( role.toLowerCase().indexOf( "chair" ) != -1 ) + if ( role.toLowerCase().contains( "chair" ) ) { return developer; } @@ -261,31 +258,28 @@ http://svn.apache.org/repos/asf/infrastr * @param developers list of <code>{...@link org.apache.maven.model.Developer}</code> * @return a not null list of Developer. */ - public static java.util.List findPMCMembers( java.util.List developers ) + public static java.util.List<org.apache.maven.model.Developer> findPMCMembers( java.util.List<org.apache.maven.model.Developer> developers ) { if ( developers == null || developers.isEmpty() ) { return null; } - java.util.List pmc = new java.util.ArrayList(); - for ( java.util.Iterator it = developers.iterator(); it.hasNext(); ) + java.util.List<org.apache.maven.model.Developer> pmcs = new java.util.ArrayList<org.apache.maven.model.Developer>(); + for ( org.apache.maven.model.Developer developer : developers ) { - org.apache.maven.model.Developer developer = (org.apache.maven.model.Developer) it.next(); - java.util.List roles = developer.getRoles(); + java.util.List<String> roles = developer.getRoles(); - for ( java.util.Iterator it2 = roles.iterator(); it2.hasNext(); ) + for ( String role : roles ) { - String role = (String) it2.next(); - - if ( role.toLowerCase().indexOf( "pmc" ) != -1 ) + if ( role.toLowerCase().contains( "pmc" ) ) { - pmc.add( developer ); + pmcs.add( developer ); } } } - return pmc; + return pmcs; } /** @@ -307,19 +301,19 @@ http://svn.apache.org/repos/asf/infrastr if ( project.getScm() != null ) { if ( org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getScm().getUrl() ) - && project.getScm().getUrl().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getScm().getUrl().contains( APACHE_DOMAIN_NAME ) ) { return true; } if ( org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getScm().getConnection() ) - && project.getScm().getConnection().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getScm().getConnection().contains( APACHE_DOMAIN_NAME ) ) { return true; } if ( org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getScm().getDeveloperConnection() ) - && project.getScm().getDeveloperConnection().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getScm().getDeveloperConnection().contains( APACHE_DOMAIN_NAME ) ) { return true; } @@ -328,28 +322,28 @@ http://svn.apache.org/repos/asf/infrastr if ( project.getDistributionManagement() != null ) { if ( org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getDistributionManagement().getDownloadUrl() ) - && project.getDistributionManagement().getDownloadUrl().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getDistributionManagement().getDownloadUrl().contains( APACHE_DOMAIN_NAME ) ) { return true; } if ( project.getDistributionManagement().getRepository() != null && org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getDistributionManagement().getRepository().getUrl() ) - && project.getDistributionManagement().getRepository().getUrl().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getDistributionManagement().getRepository().getUrl().contains( APACHE_DOMAIN_NAME ) ) { return true; } if ( project.getDistributionManagement().getSnapshotRepository() != null && org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getDistributionManagement().getSnapshotRepository().getUrl() ) - && project.getDistributionManagement().getSnapshotRepository().getUrl().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getDistributionManagement().getSnapshotRepository().getUrl().contains( APACHE_DOMAIN_NAME ) ) { return true; } if ( project.getDistributionManagement().getSite() != null && org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getDistributionManagement().getSite().getUrl() ) - && project.getDistributionManagement().getSite().getUrl().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getDistributionManagement().getSite().getUrl().contains( APACHE_DOMAIN_NAME ) ) { return true; } @@ -357,13 +351,13 @@ http://svn.apache.org/repos/asf/infrastr if ( project.getOrganization() != null && org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getOrganization().getUrl() ) - && project.getOrganization().getUrl().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getOrganization().getUrl().contains( APACHE_DOMAIN_NAME ) ) { return true; } if ( org.codehaus.plexus.util.StringUtils.isNotEmpty( project.getUrl() ) - && project.getUrl().indexOf( APACHE_DOMAIN_NAME ) > 0 ) + && project.getUrl().contains( APACHE_DOMAIN_NAME ) ) { return true; } Modified: maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java?rev=1044930&r1=1044929&r2=1044930&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java (original) +++ maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapMojoTest.java Sun Dec 12 21:27:50 2010 @@ -42,14 +42,14 @@ import org.codehaus.plexus.util.StringUt public class DoapMojoTest extends AbstractMojoTestCase { - /** {...@inheritdoc} */ + @Override protected void setUp() throws Exception { super.setUp(); } - /** {...@inheritdoc} */ + @Override protected void tearDown() throws Exception { @@ -186,7 +186,7 @@ public class DoapMojoTest /** * @return remote repo */ - private static List getRemoteRepositories() + private static List<ArtifactRepository> getRemoteRepositories() { ArtifactRepository repository = new DefaultArtifactRepository( "central", "http://repo1.maven.org/maven2", new DefaultRepositoryLayout() ); Modified: maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java?rev=1044930&r1=1044929&r2=1044930&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java (original) +++ maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/DoapUtilTest.java Sun Dec 12 21:27:50 2010 @@ -24,6 +24,7 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.List; +import org.apache.maven.model.Contributor; import org.apache.maven.model.Developer; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.i18n.I18N; @@ -117,13 +118,13 @@ public class DoapUtilTest /** * Test method for: - * {...@link DoapUtil#getDevelopersOrContributorsWithDeveloperRole(I18N, List)} - * {...@link DoapUtil#getDevelopersOrContributorsWithDocumenterRole(I18N, List)} - * {...@link DoapUtil#getDevelopersOrContributorsWithHelperRole(I18N, List)} - * {...@link DoapUtil#getDevelopersOrContributorsWithMaintainerRole(I18N, List)} - * {...@link DoapUtil#getDevelopersOrContributorsWithTesterRole(I18N, List)} - * {...@link DoapUtil#getDevelopersOrContributorsWithTranslatorRole(I18N, List)} - * {...@link DoapUtil#getDevelopersOrContributorsWithUnknownRole(I18N, List)} + * {...@link DoapUtil#getContributorsWithDeveloperRole(I18N, List)} + * {...@link DoapUtil#getContributorsWithDocumenterRole(I18N, List)} + * {...@link DoapUtil#getContributorsWithHelperRole(I18N, List)} + * {...@link DoapUtil#getContributorsWithMaintainerRole(I18N, List)} + * {...@link DoapUtil#getContributorsWithTesterRole(I18N, List)} + * {...@link DoapUtil#getContributorsWithTranslatorRole(I18N, List)} + * {...@link DoapUtil#getContributorsWithUnknownRole(I18N, List)} * * @throws Exception if any */ @@ -134,7 +135,7 @@ public class DoapUtilTest assertNotNull( i18n ); assertNotNull( i18n.getBundle() ); - List developersOrContributors = new ArrayList(); + List<Contributor> developersOrContributors = new ArrayList<Contributor>(); // One role Developer dev = new Developer(); @@ -143,13 +144,13 @@ public class DoapUtilTest developersOrContributors.add( dev ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithDeveloperRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithDocumenterRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithHelperRole( i18n, developersOrContributors ).isEmpty() ); - assertFalse( DoapUtil.getDevelopersOrContributorsWithMaintainerRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithTesterRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithTranslatorRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithUnknownRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithDeveloperRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithDocumenterRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithHelperRole( i18n, developersOrContributors ).isEmpty() ); + assertFalse( DoapUtil.getContributorsWithMaintainerRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithTesterRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithTranslatorRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithUnknownRole( i18n, developersOrContributors ).isEmpty() ); // Several roles developersOrContributors.clear(); @@ -163,13 +164,13 @@ public class DoapUtilTest developersOrContributors.add( dev ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithDeveloperRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithDocumenterRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithHelperRole( i18n, developersOrContributors ).isEmpty() ); - assertFalse( DoapUtil.getDevelopersOrContributorsWithMaintainerRole( i18n, developersOrContributors ).isEmpty() ); - assertFalse( DoapUtil.getDevelopersOrContributorsWithTesterRole( i18n, developersOrContributors ).isEmpty() ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithTranslatorRole( i18n, developersOrContributors ).isEmpty() ); - assertFalse( DoapUtil.getDevelopersOrContributorsWithUnknownRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithDeveloperRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithDocumenterRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithHelperRole( i18n, developersOrContributors ).isEmpty() ); + assertFalse( DoapUtil.getContributorsWithMaintainerRole( i18n, developersOrContributors ).isEmpty() ); + assertFalse( DoapUtil.getContributorsWithTesterRole( i18n, developersOrContributors ).isEmpty() ); + assertTrue( DoapUtil.getContributorsWithTranslatorRole( i18n, developersOrContributors ).isEmpty() ); + assertFalse( DoapUtil.getContributorsWithUnknownRole( i18n, developersOrContributors ).isEmpty() ); // Skip emeritus role developersOrContributors.clear(); @@ -181,10 +182,10 @@ public class DoapUtilTest developersOrContributors.add( dev ); - int sizeBeforeEmeritus = DoapUtil.getDevelopersOrContributorsWithUnknownRole( i18n, developersOrContributors).size(); + int sizeBeforeEmeritus = DoapUtil.getContributorsWithUnknownRole( i18n, developersOrContributors).size(); dev.addRole( " Emeritus" ); - assertTrue( DoapUtil.getDevelopersOrContributorsWithUnknownRole( i18n, developersOrContributors).size() == sizeBeforeEmeritus ); + assertTrue( DoapUtil.getContributorsWithUnknownRole( i18n, developersOrContributors).size() == sizeBeforeEmeritus ); } Modified: maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java?rev=1044930&r1=1044929&r2=1044930&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java (original) +++ maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/AsfDoapProjectStub.java Sun Dec 12 21:27:50 2010 @@ -22,6 +22,7 @@ package org.apache.maven.plugin.doap.stu import java.io.File; import java.util.List; +import org.apache.maven.model.Developer; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; @@ -64,14 +65,14 @@ public class AsfDoapProjectStub setDevelopers( model.getDevelopers() ); } - /** {...@inheritdoc} */ + @Override public File getBasedir() { return new File( super.getBasedir() + "/src/test/resources/unit/asf-doap-configuration/" ); } - /** {...@inheritdoc} */ - public List getDevelopers() + @Override + public List<Developer> getDevelopers() { return model.getDevelopers(); } Modified: maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java?rev=1044930&r1=1044929&r2=1044930&view=diff ============================================================================== --- maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java (original) +++ maven/plugins/trunk/maven-doap-plugin/src/test/java/org/apache/maven/plugin/doap/stubs/DoapProjectStub.java Sun Dec 12 21:27:50 2010 @@ -22,6 +22,7 @@ package org.apache.maven.plugin.doap.stu import java.io.File; import java.util.List; +import org.apache.maven.model.Developer; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; @@ -64,14 +65,14 @@ public class DoapProjectStub setDevelopers( model.getDevelopers() ); } - /** {...@inheritdoc} */ + @Override public File getBasedir() { return new File( super.getBasedir() + "/src/test/resources/unit/doap-configuration/" ); } - /** {...@inheritdoc} */ - public List getDevelopers() + @Override + public List<Developer> getDevelopers() { return model.getDevelopers(); }