You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by lt...@apache.org on 2009/05/06 20:29:47 UTC

svn commit: r772396 - in /maven/plugins/trunk/maven-pdf-plugin/src/main: java/org/apache/maven/plugins/pdf/PdfMojo.java resources/pdf-plugin.properties resources/pdf-plugin_fr.properties

Author: ltheussl
Date: Wed May  6 18:29:47 2009
New Revision: 772396

URL: http://svn.apache.org/viewvc?rev=772396&view=rev
Log:
Better default document descriptor

Modified:
    maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
    maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin.properties
    maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin_fr.properties

Modified: maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java?rev=772396&r1=772395&r2=772396&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java (original)
+++ maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java Wed May  6 18:29:47 2009
@@ -24,6 +24,7 @@
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.Writer;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -33,6 +34,7 @@
 
 import org.apache.maven.doxia.docrenderer.DocumentRenderer;
 import org.apache.maven.doxia.docrenderer.DocumentRendererException;
+import org.apache.maven.doxia.document.DocumentCover;
 import org.apache.maven.doxia.document.DocumentMeta;
 import org.apache.maven.doxia.document.DocumentModel;
 import org.apache.maven.doxia.document.DocumentTOC;
@@ -255,35 +257,34 @@
     private DocumentModel generateDefaultDocDescriptor()
         throws IOException, MojoExecutionException
     {
-        File outputDir = new File( project.getBuild().getDirectory(), "pdf" );
-
-        if ( outputDir.isFile() )
-        {
-            throw new IOException( outputDir + " is not a directory!" );
-        }
-
-        if ( !outputDir.exists() )
-        {
-            outputDir.mkdirs();
-        }
-
-        // TODO Improve metadata
         DocumentMeta meta = new DocumentMeta();
-        meta.setAuthor( getDocumentAuthor() );
-        meta.setTitle( getDocumentTitle() );
+        meta.setAuthor( getProjectOrganizationName() );
+        meta.setTitle( getProjectName() );
+        meta.setDescription( project.getDescription() );
+
+        DocumentCover cover = new DocumentCover();
+        cover.setCoverTitle( getProjectName() );
+        cover.setCoverVersion( project.getVersion() );
+        cover.setCoverType( getI18n().getString( "pdf-plugin", getDefaultLocale(), "toc.type" ) );
+        cover.setCoverDate( Integer.toString( Calendar.getInstance().get( Calendar.YEAR ) ) );
+        cover.setProjectName( getProjectName() );
+        cover.setCompanyName( getProjectOrganizationName() );
 
         DocumentModel docModel = new DocumentModel();
-        docModel.setModelEncoding( getModelEncoding() );
+        docModel.setModelEncoding( getProjectModelEncoding() );
         docModel.setOutputName( project.getArtifactId() );
         docModel.setMeta( meta );
+        docModel.setCover( cover );
 
-        // Populate docModel from defaultDecirationModel
+        // Populate docModel from defaultDecorationModel
         DecorationModel decorationModel = getDefaultDecorationModel();
+
         if ( decorationModel != null )
         {
             DocumentTOC toc = new DocumentTOC();
 
             toc.setName( getI18n().getString( "pdf-plugin", getDefaultLocale(), "toc.title" ) );
+
             for ( Iterator it = decorationModel.getMenus().iterator(); it.hasNext(); )
             {
                 Menu menu = (Menu) it.next();
@@ -304,6 +305,18 @@
 
         if ( getLog().isDebugEnabled() )
         {
+            File outputDir = new File( project.getBuild().getDirectory(), "pdf" );
+
+            if ( outputDir.isFile() )
+            {
+                throw new IOException( outputDir + " is not a directory!" );
+            }
+
+            if ( !outputDir.exists() )
+            {
+                outputDir.mkdirs();
+            }
+
             File doc = FileUtils.createTempFile( "pdf", ".xml", outputDir );
 
             getLog().debug( "Generated a default document model: " + doc.getAbsolutePath() );
@@ -324,7 +337,7 @@
         return docModel;
     }
 
-    private String getDocumentAuthor()
+    private String getProjectOrganizationName()
     {
         return ( project.getOrganization() != null
             && StringUtils.isNotEmpty( project.getOrganization().getName() )
@@ -332,14 +345,14 @@
                 : System.getProperty( "user.name" ) );
     }
 
-    private String getDocumentTitle()
+    private String getProjectName()
     {
         return ( StringUtils.isEmpty( project.getName() )
                 ? project.getGroupId() + ":" + project.getArtifactId()
                 : project.getName() );
     }
 
-    private String getModelEncoding()
+    private String getProjectModelEncoding()
     {
         return ( StringUtils.isEmpty( project.getModel().getModelEncoding() )
                 ? "UTF-8"
@@ -462,6 +475,7 @@
     static class ReflectionProperties
         extends Properties
     {
+        private static final long serialVersionUID = 1L;
         private MavenProject project;
 
         private Log log;

Modified: maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin.properties?rev=772396&r1=772395&r2=772396&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin.properties (original)
+++ maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin.properties Wed May  6 18:29:47 2009
@@ -16,3 +16,4 @@
 # under the License.
 
 toc.title = Table Of Content
+toc.type=Project Documentation

Modified: maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin_fr.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin_fr.properties?rev=772396&r1=772395&r2=772396&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin_fr.properties (original)
+++ maven/plugins/trunk/maven-pdf-plugin/src/main/resources/pdf-plugin_fr.properties Wed May  6 18:29:47 2009
@@ -15,4 +15,5 @@
 # specific language governing permissions and limitations
 # under the License.
 
-toc.title = Table des matières
+toc.title = Table des mati\u00E8res
+toc.type=Documentation