Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DB50BD7FF for ; Mon, 10 Dec 2012 21:43:24 +0000 (UTC) Received: (qmail 80647 invoked by uid 500); 10 Dec 2012 21:43:24 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 80573 invoked by uid 500); 10 Dec 2012 21:43:24 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 80565 invoked by uid 99); 10 Dec 2012 21:43:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Dec 2012 21:43:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Dec 2012 21:42:46 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9A7722388CB3 for ; Mon, 10 Dec 2012 21:41:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r841548 [32/34] - in /websites/production/maven/content/plugins/maven-doap-plugin: ./ apidocs/ apidocs/org/ apidocs/org/apache/ apidocs/org/apache/maven/ apidocs/org/apache/maven/plugin/ apidocs/org/apache/maven/plugin/doap/ apidocs/org/apa... Date: Mon, 10 Dec 2012 21:40:59 -0000 To: commits@maven.apache.org From: olamy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121210214116.9A7722388CB3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: websites/production/maven/content/plugins/maven-doap-plugin/xref/org/apache/maven/plugin/doap/DoapMojo.html ============================================================================== --- websites/production/maven/content/plugins/maven-doap-plugin/xref/org/apache/maven/plugin/doap/DoapMojo.html (added) +++ websites/production/maven/content/plugins/maven-doap-plugin/xref/org/apache/maven/plugin/doap/DoapMojo.html Mon Dec 10 21:40:31 2012 @@ -0,0 +1,2702 @@ + + + + +DoapMojo xref + + + +
+
+1   package org.apache.maven.plugin.doap;
+2   
+3   /*
+4    * Licensed to the Apache Software Foundation (ASF) under one
+5    * or more contributor license agreements.  See the NOTICE file
+6    * distributed with this work for additional information
+7    * regarding copyright ownership.  The ASF licenses this file
+8    * to you under the Apache License, Version 2.0 (the
+9    * "License"); you may not use this file except in compliance
+10   * with the License.  You may obtain a copy of the License at
+11   *
+12   *  http://www.apache.org/licenses/LICENSE-2.0
+13   *
+14   * Unless required by applicable law or agreed to in writing,
+15   * software distributed under the License is distributed on an
+16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+17   * KIND, either express or implied.  See the License for the
+18   * specific language governing permissions and limitations
+19   * under the License.
+20   */
+21  
+22  import java.io.File;
+23  import java.io.IOException;
+24  import java.io.Writer;
+25  import java.net.MalformedURLException;
+26  import java.net.URL;
+27  import java.text.DateFormat;
+28  import java.text.ParseException;
+29  import java.text.SimpleDateFormat;
+30  import java.util.ArrayList;
+31  import java.util.Arrays;
+32  import java.util.Collections;
+33  import java.util.Comparator;
+34  import java.util.Date;
+35  import java.util.List;
+36  import java.util.Locale;
+37  import java.util.Map;
+38  import java.util.Map.Entry;
+39  import java.util.Set;
+40  import java.util.TimeZone;
+41  
+42  import org.apache.maven.artifact.Artifact;
+43  import org.apache.maven.artifact.factory.ArtifactFactory;
+44  import org.apache.maven.artifact.repository.ArtifactRepository;
+45  import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
+46  import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+47  import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
+48  import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
+49  import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+50  import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+51  import org.apache.maven.artifact.resolver.ArtifactResolver;
+52  import org.apache.maven.model.Contributor;
+53  import org.apache.maven.model.Developer;
+54  import org.apache.maven.model.License;
+55  import org.apache.maven.plugin.AbstractMojo;
+56  import org.apache.maven.plugin.MojoExecutionException;
+57  import org.apache.maven.plugin.doap.options.ASFExtOptions;
+58  import org.apache.maven.plugin.doap.options.ASFExtOptionsUtil;
+59  import org.apache.maven.plugin.doap.options.DoapArtifact;
+60  import org.apache.maven.plugin.doap.options.DoapOptions;
+61  import org.apache.maven.plugin.doap.options.ExtOptions;
+62  import org.apache.maven.plugin.doap.options.Standard;
+63  import org.apache.maven.project.MavenProject;
+64  import org.apache.maven.project.MavenProjectBuilder;
+65  import org.apache.maven.project.ProjectBuildingException;
+66  import org.apache.maven.scm.manager.NoSuchScmProviderException;
+67  import org.apache.maven.scm.manager.ScmManager;
+68  import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository;
+69  import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
+70  import org.apache.maven.scm.repository.ScmRepository;
+71  import org.apache.maven.scm.repository.ScmRepositoryException;
+72  import org.apache.maven.settings.Settings;
+73  import org.codehaus.plexus.i18n.I18N;
+74  import org.codehaus.plexus.util.FileUtils;
+75  import org.codehaus.plexus.util.StringUtils;
+76  import org.codehaus.plexus.util.WriterFactory;
+77  import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+78  import org.codehaus.plexus.util.xml.XMLWriter;
+79  
+80  /**
+81   * Generate a <a href="http://usefulinc.com/ns/doap">Description of a Project (DOAP)</a> file from the main information
+82   * found in a POM. <br/>
+83   * <b>Note</b>: The generated file is tailored for use by projects at <a
+84   * href="http://projects.apache.org/doap.html">Apache</a>.
+85   *
+86   * @author Jason van Zyl
+87   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+88   * @version $Id: DoapMojo.java 1057614 2011-01-11 13:28:29Z vsiveton $
+89   * @since 1.0-beta-1
+90   * @goal generate
+91   */
+92  public class DoapMojo
+93      extends AbstractMojo
+94  {
+95      /** UTC Time Zone */
+96      private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
+97  
+98      /** Date format for <lastUpdated/> tag in the repository metadata, i.e.: yyyyMMddHHmmss */
+99      private static final DateFormat REPOSITORY_DATE_FORMAT;
+100 
+101     /** Date format for DOAP file, i.e. ISO-8601 YYYY-MM-DD */
+102     private static final DateFormat DOAP_DATE_FORMAT;
+103 
+104     static
+105     {
+106         REPOSITORY_DATE_FORMAT = new SimpleDateFormat( "yyyyMMddHHmmss", Locale.ENGLISH );
+107         REPOSITORY_DATE_FORMAT.setTimeZone( UTC_TIME_ZONE );
+108 
+109         DOAP_DATE_FORMAT = new SimpleDateFormat( "yyyy-MM-dd", Locale.ENGLISH );
+110         DOAP_DATE_FORMAT.setTimeZone( UTC_TIME_ZONE );
+111     }
+112 
+113     // ----------------------------------------------------------------------
+114     // Mojo components
+115     // ----------------------------------------------------------------------
+116 
+117     /**
+118      * Maven SCM Manager.
+119      *
+120      * @component
+121      * @since 1.0
+122      */
+123     private ScmManager scmManager;
+124 
+125     /**
+126      * Artifact factory.
+127      *
+128      * @component
+129      * @since 1.0
+130      */
+131     private ArtifactFactory artifactFactory;
+132 
+133     /**
+134      * Used to resolve artifacts.
+135      *
+136      * @component
+137      * @since 1.0
+138      */
+139     private RepositoryMetadataManager repositoryMetadataManager;
+140 
+141     /**
+142      * Internationalization component.
+143      *
+144      * @component
+145      * @since 1.0
+146      */
+147     private I18N i18n;
+148 
+149     // ----------------------------------------------------------------------
+150     // Mojo parameters
+151     // ----------------------------------------------------------------------
+152 
+153     /**
+154      * The POM from which information will be extracted to create a DOAP file.
+155      *
+156      * @parameter default-value="${project}"
+157      * @readonly
+158      * @required
+159      */
+160     private MavenProject project;
+161 
+162     /**
+163      * The name of the DOAP file that will be generated.
+164      *
+165      * @parameter expression="${doapFile}" default-value="doap_${project.artifactId}.rdf"
+166      * @required
+167      */
+168     private String doapFile;
+169 
+170     /**
+171      * The output directory of the DOAP file that will be generated.
+172      *
+173      * @parameter default-value="${project.reporting.outputDirectory}"
+174      * @required
+175      * @since 1.1
+176      */
+177     private String outputDirectory;
+178 
+179     /**
+180      * The local repository where the artifacts are located.
+181      *
+182      * @parameter default-value="${localRepository}"
+183      * @required
+184      * @readonly
+185      * @since 1.0
+186      */
+187     private ArtifactRepository localRepository;
+188 
+189     /**
+190      * The remote repositories where the artifacts are located.
+191      *
+192      * @parameter default-value="${project.remoteArtifactRepositories}"
+193      * @required
+194      * @readonly
+195      * @since 1.0
+196      */
+197     private List<ArtifactRepository> remoteRepositories;
+198 
+199     /**
+200      * Factory for creating artifact objects
+201      *
+202      * @component
+203      * @since 1.1
+204      */
+205     private ArtifactFactory factory;
+206 
+207     /**
+208      * Project builder
+209      *
+210      * @component
+211      * @since 1.1
+212      */
+213     private MavenProjectBuilder mavenProjectBuilder;
+214 
+215     /**
+216      * Used for resolving artifacts
+217      *
+218      * @component
+219      * @since 1.1
+220      */
+221     private ArtifactResolver resolver;
+222 
+223     /**
+224      * The current user system settings for use in Maven.
+225      *
+226      * @parameter expression="${settings}"
+227      * @required
+228      * @readonly
+229      * @since 1.1
+230      */
+231     protected Settings settings;
+232 
+233     // ----------------------------------------------------------------------
+234     // Doap options
+235     // ----------------------------------------------------------------------
+236 
+237     /**
+238      * The category which should be displayed in the DOAP file.
+239      *
+240      * @parameter expression="${category}"
+241      * @deprecated Since 1.0. Instead of, configure
+242      *             <code>&lt;doapOptions&gt;&lt;category/&gt;&lt;/doapOptions&gt;</code> parameter.
+243      */
+244     private String category;
+245 
+246     /**
+247      * The programming language which should be displayed in the DOAP file.
+248      *
+249      * @parameter expression="${language}"
+250      * @deprecated Since 1.0. Instead of, configure
+251      *             <code>&lt;doapOptions&gt;&lt;programmingLanguage/&gt;&lt;/doapOptions&gt;</code> parameter.
+252      */
+253     private String language;
+254 
+255     /**
+256      * Specific DOAP parameters, i.e. options that POM doesn't have any notions. <br/>
+257      * Example:
+258      *
+259      * <pre>
+260      * &lt;doapOptions&gt;
+261      * &nbsp;&nbsp;&lt;programmingLanguage&gt;java&lt;/programmingLanguage&gt;
+262      * &lt;/doapOptions&gt;
+263      * </pre>
+264      *
+265      * <br/>
+266      * See <a href="./apidocs/org/apache/maven/plugin/doap/options/DoapOptions.html">Javadoc</a> <br/>
+267      *
+268      * @parameter expression="${doapOptions}"
+269      * @since 1.0
+270      * @see <a href="http://usefulinc.com/ns/doap#">http://usefulinc.com/ns/doap#</a>
+271      */
+272     private DoapOptions doapOptions;
+273 
+274     /**
+275      * Specific ASF extensions parameters, i.e. options that POM doesn't have any notions but required by ASF DOAP
+276      * requirements. <br/>
+277      * Example:
+278      *
+279      * <pre>
+280      * &lt;asfExtOptions&gt;
+281      * &nbsp;&nbsp;&lt;included&gt;true&lt;/included&gt;
+282      * &nbsp;&nbsp;&lt;charter&gt;The mission of the Apache XXX project is to create and maintain software
+283      * &nbsp;&nbsp;libraries that provide ...&lt;/charter&gt;
+284      * &nbsp;&nbsp;...
+285      * &lt;/asfExtOptions&gt;
+286      * </pre>
+287      *
+288      * <b>Note</b>: By default, <code>&lt;asfExtOptions&gt;&lt;included/&gt;&lt;/asfExtOptions&gt;</code> will be
+289      * automatically set to <code>true</code> if the project is hosted at ASF. <br/>
+290      * See <a href="./apidocs/org/apache/maven/plugin/doap/options/ASFExtOptions.html">Javadoc</a> <br/>
+291      *
+292      * @parameter expression="${asfExtOptions}"
+293      * @since 1.0
+294      * @see <a href="http://svn.apache.org/repos/asf/infrastructure/site-tools/trunk/projects/asfext">
+295      *      http://svn.apache.org/repos/asf/infrastructure/site-tools/trunk/projects/asfext</a>
+296      * @see <a href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
+297      * @see <a href="http://projects.apache.org/docs/standards.html">http://projects.apache.org/docs/standards.html</a>
+298      * @see ASFExtOptionsUtil#isASFProject(MavenProject)
+299      */
+300     private ASFExtOptions asfExtOptions;
+301 
+302     /**
+303      * The value for the <code>xml:lang</code> attribute used by the <code>&lt;rdf:RDF/&gt;<code>,
+304      * <code>&lt;description/&gt;</code> and <code>&lt;shortdesc/&gt;</code> elements. <br/>
+305      * POM doesn't have any notions about language. <br/>
+306      * See <a href="http://www.w3.org/TR/REC-xml/#sec-lang-tag">http://www.w3.org/TR/REC-xml/#sec-lang-tag</a> <br/>
+307      *
+308      * @parameter expression="${lang}" default-value="en"
+309      * @required
+310      * @since 1.0
+311      */
+312     private String lang;
+313 
+314     /**
+315      * The <code>about</code> URI-reference which should be displayed in the DOAP file. Example:
+316      *
+317      * <pre>
+318      * &lt;rdf:RDF&gt;
+319      * &nbsp;&nbsp;&lt;Project rdf:about="http://maven.apache.org/"&gt;
+320      * &nbsp;&nbsp;...
+321      * &nbsp;&nbsp;&lt;/Project&gt;
+322      * &lt;/rdf:RDF&gt;
+323      * </pre>
+324      *
+325      * See <a href="http://www.w3.org/TR/1999/REC-rdf-syntax-19990222/#aboutAttr">
+326      * http://www.w3.org/TR/1999/REC-rdf-syntax-19990222/#aboutAttr</a> <br/>
+327      *
+328      * @parameter expression="${about}" default-value="${project.url}"
+329      * @since 1.0
+330      */
+331     private String about;
+332 
+333     /**
+334      * Flag to validate the generated DOAP.
+335      *
+336      * @parameter default-value="true"
+337      * @since 1.1
+338      */
+339     private boolean validate;
+340 
+341     /**
+342      * An artifact to generate the DOAP file against. <br/>
+343      * Example:
+344      *
+345      * <pre>
+346      * &lt;artifact&gt;
+347      * &nbsp;&nbsp;&lt;groupId&gt;given-artifact-groupId&lt;/groupId&gt;
+348      * &nbsp;&nbsp;&lt;artifactId&gt;given-artifact-artifactId&lt;/artifactId&gt;
+349      * &nbsp;&nbsp;&lt;version&gt;given-artifact-version&lt;/version&gt;
+350      * &lt;/artifact&gt;
+351      * </pre>
+352      *
+353      * <br/>
+354      * See <a href="./apidocs/org/apache/maven/plugin/doap/options/DaopArtifact.html">Javadoc</a> <br/>
+355      *
+356      * @parameter
+357      * @since 1.1
+358      */
+359     private DoapArtifact artifact;
+360 
+361     /**
+362      * Specifies whether the DOAP generation should be skipped.
+363      *
+364      * @parameter expression="${maven.doap.skip}" default-value="false"
+365      * @since 1.1
+366      */
+367     private boolean skip;
+368 
+369     /**
+370      * Extensions parameters. <br/>
+371      * Example:
+372      *
+373      * <pre>
+374      * &lt;extOptions&gt;
+375      * &nbsp;&lt;extOption&gt;
+376      * &nbsp;&nbsp;&nbsp;&lt;xmlnsPrefix&gt;labs&lt;/xmlnsPrefix&gt;
+377      * &nbsp;&nbsp;&nbsp;&lt;xmlnsNamespaceURI&gt;http://labs.apache.org/doap-ext/1.0#&lt;/xmlnsNamespaceURI&gt;
+378      * &nbsp;&nbsp;&nbsp;&lt;extensions&gt;
+379      * &nbsp;&nbsp;&nbsp;&nbsp;&lt;status&gt;active&lt;/status&gt;
+380      * &nbsp;&nbsp;&nbsp;&lt;/extensions&gt;
+381      * &nbsp;&lt;/extOption&gt;
+382      * &lt;/extOptions&gt;
+383      * </pre>
+384      *
+385      * See <a href="./apidocs/org/apache/maven/plugin/doap/options/ExtOptions.html">Javadoc</a> <br/>
+386      *
+387      * @parameter expression="${extOptions}"
+388      * @since 1.1
+389      */
+390     private ExtOptions[] extOptions;
+391 
+392     /**
+393      * All warn/error messages for the user.
+394      *
+395      * @since 1.1
+396      */
+397     private UserMessages messages = new UserMessages();
+398 
+399     // ----------------------------------------------------------------------
+400     // Public methods
+401     // ----------------------------------------------------------------------
+402 
+403     /** {@inheritDoc} */
+404     public void execute()
+405         throws MojoExecutionException
+406     {
+407         if ( skip )
+408         {
+409             getLog().info( "Skipping DOAP generation" );
+410             return;
+411         }
+412 
+413         // single artifact
+414         if ( artifact != null )
+415         {
+416             MavenProject givenProject = getMavenProject( artifact );
+417             if ( givenProject != null )
+418             {
+419                 File outDir = new File( outputDirectory );
+420                 if ( !outDir.isAbsolute() )
+421                 {
+422                     outDir = new File( project.getBasedir(), outputDirectory );
+423                 }
+424                 File outFile = new File( outDir, artifact.getDoapFileName() );
+425                 writeDoapFile( givenProject, outFile );
+426                 return;
+427             }
+428         }
+429 
+430         // current project
+431         File outFile = new File( doapFile );
+432         if ( !outFile.isAbsolute() )
+433         {
+434             outFile = new File( project.getBasedir(), doapFile );
+435         }
+436         if ( !doapFile.replaceAll( "\\\\", "/" ).contains( "/" ) )
+437         {
+438             File outDir = new File( outputDirectory );
+439             if ( !outDir.isAbsolute() )
+440             {
+441                 outDir = new File( project.getBasedir(), outputDirectory );
+442             }
+443             outFile = new File( outDir, doapFile );
+444         }
+445         writeDoapFile( project, outFile );
+446     }
+447 
+448     // ----------------------------------------------------------------------
+449     // Private methods
+450     // ----------------------------------------------------------------------
+451 
+452     /**
+453      * @param artifact not null
+454      * @return the maven project for the given doap artifact
+455      * @since 1.1
+456      */
+457     private MavenProject getMavenProject( DoapArtifact artifact )
+458     {
+459         if ( artifact == null )
+460         {
+461             return null;
+462         }
+463 
+464         if ( StringUtils.isEmpty( artifact.getGroupId() ) || StringUtils.isEmpty( artifact.getArtifactId() )
+465             || StringUtils.isEmpty( artifact.getVersion() ) )
+466         {
+467             getLog().warn( "Missing groupId or artifactId or version in <artifact/> parameter, ignored it." );
+468             return null;
+469         }
+470 
+471         getLog().info( "Using artifact " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
+472                            + artifact.getVersion() );
+473 
+474         try
+475         {
+476             Artifact art =
+477                 factory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+478                                                Artifact.SCOPE_COMPILE );
+479 
+480             if ( art.getFile() == null )
+481             {
+482                 MavenProject proj = mavenProjectBuilder.buildFromRepository( art, remoteRepositories, localRepository );
+483                 art = proj.getArtifact();
+484 
+485                 resolver.resolve( art, remoteRepositories, localRepository );
+486 
+487                 return proj;
+488             }
+489         }
+490         catch ( ArtifactResolutionException e )
+491         {
+492             getLog().error( "ArtifactResolutionException: " + e.getMessage() + "\nIgnored <artifact/> parameter." );
+493         }
+494         catch ( ArtifactNotFoundException e )
+495         {
+496             getLog().error( "ArtifactNotFoundException: " + e.getMessage() + "\nIgnored <artifact/> parameter." );
+497         }
+498         catch ( ProjectBuildingException e )
+499         {
+500             getLog().error( "ProjectBuildingException: " + e.getMessage() + "\nIgnored <artifact/> parameter." );
+501         }
+502 
+503         return null;
+504     }
+505 
+506     /**
+507      * Write a doap file for the given project.
+508      *
+509      * @param project not null
+510      * @param outputFile not null
+511      * @since 1.1
+512      */
+513     private void writeDoapFile( MavenProject project, File outputFile )
+514         throws MojoExecutionException
+515     {
+516         // ----------------------------------------------------------------------------
+517         // Includes ASF extensions
+518         // ----------------------------------------------------------------------------
+519 
+520         if ( !asfExtOptions.isIncluded() && ASFExtOptionsUtil.isASFProject( project ) )
+521         {
+522             getLog().info( "This project is an ASF project, ASF Extensions to DOAP will be added." );
+523             asfExtOptions.setIncluded( true );
+524         }
+525 
+526         // ----------------------------------------------------------------------------
+527         // setup pretty print xml writer
+528         // ----------------------------------------------------------------------------
+529 
+530         Writer w;
+531         try
+532         {
+533             if ( !outputFile.getParentFile().exists() )
+534             {
+535                 FileUtils.mkdir( outputFile.getParentFile().getAbsolutePath() );
+536             }
+537 
+538             w = WriterFactory.newXmlWriter( outputFile );
+539         }
+540         catch ( IOException e )
+541         {
+542             throw new MojoExecutionException( "Error creating DOAP file " + outputFile.getAbsolutePath(), e );
+543         }
+544 
+545         if ( asfExtOptions.isIncluded() )
+546         {
+547             getLog().info( "Generating an ASF DOAP file " + outputFile.getAbsolutePath() );
+548         }
+549         else
+550         {
+551             getLog().info( "Generating a pure DOAP file " + outputFile.getAbsolutePath() );
+552         }
+553 
+554         XMLWriter writer = new PrettyPrintXMLWriter( w, project.getModel().getModelEncoding(), null );
+555 
+556         // ----------------------------------------------------------------------------
+557         // Convert POM to DOAP
+558         // ----------------------------------------------------------------------------
+559 
+560         DoapUtil.writeHeader( writer );
+561 
+562         // Heading
+563         DoapUtil.writeStartElement( writer, "rdf", "RDF" );
+564         if ( Arrays.binarySearch( Locale.getISOLanguages(), lang ) < 0 )
+565         {
+566             messages.addMessage( new String[] { "doapOptions", "lang" }, lang, UserMessages.INVALID_ISO_DATE );
+567             throw new MojoExecutionException( messages.getErrorMessages().get( 0 ) );
+568         }
+569         writer.addAttribute( "xml:lang", lang );
+570         if ( StringUtils.isEmpty( doapOptions.getXmlnsNamespaceURI() ) )
+571         {
+572             messages.addMessage( new String[] { "doapOptions", "xmlnsNamespaceURI" }, null, UserMessages.REQUIRED );
+573             throw new MojoExecutionException( messages.getErrorMessages().get( 0 ) );
+574         }
+575         writer.addAttribute( "xmlns"
+576                                  + ( StringUtils.isEmpty( doapOptions.getXmlnsPrefix() ) ? "" : ":"
+577                                      + doapOptions.getXmlnsPrefix() ), doapOptions.getXmlnsNamespaceURI() );
+578         writer.addAttribute( "xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" );
+579         writer.addAttribute( "xmlns:foaf", "http://xmlns.com/foaf/0.1/" );
+580         if ( asfExtOptions.isIncluded() )
+581         {
+582             if ( StringUtils.isEmpty( asfExtOptions.getXmlnsPrefix() ) )
+583             {
+584                 messages.addMessage( new String[] { "doapOptions", "xmlnsPrefix" }, null, UserMessages.REQUIRED );
+585                 throw new MojoExecutionException( messages.getErrorMessages().get( 0 ) );
+586             }
+587             if ( StringUtils.isEmpty( asfExtOptions.getXmlnsNamespaceURI() ) )
+588             {
+589                 messages.addMessage( new String[] { "doapOptions", "xmlnsNamespaceURI" }, null, UserMessages.REQUIRED );
+590             }
+591             writer.addAttribute( "xmlns"
+592                                      + ( StringUtils.isEmpty( asfExtOptions.getXmlnsPrefix() ) ? "" : ":"
+593                                          + asfExtOptions.getXmlnsPrefix() ), asfExtOptions.getXmlnsNamespaceURI() );
+594         }
+595         if ( extOptions != null && extOptions.length > 0 && !extOptions[0].getExtensions().isEmpty() )
+596         {
+597             for ( ExtOptions extOption : extOptions )
+598             {
+599                 if ( StringUtils.isEmpty( extOption.getXmlnsPrefix() ) )
+600                 {
+601                     messages.addMessage( new String[] { "extOptions", "extOption", "xmlnsPrefix" }, null,
+602                                          UserMessages.REQUIRED );
+603                     throw new MojoExecutionException( messages.getErrorMessages().get( 0 ) );
+604                 }
+605                 if ( StringUtils.isEmpty( extOption.getXmlnsNamespaceURI() ) )
+606                 {
+607                     messages.addMessage( new String[] { "extOptions", "extOption", "xmlnsNamespaceURI" }, null,
+608                                          UserMessages.REQUIRED );
+609                     throw new MojoExecutionException( messages.getErrorMessages().get( 0 ) );
+610                 }
+611                 writer.addAttribute( "xmlns"
+612                                          + ( StringUtils.isEmpty( extOption.getXmlnsPrefix() ) ? "" : ":"
+613                                              + extOption.getXmlnsPrefix() ),
+614                                      extOption.getXmlnsNamespaceURI() );
+615             }
+616         }
+617 
+618         // Project
+619         DoapUtil.writeStartElement( writer, doapOptions.getXmlnsPrefix(), "Project" );
+620         boolean added = false;
+621         if ( artifact != null )
+622         {
+623             String about_ = project.getUrl();
+624 
+625             if ( StringUtils.isNotEmpty( about_ ) )
+626             {
+627                 try
+628                 {
+629                     new URL( about_ );
+630 
+631                     writer.addAttribute( "rdf:about", about_ );
+632                     added = true;
+633                 }
+634                 catch ( MalformedURLException e )
+635                 {
+636                 }
+637             }
+638 
+639             if ( !added )
+640             {
+641                 messages.getWarnMessages().add( "The project's url defined from " + artifact.toConfiguration()
+642                                                     + " is empty or not a valid URL, using <about/> parameter." );
+643             }
+644         }
+645 
+646         if ( !added )
+647         {
+648             if ( StringUtils.isNotEmpty( about ) )
+649             {
+650                 try
+651                 {
+652                     new URL( about );
+653 
+654                     writer.addAttribute( "rdf:about", about );
+655                 }
+656                 catch ( MalformedURLException e )
+657                 {
+658                     messages.addMessage( new String[] { "about" }, about, UserMessages.INVALID_URL );
+659                 }
+660                 added = true;
+661             }
+662         }
+663 
+664         if ( !added )
+665         {
+666             messages.addMessage( new String[] { "about" }, null, UserMessages.RECOMMENDED );
+667         }
+668 
+669         // name
+670         writeName( writer, project );
+671 
+672         // description
+673         writeDescription( writer, project );
+674 
+675         // implements
+676         writeImplements( writer );
+677 
+678         // Audience
+679         writeAudience( writer );
+680 
+681         // Vendor
+682         writeVendor( writer, project );
+683 
+684         // created
+685         writeCreated( writer, project );
+686 
+687         // homepage and old-homepage
+688         writeHomepage( writer, project );
+689 
+690         // Blog
+691         writeBlog( writer );
+692 
+693         // licenses
+694         writeLicenses( writer, project );
+695 
+696         // programming-language
+697         writeProgrammingLanguage( writer, project );
+698 
+699         // category
+700         writeCategory( writer, project );
+701 
+702         // os
+703         writeOS( writer, project );
+704 
+705         // Plateform
+706         writePlateform( writer );
+707 
+708         // Language
+709         writeLanguage( writer );
+710 
+711         // SCM
+712         writeSourceRepositories( writer, project );
+713 
+714         // bug-database
+715         writeBugDatabase( writer, project );
+716 
+717         // mailing list
+718         writeMailingList( writer, project );
+719 
+720         // download-page and download-mirror
+721         writeDownloadPage( writer, project );
+722 
+723         // screenshots
+724         writeScreenshots( writer, project );
+725 
+726         // service-endpoint
+727         writeServiceEndpoint( writer );
+728 
+729         // wiki
+730         writeWiki( writer, project );
+731 
+732         // Releases
+733         writeReleases( writer, project );
+734 
+735         // Developers
+736         @SuppressWarnings( "unchecked" )
+737         List<Contributor> developers = project.getDevelopers();
+738         writeContributors( writer, developers );
+739 
+740         // Contributors
+741         @SuppressWarnings( "unchecked" )
+742         List<Contributor> contributors = project.getContributors();
+743         writeContributors( writer, contributors );
+744 
+745         // Extra DOAP
+746         @SuppressWarnings( "unchecked" )
+747         Map<String, String> map = doapOptions.getExtra();
+748         writeExtra( writer, project, "Extra DOAP vocabulary.", map, doapOptions.getXmlnsPrefix() );
+749 
+750         // ASFext
+751         writeASFext( writer, project );
+752 
+753         // Extra extensions
+754         writeExtensions( writer );
+755 
+756         writer.endElement(); // Project
+757 
+758         writeOrganizations( writer );
+759 
+760         writer.endElement(); // rdf:RDF
+761 
+762         try
+763         {
+764             w.close();
+765         }
+766         catch ( IOException e )
+767         {
+768             throw new MojoExecutionException( "Error when closing the writer.", e );
+769         }
+770 
+771         if ( !messages.getWarnMessages().isEmpty() )
+772         {
+773             for ( String warn : messages.getWarnMessages() )
+774             {
+775                 getLog().warn( warn );
+776             }
+777         }
+778 
+779         if ( !messages.getErrorMessages().isEmpty() )
+780         {
+781             getLog().error( "" );
+782             for ( String error : messages.getErrorMessages() )
+783             {
+784                 getLog().error( error );
+785             }
+786             getLog().error( "" );
+787 
+788             if ( ASFExtOptionsUtil.isASFProject( project ) )
+789             {
+790                 getLog().error( "For more information about the errors and possible solutions, please read the plugin documentation:" );
+791                 getLog().error( "http://maven.apache.org/plugins/maven-doap-plugin/usage.html#DOAP_ASF_Configuration" );
+792                 throw new MojoExecutionException( "The generated DOAP doesn't respect ASF rules, see above." );
+793             }
+794         }
+795 
+796         if ( validate )
+797         {
+798             List<String> errors = DoapUtil.validate( outputFile );
+799             if ( !errors.isEmpty() )
+800             {
+801                 getLog().error( "" );
+802                 for ( String error : errors )
+803                 {
+804                     getLog().error( error );
+805                 }
+806                 getLog().error( "" );
+807 
+808                 throw new MojoExecutionException( "Error parsing the generated DOAP file, see above." );
+809             }
+810         }
+811     }
+812 
+813     /**
+814      * Write DOAP name.
+815      *
+816      * @param writer not null
+817      * @param project the Maven project, not null
+818      * @see <a href="http://usefulinc.com/ns/doap#name">http://usefulinc.com/ns/doap#name</a>
+819      */
+820     private void writeName( XMLWriter writer, MavenProject project )
+821     {
+822         String name = DoapUtil.interpolate( doapOptions.getName(), project, settings );
+823         if ( StringUtils.isEmpty( name ) )
+824         {
+825             messages.addMessage( new String[] { "doapOptions", "name" }, null,
+826                                  UserMessages.REQUIRED_BY_ASF_OR_RECOMMENDED );
+827             return;
+828         }
+829 
+830         DoapUtil.writeComment( writer, "A name of something." );
+831         if ( ASFExtOptionsUtil.isASFProject( project ) && !name.toLowerCase( Locale.ENGLISH ).startsWith( "apache" ) )
+832         {
+833             name = "Apache " + name;
+834         }
+835         DoapUtil.writeElement( writer, doapOptions.getXmlnsPrefix(), "name", name );
+836     }
+837 
+838     /**
+839      * Write DOAP description.
+840      *
+841      * @param writer not null
+842      * @param project the Maven project, not null
+843      * @see <a href="http://usefulinc.com/ns/doap#description">http://usefulinc.com/ns/doap#description</a>
+844      * @see <a href="http://usefulinc.com/ns/doap#shortdesc">http://usefulinc.com/ns/doap#shortdesc</a>
+845      */
+846     private void writeDescription( XMLWriter writer, MavenProject project )
+847     {
+848         boolean addComment = false;
+849         String description = DoapUtil.interpolate( doapOptions.getDescription(), project, settings );
+850         if ( StringUtils.isEmpty( description ) )
+851         {
+852             messages.addMessage( new String[] { "doapOptions", "description" }, null,
+853                                  UserMessages.REQUIRED_BY_ASF_OR_RECOMMENDED );
+854         }
+855         else
+856         {
+857             DoapUtil.writeComment( writer, "Plain text description of a project, of 2-4 sentences in length." );
+858             addComment = true;
+859             DoapUtil.writeElement( writer, doapOptions.getXmlnsPrefix(), "description", description, lang );
+860         }
+861 
+862         String comment = "Short plain text description of a project.";
+863         String shortdesc = DoapUtil.interpolate( doapOptions.getShortdesc(), project, settings );
+864         if ( StringUtils.isEmpty( shortdesc ) )
+865         {
+866             messages.addMessage( new String[] { "doapOptions", "shortdesc" }, null,
+867                                  UserMessages.REQUIRED_BY_ASF_OR_RECOMMENDED );
+868             return;
+869         }
+870         if ( description.equals( shortdesc ) )
+871         {
+872             // try to get the first 10 words of the description
+873             String sentence = StringUtils.split( shortdesc, "." )[0];
+874             if ( StringUtils.split( sentence, " " ).length > 10 )
+875             {
+876                 messages.addMessage( new String[] { "doapOptions", "shortdesc" }, null,
+877                                      UserMessages.REQUIRED_BY_ASF_OR_RECOMMENDED );
+878                 return;
+879             }
+880             if ( !addComment )
+881             {
+882                 DoapUtil.writeComment( writer, comment );
+883             }
+884             DoapUtil.writeElement( writer, doapOptions.getXmlnsPrefix(), "shortdesc", sentence, lang );
+885             return;
+886         }
+887         if ( !addComment )
+888         {
+889             DoapUtil.writeComment( writer, comment );

[... 1804 lines stripped ...]