You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2023/02/01 20:55:23 UTC
[maven-pdf-plugin] 02/02: (doc) apply new formatting
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MPDF-108
in repository https://gitbox.apache.org/repos/asf/maven-pdf-plugin.git
commit 8cfa28f0b2c23324506eacf16fa7595da807f6f9
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Wed Feb 1 21:53:39 2023 +0100
(doc) apply new formatting
---
pom.xml | 57 +-
.../apache/maven/plugins/pdf/AbstractPdfMojo.java | 41 +-
.../org/apache/maven/plugins/pdf/DateBean.java | 162 ++--
.../plugins/pdf/DocumentDescriptorReader.java | 113 +--
.../maven/plugins/pdf/DocumentModelBuilder.java | 201 ++---
.../apache/maven/plugins/pdf/PdfAggregateMojo.java | 226 +++--
.../java/org/apache/maven/plugins/pdf/PdfMojo.java | 988 +++++++++------------
.../apache/maven/plugins/pdf/TocFileHelper.java | 52 +-
.../org/apache/maven/plugins/pdf/DateBeanTest.java | 48 +-
.../plugins/pdf/DocumentDescriptorReaderTest.java | 71 +-
.../plugins/pdf/DocumentModelBuilderTest.java | 117 +--
.../org/apache/maven/plugins/pdf/PdfMojoTest.java | 101 ++-
.../plugins/pdf/stubs/DefaultMavenProjectStub.java | 60 +-
.../pdf/stubs/FilteringMavenProjectStub.java | 70 +-
.../plugins/pdf/stubs/ITextMavenProjectStub.java | 58 +-
.../pdf/stubs/ModelBuilderMavenProjectStub.java | 85 +-
16 files changed, 1160 insertions(+), 1290 deletions(-)
diff --git a/pom.xml b/pom.xml
index 49ed522..473e674 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -18,7 +17,6 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -70,8 +68,8 @@ under the License.
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-pdf-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-pdf-plugin.git</developerConnection>
- <url>https://github.com/apache/maven-pdf-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/maven-pdf-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>JIRA</system>
@@ -201,8 +199,8 @@ under the License.
<version>${doxiaSitetoolsVersion}</version>
<exclusions>
<exclusion>
- <artifactId>plexus-container-default</artifactId>
<groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
@@ -307,7 +305,8 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <configuration> <!-- remove after MPOM-269 -->
+ <configuration>
+ <!-- remove after MPOM-269 -->
<tagletArtifacts combine.self="override" />
</configuration>
</plugin>
@@ -321,10 +320,10 @@ under the License.
<version>3.2.1</version>
<executions>
<execution>
+ <id>ensure-no-container-api</id>
<goals>
<goal>enforce</goal>
</goals>
- <id>ensure-no-container-api</id>
<configuration>
<rules>
<bannedDependencies>
@@ -340,17 +339,17 @@ under the License.
</execution>
</executions>
</plugin>
-<!-- START SNIPPET: configuration -->
+ <!-- START SNIPPET: configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<executions>
<execution>
<id>pdf</id>
- <phase>site</phase>
<goals>
<goal>pdf</goal>
</goals>
+ <phase>site</phase>
<configuration>
<outputDirectory>${project.reporting.outputDirectory}</outputDirectory>
<includeReports>false</includeReports>
@@ -358,7 +357,7 @@ under the License.
</execution>
</executions>
</plugin>
-<!-- END SNIPPET: configuration -->
+ <!-- END SNIPPET: configuration -->
</plugins>
</build>
@@ -408,6 +407,25 @@ under the License.
<name>pdf.skip</name>
</property>
</activation>
+
+ <build>
+ <defaultGoal>pdf:pdf</defaultGoal>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pdf-plugin</artifactId>
+ <version>${project.version}</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pdf-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<reporting>
<plugins>
<plugin>
@@ -429,25 +447,6 @@ under the License.
</plugin>
</plugins>
</reporting>
-
- <build>
- <defaultGoal>pdf:pdf</defaultGoal>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pdf-plugin</artifactId>
- <version>${project.version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pdf-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
</profile>
</profiles>
</project>
diff --git a/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo.java b/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo.java
index 152ed69..7920ad6 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -26,14 +44,14 @@ import org.apache.maven.plugin.AbstractMojo;
/**
* Common code to create pdf, either module pdf or reactor aggregate.
- *
+ *
* @since 1.5
*/
-public abstract class AbstractPdfMojo
- extends AbstractMojo
-{
+public abstract class AbstractPdfMojo extends AbstractMojo {
protected abstract File getOutputDirectory();
+
protected abstract File getWorkingDirectory();
+
protected abstract boolean isIncludeReports();
/**
@@ -43,26 +61,21 @@ public abstract class AbstractPdfMojo
*/
private File siteDirectoryTmp;
- protected abstract void prepareTempSiteDirectory( final File tmpSiteDir )
- throws IOException;
+ protected abstract void prepareTempSiteDirectory(File tmpSiteDir) throws IOException;
/**
* @return the default tmpSiteDirectory.
* @throws IOException if any
* @since 1.1
*/
- protected File getSiteDirectoryTmp()
- throws IOException
- {
- if ( this.siteDirectoryTmp == null )
- {
- final File tmpSiteDir = new File( getWorkingDirectory(), "site.tmp" );
- prepareTempSiteDirectory( tmpSiteDir );
+ protected File getSiteDirectoryTmp() throws IOException {
+ if (this.siteDirectoryTmp == null) {
+ final File tmpSiteDir = new File(getWorkingDirectory(), "site.tmp");
+ prepareTempSiteDirectory(tmpSiteDir);
this.siteDirectoryTmp = tmpSiteDir;
}
return this.siteDirectoryTmp;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/pdf/DateBean.java b/src/main/java/org/apache/maven/plugins/pdf/DateBean.java
index 68511ed..6700af5 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/DateBean.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/DateBean.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -20,7 +38,6 @@ package org.apache.maven.plugins.pdf;
*/
import java.text.SimpleDateFormat;
-
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
@@ -33,33 +50,31 @@ import java.util.TimeZone;
* </pre>
* @author ltheussl
*/
-public class DateBean
-{
- private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
-
- private static final SimpleDateFormat YEAR = new SimpleDateFormat( "yyyy", Locale.US );
- private static final SimpleDateFormat MONTH = new SimpleDateFormat( "MM", Locale.US );
- private static final SimpleDateFormat DAY = new SimpleDateFormat( "dd", Locale.US );
- private static final SimpleDateFormat HOUR = new SimpleDateFormat( "HH", Locale.US );
- private static final SimpleDateFormat MINUTE = new SimpleDateFormat( "mm", Locale.US );
- private static final SimpleDateFormat SECOND = new SimpleDateFormat( "ss", Locale.US );
- private static final SimpleDateFormat MILLI_SECOND = new SimpleDateFormat( "SSS", Locale.US );
- private static final SimpleDateFormat DATE = new SimpleDateFormat( "yyyy-MM-dd", Locale.US );
- private static final SimpleDateFormat TIME = new SimpleDateFormat( "HH:mm:ss'Z'", Locale.US );
- private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US );
-
- static
- {
- YEAR.setTimeZone( UTC_TIME_ZONE );
- MONTH.setTimeZone( UTC_TIME_ZONE );
- DAY.setTimeZone( UTC_TIME_ZONE );
- HOUR.setTimeZone( UTC_TIME_ZONE );
- MINUTE.setTimeZone( UTC_TIME_ZONE );
- SECOND.setTimeZone( UTC_TIME_ZONE );
- MILLI_SECOND.setTimeZone( UTC_TIME_ZONE );
- DATE.setTimeZone( UTC_TIME_ZONE );
- TIME.setTimeZone( UTC_TIME_ZONE );
- DATE_TIME.setTimeZone( UTC_TIME_ZONE );
+public class DateBean {
+ private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone("UTC");
+
+ private static final SimpleDateFormat YEAR = new SimpleDateFormat("yyyy", Locale.US);
+ private static final SimpleDateFormat MONTH = new SimpleDateFormat("MM", Locale.US);
+ private static final SimpleDateFormat DAY = new SimpleDateFormat("dd", Locale.US);
+ private static final SimpleDateFormat HOUR = new SimpleDateFormat("HH", Locale.US);
+ private static final SimpleDateFormat MINUTE = new SimpleDateFormat("mm", Locale.US);
+ private static final SimpleDateFormat SECOND = new SimpleDateFormat("ss", Locale.US);
+ private static final SimpleDateFormat MILLI_SECOND = new SimpleDateFormat("SSS", Locale.US);
+ private static final SimpleDateFormat DATE = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
+ private static final SimpleDateFormat TIME = new SimpleDateFormat("HH:mm:ss'Z'", Locale.US);
+ private static final SimpleDateFormat DATE_TIME = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
+
+ static {
+ YEAR.setTimeZone(UTC_TIME_ZONE);
+ MONTH.setTimeZone(UTC_TIME_ZONE);
+ DAY.setTimeZone(UTC_TIME_ZONE);
+ HOUR.setTimeZone(UTC_TIME_ZONE);
+ MINUTE.setTimeZone(UTC_TIME_ZONE);
+ SECOND.setTimeZone(UTC_TIME_ZONE);
+ MILLI_SECOND.setTimeZone(UTC_TIME_ZONE);
+ DATE.setTimeZone(UTC_TIME_ZONE);
+ TIME.setTimeZone(UTC_TIME_ZONE);
+ DATE_TIME.setTimeZone(UTC_TIME_ZONE);
}
private Date date;
@@ -67,9 +82,8 @@ public class DateBean
/**
* Construct a new DateBean for the current Date.
*/
- public DateBean()
- {
- this( new Date() );
+ public DateBean() {
+ this(new Date());
}
/**
@@ -77,8 +91,7 @@ public class DateBean
*
* @param date the date to set.
*/
- public DateBean( final Date date )
- {
+ public DateBean(final Date date) {
this.date = date;
}
@@ -87,118 +100,97 @@ public class DateBean
*
* @param date the date to set.
*/
- public void setDate( final Date date )
- {
+ public void setDate(final Date date) {
this.date = date;
}
/**
* @return the year in format "yyyy".
*/
- public String getYear()
- {
- synchronized ( this )
- {
- return YEAR.format( date );
+ public String getYear() {
+ synchronized (this) {
+ return YEAR.format(date);
}
}
/**
* @return the month in format "MM".
*/
- public String getMonth()
- {
- synchronized ( this )
- {
- return MONTH.format( date );
+ public String getMonth() {
+ synchronized (this) {
+ return MONTH.format(date);
}
}
/**
* @return the day in format "dd".
*/
- public String getDay()
- {
- synchronized ( this )
- {
- return DAY.format( date );
+ public String getDay() {
+ synchronized (this) {
+ return DAY.format(date);
}
}
/**
* @return the hour in format "HH".
*/
- public String getHour()
- {
- synchronized ( this )
- {
- return HOUR.format( date );
+ public String getHour() {
+ synchronized (this) {
+ return HOUR.format(date);
}
}
/**
* @return the minute in format "mm".
*/
- public String getMinute()
- {
- synchronized ( this )
- {
- return MINUTE.format( date );
+ public String getMinute() {
+ synchronized (this) {
+ return MINUTE.format(date);
}
}
/**
* @return the second in format "ss".
*/
- public String getSecond()
- {
- synchronized ( this )
- {
- return SECOND.format( date );
+ public String getSecond() {
+ synchronized (this) {
+ return SECOND.format(date);
}
}
/**
* @return the millisecond in format "SSS".
*/
- public String getMillisecond()
- {
- synchronized ( this )
- {
- return MILLI_SECOND.format( date );
+ public String getMillisecond() {
+ synchronized (this) {
+ return MILLI_SECOND.format(date);
}
}
/**
* @return the date using the ISO 8601 format, i.e. <code>yyyy-MM-dd</code>.
*/
- public String getDate()
- {
- synchronized ( this )
- {
- return DATE.format( date );
+ public String getDate() {
+ synchronized (this) {
+ return DATE.format(date);
}
}
/**
* @return the time using the ISO 8601 format and UTC time zone, i.e. <code>HH:mm:ss'Z'</code>.
*/
- public String getTime()
- {
- synchronized ( this )
- {
- return TIME.format( date );
+ public String getTime() {
+ synchronized (this) {
+ return TIME.format(date);
}
}
/**
* @return the datetime using the ISO 8601 format, i.e. <code>yyyy-MM-dd'T'HH:mm:ss'Z'</code>.
*/
- public String getDateTime()
- {
- synchronized ( this )
- {
- return DATE_TIME.format( date );
+ public String getDateTime() {
+ synchronized (this) {
+ return DATE_TIME.format(date);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java b/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java
index c893606..31602d9 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/DocumentDescriptorReader.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -23,12 +41,11 @@ import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
-
+import java.util.Locale;
import java.util.Properties;
import org.apache.maven.doxia.document.DocumentModel;
import org.apache.maven.doxia.document.io.xpp3.DocumentXpp3Reader;
-
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.io.FileUtils;
@@ -42,15 +59,13 @@ import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import java.util.Locale;
/**
* Read and filter a DocumentModel from a document descriptor file.
*
* @author ltheussl
*/
-public class DocumentDescriptorReader
-{
+public class DocumentDescriptorReader {
/** A MavenProject to extract additional info. */
private final MavenProject project;
@@ -62,9 +77,8 @@ public class DocumentDescriptorReader
/**
* Constructor.
*/
- public DocumentDescriptorReader()
- {
- this( null, null, null );
+ public DocumentDescriptorReader() {
+ this(null, null, null);
}
/**
@@ -72,9 +86,8 @@ public class DocumentDescriptorReader
*
* @param project may be null.
*/
- public DocumentDescriptorReader( final MavenProject project )
- {
- this( project, null, null );
+ public DocumentDescriptorReader(final MavenProject project) {
+ this(project, null, null);
}
/**
@@ -83,8 +96,7 @@ public class DocumentDescriptorReader
* @param project may be null.
* @param log may be null.
*/
- public DocumentDescriptorReader( final MavenProject project, final Log log, final Locale locale )
- {
+ public DocumentDescriptorReader(final MavenProject project, final Log log, final Locale locale) {
this.project = project;
this.log = log;
this.locale = locale;
@@ -98,73 +110,62 @@ public class DocumentDescriptorReader
* @throws XmlPullParserException if an error occurs during parsing.
* @throws IOException if an error occurs during reading.
*/
- public DocumentModel readAndFilterDocumentDescriptor( File docDescriptor )
- throws XmlPullParserException, IOException
- {
- if ( locale != null )
- {
+ public DocumentModel readAndFilterDocumentDescriptor(File docDescriptor)
+ throws XmlPullParserException, IOException {
+ if (locale != null) {
String descriptorFilename = docDescriptor.getName();
- String localized = FileUtils.removeExtension( descriptorFilename ) + '_' + locale.getLanguage() + '.'
- + FileUtils.getExtension( descriptorFilename );
- File localizedDocDescriptor = new File( docDescriptor.getParentFile(), localized );
-
- if ( localizedDocDescriptor.exists() )
- {
+ String localized = FileUtils.removeExtension(descriptorFilename)
+ + '_'
+ + locale.getLanguage()
+ + '.'
+ + FileUtils.getExtension(descriptorFilename);
+ File localizedDocDescriptor = new File(docDescriptor.getParentFile(), localized);
+
+ if (localizedDocDescriptor.exists()) {
docDescriptor = localizedDocDescriptor;
}
}
- try
- {
+ try {
// System properties
final Properties filterProperties = System.getProperties();
// Project properties
- if ( project != null && project.getProperties() != null )
- {
- filterProperties.putAll( project.getProperties() );
+ if (project != null && project.getProperties() != null) {
+ filterProperties.putAll(project.getProperties());
}
final Interpolator interpolator = new RegexBasedInterpolator();
- interpolator.addValueSource( new MapBasedValueSource( filterProperties ) );
- interpolator.addValueSource( new EnvarBasedValueSource() );
- interpolator.addValueSource( new ObjectBasedValueSource( project )
- {
+ interpolator.addValueSource(new MapBasedValueSource(filterProperties));
+ interpolator.addValueSource(new EnvarBasedValueSource());
+ interpolator.addValueSource(new ObjectBasedValueSource(project) {
/** {@inheritDoc} */
- public Object getValue( final String expression )
- {
- try
- {
- return ReflectionValueExtractor.evaluate( expression, project );
- }
- catch ( Exception e )
- {
- addFeedback( "Failed to extract '" + expression + "' from: " + project, e );
+ public Object getValue(final String expression) {
+ try {
+ return ReflectionValueExtractor.evaluate(expression, project);
+ } catch (Exception e) {
+ addFeedback("Failed to extract '" + expression + "' from: " + project, e);
}
return null;
}
- } );
+ });
final DateBean bean = new DateBean();
- interpolator.addValueSource( new ObjectBasedValueSource( bean ) );
+ interpolator.addValueSource(new ObjectBasedValueSource(bean));
- try ( Reader reader = ReaderFactory.newXmlReader( docDescriptor ) )
- {
- final String interpolatedDoc = interpolator.interpolate( IOUtil.toString( reader ) );
+ try (Reader reader = ReaderFactory.newXmlReader(docDescriptor)) {
+ final String interpolatedDoc = interpolator.interpolate(IOUtil.toString(reader));
- if ( log != null && log.isDebugEnabled() )
- {
- log.debug( "Interpolated document descriptor ("
- + docDescriptor.getAbsolutePath() + ")\n" + interpolatedDoc );
+ if (log != null && log.isDebugEnabled()) {
+ log.debug("Interpolated document descriptor (" + docDescriptor.getAbsolutePath() + ")\n"
+ + interpolatedDoc);
}
// No Strict
- return new DocumentXpp3Reader().read( new StringReader( interpolatedDoc ), false );
+ return new DocumentXpp3Reader().read(new StringReader(interpolatedDoc), false);
}
- }
- catch ( InterpolationException e )
- {
- throw new IOException( "Error interpolating document descriptor", e );
+ } catch (InterpolationException e) {
+ throw new IOException("Error interpolating document descriptor", e);
}
}
}
diff --git a/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java b/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
index 3e30f15..cd555b7 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/DocumentModelBuilder.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -24,6 +42,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import org.apache.commons.io.input.XmlStreamReader;
import org.apache.maven.doxia.document.DocumentAuthor;
import org.apache.maven.doxia.document.DocumentCover;
import org.apache.maven.doxia.document.DocumentMeta;
@@ -36,15 +55,13 @@ import org.apache.maven.doxia.site.decoration.MenuItem;
import org.apache.maven.model.Developer;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
-import org.apache.commons.io.input.XmlStreamReader;
/**
* Construct a DocumentModel from a MavenProject and related information.
*
* @author ltheussl
*/
-public class DocumentModelBuilder
-{
+public class DocumentModelBuilder {
/** A MavenProject to extract the information. */
private final MavenProject project;
@@ -56,9 +73,8 @@ public class DocumentModelBuilder
*
* @param project a MavenProject. May be null.
*/
- public DocumentModelBuilder( MavenProject project )
- {
- this( project, null );
+ public DocumentModelBuilder(MavenProject project) {
+ this(project, null);
}
/**
@@ -67,8 +83,7 @@ public class DocumentModelBuilder
* @param project a MavenProject. May be null.
* @param decorationModel a DecorationModel. May be null.
*/
- public DocumentModelBuilder( MavenProject project, DecorationModel decorationModel )
- {
+ public DocumentModelBuilder(MavenProject project, DecorationModel decorationModel) {
this.project = project;
this.decorationModel = decorationModel;
}
@@ -78,9 +93,8 @@ public class DocumentModelBuilder
*
* @return a DocumentModel. Always non-null.
*/
- public DocumentModel getDocumentModel()
- {
- return getDocumentModel( project, decorationModel, null );
+ public DocumentModel getDocumentModel() {
+ return getDocumentModel(project, decorationModel, null);
}
/**
@@ -89,9 +103,8 @@ public class DocumentModelBuilder
* @param date overrides the default date in meta- and cover information.
* @return a DocumentModel. Always non-null.
*/
- public DocumentModel getDocumentModel( Date date )
- {
- return getDocumentModel( project, decorationModel, date );
+ public DocumentModel getDocumentModel(Date date) {
+ return getDocumentModel(project, decorationModel, date);
}
/**
@@ -103,19 +116,17 @@ public class DocumentModelBuilder
*
* @return a DocumentModel. Always non-null.
*/
- private static DocumentModel getDocumentModel( MavenProject project,
- DecorationModel decorationModel, Date date )
- {
- final Date now = ( date == null ? new Date() : date );
+ private static DocumentModel getDocumentModel(MavenProject project, DecorationModel decorationModel, Date date) {
+ final Date now = (date == null ? new Date() : date);
final DocumentModel docModel = new DocumentModel();
- docModel.setModelEncoding( getProjectModelEncoding( project ) );
- docModel.setOutputName( project == null || project.getArtifactId() == null
- ? "unnamed" : project.getArtifactId() );
- docModel.setMeta( getDocumentMeta( project, now ) );
- docModel.setCover( getDocumentCover( project, now ) );
- docModel.setToc( getDocumentTOC( decorationModel ) );
+ docModel.setModelEncoding(getProjectModelEncoding(project));
+ docModel.setOutputName(
+ project == null || project.getArtifactId() == null ? "unnamed" : project.getArtifactId());
+ docModel.setMeta(getDocumentMeta(project, now));
+ docModel.setCover(getDocumentCover(project, now));
+ docModel.setToc(getDocumentTOC(decorationModel));
return docModel;
}
@@ -126,20 +137,16 @@ public class DocumentModelBuilder
* @param decorationModel a DecorationModel. May be null.
* @return a DocumentTOC, always non-null.
*/
- private static DocumentTOC getDocumentTOC( DecorationModel decorationModel )
- {
+ private static DocumentTOC getDocumentTOC(DecorationModel decorationModel) {
final DocumentTOC toc = new DocumentTOC();
- if ( decorationModel != null && decorationModel.getMenus() != null )
- {
- for ( final Menu menu : decorationModel.getMenus() )
- {
- for ( final MenuItem item : menu.getItems() )
- {
+ if (decorationModel != null && decorationModel.getMenus() != null) {
+ for (final Menu menu : decorationModel.getMenus()) {
+ for (final MenuItem item : menu.getItems()) {
final DocumentTOCItem documentTOCItem = new DocumentTOCItem();
- documentTOCItem.setName( item.getName() );
- documentTOCItem.setRef( item.getHref() );
- toc.addItem( documentTOCItem );
+ documentTOCItem.setName(item.getName());
+ documentTOCItem.setRef(item.getHref());
+ toc.addItem(documentTOCItem);
}
}
}
@@ -155,21 +162,20 @@ public class DocumentModelBuilder
*
* @return a DocumentMeta object. Always non-null.
*/
- private static DocumentMeta getDocumentMeta( MavenProject project, Date date )
- {
+ private static DocumentMeta getDocumentMeta(MavenProject project, Date date) {
final DocumentMeta meta = new DocumentMeta();
- meta.setAuthors( getAuthors( project ) );
- meta.setCreationDate( date );
- meta.setCreator( System.getProperty( "user.name" ) );
- meta.setDate( date );
- meta.setDescription( project == null ? null : project.getDescription() );
- //meta.setGenerator( generator );
- meta.setInitialCreator( System.getProperty( "user.name" ) );
- //meta.setLanguage( locale == null ? null : locale.getLanguage() );
- //meta.setPageSize( pageSize );
- meta.setSubject( getProjectName( project ) );
- meta.setTitle( getProjectName( project ) );
+ meta.setAuthors(getAuthors(project));
+ meta.setCreationDate(date);
+ meta.setCreator(System.getProperty("user.name"));
+ meta.setDate(date);
+ meta.setDescription(project == null ? null : project.getDescription());
+ // meta.setGenerator( generator );
+ meta.setInitialCreator(System.getProperty("user.name"));
+ // meta.setLanguage( locale == null ? null : locale.getLanguage() );
+ // meta.setPageSize( pageSize );
+ meta.setSubject(getProjectName(project));
+ meta.setTitle(getProjectName(project));
return meta;
}
@@ -182,20 +188,19 @@ public class DocumentModelBuilder
*
* @return a DocumentCover object. Always non-null.
*/
- private static DocumentCover getDocumentCover( MavenProject project, Date date )
- {
+ private static DocumentCover getDocumentCover(MavenProject project, Date date) {
final DocumentCover cover = new DocumentCover();
- cover.setAuthors( getAuthors( project ) );
- //cover.setCompanyLogo( companyLogo );
- cover.setCompanyName( getProjectOrganizationName( project ) );
- cover.setCoverDate( date );
- cover.setCoverSubTitle( project == null ? null : "v. " + project.getVersion() );
- cover.setCoverTitle( getProjectName( project ) );
- //cover.setCoverType( type );
- cover.setCoverVersion( project == null ? null : project.getVersion() );
- //cover.setProjectLogo( projectLogo );
- cover.setProjectName( getProjectName( project ) );
+ cover.setAuthors(getAuthors(project));
+ // cover.setCompanyLogo( companyLogo );
+ cover.setCompanyName(getProjectOrganizationName(project));
+ cover.setCoverDate(date);
+ cover.setCoverSubTitle(project == null ? null : "v. " + project.getVersion());
+ cover.setCoverTitle(getProjectName(project));
+ // cover.setCoverType( type );
+ cover.setCoverVersion(project == null ? null : project.getVersion());
+ // cover.setProjectLogo( projectLogo );
+ cover.setProjectName(getProjectName(project));
return cover;
}
@@ -207,41 +212,33 @@ public class DocumentModelBuilder
* @return a list of DocumentAuthors from the project developers.
* Returns null if project is null or contains no developers.
*/
- private static List<DocumentAuthor> getAuthors( MavenProject project )
- {
- if ( project == null || project.getDevelopers() == null )
- {
+ private static List<DocumentAuthor> getAuthors(MavenProject project) {
+ if (project == null || project.getDevelopers() == null) {
return null;
}
- final List<DocumentAuthor> ret = new ArrayList<>( 4 );
+ final List<DocumentAuthor> ret = new ArrayList<>(4);
- for ( Developer developer : project.getDevelopers() )
- {
+ for (Developer developer : project.getDevelopers()) {
final DocumentAuthor author = new DocumentAuthor();
- author.setName( developer.getName() );
- author.setEmail( developer.getEmail() );
- author.setCompanyName( developer.getOrganization() );
+ author.setName(developer.getName());
+ author.setEmail(developer.getEmail());
+ author.setCompanyName(developer.getOrganization());
StringBuilder roles = null;
- for ( final String role : developer.getRoles() )
- {
- if ( roles == null )
- {
- roles = new StringBuilder( 32 );
+ for (final String role : developer.getRoles()) {
+ if (roles == null) {
+ roles = new StringBuilder(32);
+ } else {
+ roles.append(',').append(' ');
}
- else
- {
- roles.append( ',' ).append( ' ' );
- }
- roles.append( role );
+ roles.append(role);
}
- if ( roles != null )
- {
- author.setPosition( roles.toString() );
+ if (roles != null) {
+ author.setPosition(roles.toString());
}
- ret.add( author );
+ ret.add(author);
}
return ret;
@@ -251,15 +248,14 @@ public class DocumentModelBuilder
* @param project the MavenProject to extract the project organization name from.
* @return the project organization name if not empty, or the current System user name otherwise.
*/
- private static String getProjectOrganizationName( MavenProject project )
- {
- if ( project != null && project.getOrganization() != null
- && StringUtils.isNotEmpty( project.getOrganization().getName() ) )
- {
+ private static String getProjectOrganizationName(MavenProject project) {
+ if (project != null
+ && project.getOrganization() != null
+ && StringUtils.isNotEmpty(project.getOrganization().getName())) {
return project.getOrganization().getName();
}
- return System.getProperty( "user.name" );
+ return System.getProperty("user.name");
}
/**
@@ -269,15 +265,12 @@ public class DocumentModelBuilder
* @return the project name, or the project groupId and artifactId if
* the project name is empty, or null if project is null.
*/
- private static String getProjectName( MavenProject project )
- {
- if ( project == null )
- {
+ private static String getProjectName(MavenProject project) {
+ if (project == null) {
return null;
}
- if ( StringUtils.isEmpty( project.getName() ) )
- {
+ if (StringUtils.isEmpty(project.getName())) {
return project.getGroupId() + ":" + project.getArtifactId();
}
@@ -290,27 +283,21 @@ public class DocumentModelBuilder
* @param project the MavenProject to extract the encoding name from.
* @return the project encoding if defined, or UTF-8 otherwise, or null if project is null.
*/
- private static String getProjectModelEncoding( MavenProject project )
- {
- if ( project == null )
- {
+ private static String getProjectModelEncoding(MavenProject project) {
+ if (project == null) {
return null;
}
String encoding = project.getModel().getModelEncoding();
// Workaround for MNG-4289
- try ( XmlStreamReader reader = new XmlStreamReader( project.getFile() ) )
- {
+ try (XmlStreamReader reader = new XmlStreamReader(project.getFile())) {
encoding = reader.getEncoding();
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
// nop
}
- if ( StringUtils.isEmpty( encoding ) )
- {
+ if (StringUtils.isEmpty(encoding)) {
return "UTF-8";
}
diff --git a/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java b/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
index 7576320..ca4f68e 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -19,17 +37,6 @@ package org.apache.maven.plugins.pdf;
* under the License.
*/
-import org.apache.maven.doxia.document.DocumentModel;
-import org.apache.maven.doxia.document.DocumentTOC;
-import org.apache.maven.doxia.document.DocumentTOCItem;
-import org.apache.maven.model.Reporting;
-import org.apache.maven.plugins.annotations.Execute;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.FileUtils;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
@@ -41,216 +48,195 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.apache.maven.doxia.document.DocumentModel;
+import org.apache.maven.doxia.document.DocumentTOC;
+import org.apache.maven.doxia.document.DocumentTOCItem;
+import org.apache.maven.model.Reporting;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
+
/**
* Forks {@code pdf} goal then aggregates PDF content from all modules in the reactor.
*
* @author anthony-beurive
* @since 1.5
*/
-@Mojo( name = "aggregate", aggregator = true, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
-@Execute( goal = "pdf" )
+@Mojo(name = "aggregate", aggregator = true, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
+@Execute(goal = "pdf")
// TODO should extend AbstractPdfMojo, but requires extensive refactoring
-public class PdfAggregateMojo extends PdfMojo
-{
+public class PdfAggregateMojo extends PdfMojo {
/**
* The reactor projects.
*/
- @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true )
+ @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true)
private List<MavenProject> reactorProjects;
/**
* Output directory where aggregated PDF files should be created.
*/
- @Parameter( defaultValue = "${project.build.directory}/pdf-aggregate", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/pdf-aggregate", required = true)
private File aggregatedOutputDirectory;
/**
* Working directory for aggregated working files like temp files/resources.
*/
- @Parameter( defaultValue = "${project.build.directory}/pdf-aggregate", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/pdf-aggregate", required = true)
private File aggregatedWorkingDirectory;
- protected File getOutputDirectory()
- {
+ protected File getOutputDirectory() {
return aggregatedOutputDirectory;
}
- protected File getWorkingDirectory()
- {
+ protected File getWorkingDirectory() {
return aggregatedWorkingDirectory;
}
- protected boolean isIncludeReports()
- {
+ protected boolean isIncludeReports() {
return false; // reports were generate (or not) during pdf:pdf: here, we only aggregate
}
- protected void prepareTempSiteDirectory( final File tmpSiteDir )
- {
+ protected void prepareTempSiteDirectory(final File tmpSiteDir) {
tmpSiteDir.mkdirs();
}
@Override
- protected void appendGeneratedReports( DocumentModel model, Locale locale )
- {
- super.appendGeneratedReports( model, locale );
+ protected void appendGeneratedReports(DocumentModel model, Locale locale) {
+ super.appendGeneratedReports(model, locale);
- getLog().info( "Appending staged reports." );
+ getLog().info("Appending staged reports.");
DocumentTOC toc = model.getToc();
File dstSiteTmp = null;
- try
- {
+ try {
dstSiteTmp = getSiteDirectoryTmp();
+ } catch (IOException ioe) {
+ getLog().error("unexpected IOException while getting aggregator root tmp site dir", ioe);
}
- catch ( IOException ioe )
- {
- getLog().error( "unexpected IOException while getting aggregator root tmp site dir", ioe );
- }
- if ( !dstSiteTmp.exists() )
- {
- getLog().error( "Top-level project does not have src.tmp directory" );
+ if (!dstSiteTmp.exists()) {
+ getLog().error("Top-level project does not have src.tmp directory");
return;
}
- for ( MavenProject reactorProject : reactorProjects )
- {
- getLog().info( "Appending " + reactorProject.getArtifactId() + " reports." );
+ for (MavenProject reactorProject : reactorProjects) {
+ getLog().info("Appending " + reactorProject.getArtifactId() + " reports.");
- copySiteDirectoryTmp( reactorProject, dstSiteTmp );
+ copySiteDirectoryTmp(reactorProject, dstSiteTmp);
- addTOCItems( toc, reactorProject );
+ addTOCItems(toc, reactorProject);
}
}
- private void copySiteDirectoryTmp( MavenProject project, File dstSiteTmp )
- {
+ private void copySiteDirectoryTmp(MavenProject project, File dstSiteTmp) {
Reporting reporting = project.getReporting();
- if ( reporting == null )
- {
- getLog().info( "Skipping reactor project " + project + ": no reporting" );
+ if (reporting == null) {
+ getLog().info("Skipping reactor project " + project + ": no reporting");
return;
}
- File srcSiteTmp = getModuleSiteDirectoryTmp( project );
- if ( !srcSiteTmp.exists() )
- {
- getLog().info( "Skipping reactor project " + project + ": no site.tmp directory" );
+ File srcSiteTmp = getModuleSiteDirectoryTmp(project);
+ if (!srcSiteTmp.exists()) {
+ getLog().info("Skipping reactor project " + project + ": no site.tmp directory");
return;
}
- String stagedId = getStagedId( project );
+ String stagedId = getStagedId(project);
- try
- {
+ try {
String defaultExcludes = FileUtils.getDefaultExcludesAsString();
- List<String> srcDirNames = FileUtils.getDirectoryNames( srcSiteTmp, "*", defaultExcludes, false );
- for ( String srcDirName : srcDirNames )
- {
- File srcDir = new File( srcSiteTmp, srcDirName );
- File dstDir = new File( new File( dstSiteTmp, srcDirName ), stagedId );
- if ( !dstDir.exists() && !dstDir.mkdirs() )
- {
- getLog().error( "Could not create directory: " + dstDir );
+ List<String> srcDirNames = FileUtils.getDirectoryNames(srcSiteTmp, "*", defaultExcludes, false);
+ for (String srcDirName : srcDirNames) {
+ File srcDir = new File(srcSiteTmp, srcDirName);
+ File dstDir = new File(new File(dstSiteTmp, srcDirName), stagedId);
+ if (!dstDir.exists() && !dstDir.mkdirs()) {
+ getLog().error("Could not create directory: " + dstDir);
return;
}
- FileUtils.copyDirectoryStructure( srcDir, dstDir );
+ FileUtils.copyDirectoryStructure(srcDir, dstDir);
}
- }
- catch ( IOException e )
- {
- getLog().error( "Error while copying sub-project " + project.getArtifactId()
- + " site.tmp: " + e.getMessage(), e );
+ } catch (IOException e) {
+ getLog().error(
+ "Error while copying sub-project " + project.getArtifactId() + " site.tmp: "
+ + e.getMessage(),
+ e);
}
}
- private void addTOCItems( DocumentTOC topLevelToc, MavenProject project )
- {
- String stagedId = getStagedId( project );
+ private void addTOCItems(DocumentTOC topLevelToc, MavenProject project) {
+ String stagedId = getStagedId(project);
- Map<String, Object> toc = loadToc( project );
+ Map<String, Object> toc = loadToc(project);
- List<Map<String, Object>> items = (ArrayList) toc.get( "items" );
+ List<Map<String, Object>> items = (ArrayList) toc.get("items");
DocumentTOCItem tocItem = new DocumentTOCItem();
- tocItem.setName( project.getName() );
- tocItem.setRef( stagedId );
+ tocItem.setName(project.getName());
+ tocItem.setRef(stagedId);
- if ( items.size() == 1 && "project-info".equals( items.get( 0 ).get( "ref" ) ) )
- {
+ if (items.size() == 1 && "project-info".equals(items.get(0).get("ref"))) {
// Special case where a sub-project only contains generated reports.
- items = (List) items.get( 0 ).get( "items" );
+ items = (List) items.get(0).get("items");
}
- for ( Map<String, Object> item : items )
- {
- addTOCItems( tocItem, item, stagedId );
+ for (Map<String, Object> item : items) {
+ addTOCItems(tocItem, item, stagedId);
}
- topLevelToc.addItem( tocItem );
+ topLevelToc.addItem(tocItem);
}
- private Map<String, Object> loadToc( MavenProject project )
- {
- try
- {
- return TocFileHelper.loadToc( getModuleWorkingDirectory( project ) );
- }
- catch ( IOException e )
- {
- getLog().error( "Error while reading table of contents of module " + project.getArtifactId(), e );
+ private Map<String, Object> loadToc(MavenProject project) {
+ try {
+ return TocFileHelper.loadToc(getModuleWorkingDirectory(project));
+ } catch (IOException e) {
+ getLog().error("Error while reading table of contents of module " + project.getArtifactId(), e);
return Collections.emptyMap();
}
}
- private void addTOCItems( DocumentTOCItem parent, Map<String, Object> item, String stagedId )
- {
+ private void addTOCItems(DocumentTOCItem parent, Map<String, Object> item, String stagedId) {
DocumentTOCItem tocItem = new DocumentTOCItem();
- tocItem.setName( (String) item.get( "name" ) );
- tocItem.setRef( stagedId + "/" + item.get( "ref" ) );
+ tocItem.setName((String) item.get("name"));
+ tocItem.setRef(stagedId + "/" + item.get("ref"));
- List<Map<String, Object>> items = (List) item.get( "items" );
+ List<Map<String, Object>> items = (List) item.get("items");
- for ( Map<String, Object> it : items )
- {
- addTOCItems( tocItem, it, stagedId );
+ for (Map<String, Object> it : items) {
+ addTOCItems(tocItem, it, stagedId);
}
- parent.addItem( tocItem );
+ parent.addItem(tocItem);
}
- private String getStagedId( MavenProject p )
- {
+ private String getStagedId(MavenProject p) {
Deque<String> projectPath = new ArrayDeque<>();
- projectPath.addFirst( p.getArtifactId() );
- while ( p.getParent() != null )
- {
+ projectPath.addFirst(p.getArtifactId());
+ while (p.getParent() != null) {
p = p.getParent();
- projectPath.addFirst( p.getArtifactId() );
+ projectPath.addFirst(p.getArtifactId());
}
StringBuilder stagedId = new StringBuilder();
Iterator<String> artifactIds = projectPath.iterator();
- while ( artifactIds.hasNext() )
- {
- stagedId.append( artifactIds.next() );
- if ( artifactIds.hasNext() )
- {
- stagedId.append( '/' );
+ while (artifactIds.hasNext()) {
+ stagedId.append(artifactIds.next());
+ if (artifactIds.hasNext()) {
+ stagedId.append('/');
}
}
return stagedId.toString();
}
- private File getModuleWorkingDirectory( MavenProject project )
- {
- return new File( project.getBuild().getDirectory(), "pdf" );
+ private File getModuleWorkingDirectory(MavenProject project) {
+ return new File(project.getBuild().getDirectory(), "pdf");
}
- private File getModuleSiteDirectoryTmp( MavenProject project )
- {
- return new File( getModuleWorkingDirectory( project ), "site.tmp" );
+ private File getModuleSiteDirectoryTmp(MavenProject project) {
+ return new File(getModuleWorkingDirectory(project), "site.tmp");
}
}
diff --git a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
index d116982..7ea41d1 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -93,20 +111,18 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
*
* @author ltheussl
*/
-@Mojo( name = "pdf", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
-public class PdfMojo
- extends AbstractPdfMojo implements Contextualizable
-{
+@Mojo(name = "pdf", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
+public class PdfMojo extends AbstractPdfMojo implements Contextualizable {
/**
* The vm line separator
*/
- private static final String EOL = System.getProperty( "line.separator" );
+ private static final String EOL = System.getProperty("line.separator");
/**
* FO Document Renderer.
*/
- @Component( hint = "fo" )
+ @Component(hint = "fo")
private PdfRenderer foRenderer;
/**
@@ -118,14 +134,14 @@ public class PdfMojo
/**
* IText Document Renderer.
*/
- @Component( hint = "itext" )
+ @Component(hint = "itext")
private PdfRenderer itextRenderer;
/**
* A comma separated list of locales supported by Maven.
* The first valid token will be the default Locale for this instance of the Java Virtual Machine.
*/
- @Parameter( property = "locales" )
+ @Parameter(property = "locales")
private String locales;
/**
@@ -151,7 +167,7 @@ public class PdfMojo
/**
* The Maven Project Object.
*/
- @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;
/**
@@ -159,7 +175,7 @@ public class PdfMojo
*
* @since 1.1
*/
- @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+ @Parameter(defaultValue = "${settings}", readonly = true, required = true)
private Settings settings;
/**
@@ -167,13 +183,13 @@ public class PdfMojo
*
* @since 1.1
*/
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
private MavenSession session;
/**
* Directory containing source for apt, fml and xdoc docs.
*/
- @Parameter( defaultValue = "${basedir}/src/site", required = true )
+ @Parameter(defaultValue = "${basedir}/src/site", required = true)
private File siteDirectory;
/**
@@ -181,37 +197,37 @@ public class PdfMojo
*
* @since 1.1
*/
- @Parameter( defaultValue = "${project.build.directory}/generated-site", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/generated-site", required = true)
private File generatedSiteDirectory;
/**
* Output directory where PDF files should be created.
*/
- @Parameter( defaultValue = "${project.build.directory}/pdf", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/pdf", required = true)
private File outputDirectory;
/**
* Working directory for working files like temp files/resources.
*/
- @Parameter( defaultValue = "${project.build.directory}/pdf", required = true )
+ @Parameter(defaultValue = "${project.build.directory}/pdf", required = true)
private File workingDirectory;
/**
* File that contains the DocumentModel of the PDF to generate.
*/
- @Parameter( defaultValue = "src/site/pdf.xml" )
+ @Parameter(defaultValue = "src/site/pdf.xml")
private File docDescriptor;
/**
* Identifies the framework to use for pdf generation: either "fo" (default) or "itext".
*/
- @Parameter( property = "implementation", defaultValue = "fo", required = true )
+ @Parameter(property = "implementation", defaultValue = "fo", required = true)
private String implementation;
/**
* The local repository.
*/
- @Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
+ @Parameter(defaultValue = "${localRepository}", required = true, readonly = true)
private ArtifactRepository localRepository;
/**
@@ -219,20 +235,20 @@ public class PdfMojo
*
* @since 1.1
*/
- @Parameter( defaultValue = "${project.remoteArtifactRepositories}" )
+ @Parameter(defaultValue = "${project.remoteArtifactRepositories}")
private List<ArtifactRepository> remoteRepositories;
/**
* If <code>true</false>, aggregate all source documents in one pdf, otherwise generate one pdf for each
* source document.
*/
- @Parameter( property = "aggregate", defaultValue = "true" )
+ @Parameter(property = "aggregate", defaultValue = "true")
private boolean aggregate;
/**
* The current version of this plugin.
*/
- @Parameter( defaultValue = "${plugin.version}", readonly = true )
+ @Parameter(defaultValue = "${plugin.version}", readonly = true)
private String pluginVersion;
/**
@@ -242,7 +258,7 @@ public class PdfMojo
*
* @since 1.1
*/
- @Parameter( property = "includeReports", defaultValue = "true" )
+ @Parameter(property = "includeReports", defaultValue = "true")
private boolean includeReports;
/**
@@ -252,7 +268,7 @@ public class PdfMojo
*
* @since 1.1
*/
- @Parameter( property = "generateTOC", defaultValue = "start" )
+ @Parameter(property = "generateTOC", defaultValue = "start")
private String generateTOC;
/**
@@ -263,7 +279,7 @@ public class PdfMojo
*
* @since 1.2
*/
- @Parameter( property = "validate", defaultValue = "false" )
+ @Parameter(property = "validate", defaultValue = "false")
private boolean validate;
/**
@@ -271,7 +287,7 @@ public class PdfMojo
*
* @since 1.3
*/
- @Parameter( defaultValue = "${reports}", required = true, readonly = true )
+ @Parameter(defaultValue = "${reports}", required = true, readonly = true)
private MavenReport[] reports;
/**
@@ -279,7 +295,7 @@ public class PdfMojo
*
* @since 1.5
*/
- @Parameter( defaultValue = "${project.reporting}", readonly = true )
+ @Parameter(defaultValue = "${project.reporting}", readonly = true)
private Reporting reporting;
/**
@@ -323,80 +339,59 @@ public class PdfMojo
private PlexusContainer container;
/** {@inheritDoc} */
- public void execute()
- throws MojoExecutionException
- {
+ public void execute() throws MojoExecutionException {
init();
- try
- {
+ try {
generatePdf();
- }
- catch ( IOException e )
- {
- debugLogGeneratedModel( getDocumentModel( Locale.ENGLISH ) );
+ } catch (IOException e) {
+ debugLogGeneratedModel(getDocumentModel(Locale.ENGLISH));
- throw new MojoExecutionException( "Error during document generation: " + e.getMessage(), e );
+ throw new MojoExecutionException("Error during document generation: " + e.getMessage(), e);
}
- try
- {
+ try {
copyGeneratedPdf();
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error copying generated PDF: " + e.getMessage(), e );
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error copying generated PDF: " + e.getMessage(), e);
}
}
/** {@inheritDoc} */
- public void contextualize( Context context )
- throws ContextException
- {
- container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ public void contextualize(Context context) throws ContextException {
+ container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
}
- protected File getOutputDirectory()
- {
+ protected File getOutputDirectory() {
return outputDirectory;
}
- protected File getWorkingDirectory()
- {
+ protected File getWorkingDirectory() {
return workingDirectory;
}
- protected boolean isIncludeReports()
- {
+ protected boolean isIncludeReports() {
return includeReports;
}
/**
* Init and validate parameters
*/
- private void init()
- {
- if ( "fo".equalsIgnoreCase( implementation ) )
- {
+ private void init() {
+ if ("fo".equalsIgnoreCase(implementation)) {
this.docRenderer = foRenderer;
- }
- else if ( "itext".equalsIgnoreCase( implementation ) )
- {
+ } else if ("itext".equalsIgnoreCase(implementation)) {
this.docRenderer = itextRenderer;
- }
- else
- {
- getLog().warn( "Invalid 'implementation' parameter: '" + implementation
- + "', using 'fo' as default." );
+ } else {
+ getLog().warn("Invalid 'implementation' parameter: '" + implementation + "', using 'fo' as default.");
this.docRenderer = foRenderer;
}
- if ( !( "none".equalsIgnoreCase( generateTOC )
- || "start".equalsIgnoreCase( generateTOC ) || "end".equalsIgnoreCase( generateTOC ) ) )
- {
- getLog().warn( "Invalid 'generateTOC' parameter: '" + generateTOC
- + "', using 'start' as default." );
+ if (!("none".equalsIgnoreCase(generateTOC)
+ || "start".equalsIgnoreCase(generateTOC)
+ || "end".equalsIgnoreCase(generateTOC))) {
+ getLog().warn("Invalid 'generateTOC' parameter: '" + generateTOC + "', using 'start' as default.");
this.generateTOC = "start";
}
@@ -409,37 +404,32 @@ public class PdfMojo
* @throws IOException if any
* @since 1.1
*/
- private void copyGeneratedPdf()
- throws MojoExecutionException, IOException
- {
- boolean requireCopy =
- !getOutputDirectory().getCanonicalPath().equals( getWorkingDirectory().getCanonicalPath() );
-
- String outputName = getDocumentModel( getDefaultLocale() ).getOutputName().trim();
- if ( !outputName.endsWith( ".pdf" ) )
- {
- outputName = outputName.concat( ".pdf" );
+ private void copyGeneratedPdf() throws MojoExecutionException, IOException {
+ boolean requireCopy = !getOutputDirectory()
+ .getCanonicalPath()
+ .equals(getWorkingDirectory().getCanonicalPath());
+
+ String outputName = getDocumentModel(getDefaultLocale()).getOutputName().trim();
+ if (!outputName.endsWith(".pdf")) {
+ outputName = outputName.concat(".pdf");
}
- for ( final Locale locale : getAvailableLocales() )
- {
- File generatedPdfSource = new File( getLocaleDirectory( getWorkingDirectory(), locale ), outputName );
+ for (final Locale locale : getAvailableLocales()) {
+ File generatedPdfSource = new File(getLocaleDirectory(getWorkingDirectory(), locale), outputName);
- if ( !generatedPdfSource.exists() )
- {
- getLog().warn( "Unable to find the generated pdf: " + generatedPdfSource.getAbsolutePath() );
+ if (!generatedPdfSource.exists()) {
+ getLog().warn("Unable to find the generated pdf: " + generatedPdfSource.getAbsolutePath());
continue;
}
- File generatedPdfDest = new File( getLocaleDirectory( getOutputDirectory(), locale ), outputName );
+ File generatedPdfDest = new File(getLocaleDirectory(getOutputDirectory(), locale), outputName);
- if ( requireCopy )
- {
- FileUtils.copyFile( generatedPdfSource, generatedPdfDest );
+ if (requireCopy) {
+ FileUtils.copyFile(generatedPdfSource, generatedPdfDest);
generatedPdfSource.delete();
}
- getLog().info( "pdf generated: " + generatedPdfDest );
+ getLog().info("pdf generated: " + generatedPdfDest);
}
}
@@ -450,49 +440,42 @@ public class PdfMojo
* @throws IOException if any
* @since 1.1
*/
- private void generatePdf()
- throws MojoExecutionException, IOException
- {
- Locale.setDefault( getDefaultLocale() );
+ private void generatePdf() throws MojoExecutionException, IOException {
+ Locale.setDefault(getDefaultLocale());
- for ( final Locale locale : getAvailableLocales() )
- {
- final File workingDir = getLocaleDirectory( getWorkingDirectory(), locale );
+ for (final Locale locale : getAvailableLocales()) {
+ final File workingDir = getLocaleDirectory(getWorkingDirectory(), locale);
- File siteDirectoryFile = getLocaleDirectory( getSiteDirectoryTmp(), locale );
+ File siteDirectoryFile = getLocaleDirectory(getSiteDirectoryTmp(), locale);
- copyResources( locale );
+ copyResources(locale);
// generated xdoc sources for reports
- generateMavenReports( locale );
+ generateMavenReports(locale);
// render all Doxia source files to pdf (were handwritten or generated by reports)
DocumentRendererContext context = new DocumentRendererContext();
- context.put( "project", project );
- context.put( "settings", settings );
- context.put( "PathTool", new PathTool() );
- context.put( "FileUtils", new FileUtils() );
- context.put( "StringUtils", new StringUtils() );
- context.put( "i18n", i18n );
- context.put( "generateTOC", generateTOC );
- context.put( "validate", validate );
+ context.put("project", project);
+ context.put("settings", settings);
+ context.put("PathTool", new PathTool());
+ context.put("FileUtils", new FileUtils());
+ context.put("StringUtils", new StringUtils());
+ context.put("i18n", i18n);
+ context.put("generateTOC", generateTOC);
+ context.put("validate", validate);
// Put any of the properties in directly into the Velocity context
- for ( Map.Entry<Object, Object> entry : project.getProperties().entrySet() )
- {
- context.put( (String) entry.getKey(), entry.getValue() );
+ for (Map.Entry<Object, Object> entry : project.getProperties().entrySet()) {
+ context.put((String) entry.getKey(), entry.getValue());
}
- final DocumentModel model = aggregate ? getDocumentModel( locale ) : null;
+ final DocumentModel model = aggregate ? getDocumentModel(locale) : null;
- try
- {
+ try {
// TODO use interface see DOXIASITETOOLS-30
- ( (AbstractDocumentRenderer) docRenderer ).render( siteDirectoryFile, workingDir, model, context );
- }
- catch ( DocumentRendererException e )
- {
- throw new MojoExecutionException( "Error during document generation: " + e.getMessage(), e );
+ ((AbstractDocumentRenderer) docRenderer).render(siteDirectoryFile, workingDir, model, context);
+ } catch (DocumentRendererException e) {
+ throw new MojoExecutionException("Error during document generation: " + e.getMessage(), e);
}
}
}
@@ -501,11 +484,9 @@ public class PdfMojo
* @return the default tmpGeneratedSiteDirectory when report will be created.
* @since 1.1
*/
- private File getGeneratedSiteDirectoryTmp()
- {
- if ( this.generatedSiteDirectoryTmp == null )
- {
- this.generatedSiteDirectoryTmp = new File( getWorkingDirectory(), "generated-site.tmp" );
+ private File getGeneratedSiteDirectoryTmp() {
+ if (this.generatedSiteDirectoryTmp == null) {
+ this.generatedSiteDirectoryTmp = new File(getWorkingDirectory(), "generated-site.tmp");
}
return this.generatedSiteDirectoryTmp;
@@ -521,37 +502,29 @@ public class PdfMojo
* @throws IOException if any
* @since 1.1
*/
- protected void prepareTempSiteDirectory( final File tmpSiteDir )
- throws IOException
- {
+ protected void prepareTempSiteDirectory(final File tmpSiteDir) throws IOException {
// safety
tmpSiteDir.mkdirs();
// copy site
- if ( siteDirectory.exists() )
- {
- FileUtils.copyDirectoryStructure( siteDirectory, tmpSiteDir );
+ if (siteDirectory.exists()) {
+ FileUtils.copyDirectoryStructure(siteDirectory, tmpSiteDir);
}
// Remove SCM files
- List<String> files =
- FileUtils.getFileAndDirectoryNames( tmpSiteDir, FileUtils.getDefaultExcludesAsString(), null, true,
- true, true, true );
- for ( final String fileName : files )
- {
- final File file = new File( fileName );
-
- if ( file.isDirectory() )
- {
- FileUtils.deleteDirectory( file );
- }
- else
- {
+ List<String> files = FileUtils.getFileAndDirectoryNames(
+ tmpSiteDir, FileUtils.getDefaultExcludesAsString(), null, true, true, true, true);
+ for (final String fileName : files) {
+ final File file = new File(fileName);
+
+ if (file.isDirectory()) {
+ FileUtils.deleteDirectory(file);
+ } else {
file.delete();
}
}
- copySiteDir( generatedSiteDirectory, tmpSiteDir );
+ copySiteDir(generatedSiteDirectory, tmpSiteDir);
}
/**
@@ -562,59 +535,47 @@ public class PdfMojo
* @throws IOException if any
* @since 1.1
*/
- private void copySiteDir( final File from, final File to )
- throws IOException
- {
- if ( from == null || !from.exists() )
- {
+ private void copySiteDir(final File from, final File to) throws IOException {
+ if (from == null || !from.exists()) {
return;
}
// copy generated-site
- for ( final Locale locale : getAvailableLocales() )
- {
- String excludes = getDefaultExcludesWithLocales( getAvailableLocales(), getDefaultLocale() );
- List<String> siteFiles =
- siteDirectory.exists() ? FileUtils.getFileNames( siteDirectory, "**/*", excludes, false )
- : new ArrayList<>();
- File siteDirectoryLocale = new File( siteDirectory, locale.getLanguage() );
- if ( !locale.getLanguage().equals( getDefaultLocale().getLanguage() ) && siteDirectoryLocale.exists() )
- {
- siteFiles = FileUtils.getFileNames( siteDirectoryLocale, "**/*", excludes, false );
+ for (final Locale locale : getAvailableLocales()) {
+ String excludes = getDefaultExcludesWithLocales(getAvailableLocales(), getDefaultLocale());
+ List<String> siteFiles = siteDirectory.exists()
+ ? FileUtils.getFileNames(siteDirectory, "**/*", excludes, false)
+ : new ArrayList<>();
+ File siteDirectoryLocale = new File(siteDirectory, locale.getLanguage());
+ if (!locale.getLanguage().equals(getDefaultLocale().getLanguage()) && siteDirectoryLocale.exists()) {
+ siteFiles = FileUtils.getFileNames(siteDirectoryLocale, "**/*", excludes, false);
}
- List<String> generatedSiteFiles = FileUtils.getFileNames( from, "**/*", excludes, false );
- File fromLocale = new File( from, locale.getLanguage() );
- if ( !locale.getLanguage().equals( getDefaultLocale().getLanguage() ) && fromLocale.exists() )
- {
- generatedSiteFiles = FileUtils.getFileNames( fromLocale, "**/*", excludes, false );
+ List<String> generatedSiteFiles = FileUtils.getFileNames(from, "**/*", excludes, false);
+ File fromLocale = new File(from, locale.getLanguage());
+ if (!locale.getLanguage().equals(getDefaultLocale().getLanguage()) && fromLocale.exists()) {
+ generatedSiteFiles = FileUtils.getFileNames(fromLocale, "**/*", excludes, false);
}
- for ( final String generatedSiteFile : generatedSiteFiles )
- {
- if ( siteFiles.contains( generatedSiteFile ) )
- {
- getLog().warn( "Generated-site already contains a file in site: " + generatedSiteFile
- + ". Ignoring copying it!" );
+ for (final String generatedSiteFile : generatedSiteFiles) {
+ if (siteFiles.contains(generatedSiteFile)) {
+ getLog().warn("Generated-site already contains a file in site: " + generatedSiteFile
+ + ". Ignoring copying it!");
continue;
}
- if ( !locale.getLanguage().equals( getDefaultLocale().getLanguage() ) )
- {
- if ( fromLocale.exists() )
- {
- File in = new File( fromLocale, generatedSiteFile );
- File out = new File( new File( to, locale.getLanguage() ), generatedSiteFile );
+ if (!locale.getLanguage().equals(getDefaultLocale().getLanguage())) {
+ if (fromLocale.exists()) {
+ File in = new File(fromLocale, generatedSiteFile);
+ File out = new File(new File(to, locale.getLanguage()), generatedSiteFile);
out.getParentFile().mkdirs();
- FileUtils.copyFile( in, out );
+ FileUtils.copyFile(in, out);
}
- }
- else
- {
- File in = new File( from, generatedSiteFile );
- File out = new File( to, generatedSiteFile );
+ } else {
+ File in = new File(from, generatedSiteFile);
+ File out = new File(to, generatedSiteFile);
out.getParentFile().mkdirs();
- FileUtils.copyFile( in, out );
+ FileUtils.copyFile(in, out);
}
}
}
@@ -629,33 +590,30 @@ public class PdfMojo
* @throws MojoExecutionException if any
* @see #appendGeneratedReports(DocumentModel, Locale)
*/
- private DocumentModel getDocumentModel( Locale locale )
- throws MojoExecutionException
- {
- if ( docDescriptor.exists() )
- {
- DocumentModel doc = getDocumentModelFromDescriptor( locale );
+ private DocumentModel getDocumentModel(Locale locale) throws MojoExecutionException {
+ if (docDescriptor.exists()) {
+ DocumentModel doc = getDocumentModelFromDescriptor(locale);
// TODO: descriptor model should get merged into default model, see MODELLO-63
- appendGeneratedReports( doc, locale );
+ appendGeneratedReports(doc, locale);
- saveTOC( doc.getToc(), locale );
+ saveTOC(doc.getToc(), locale);
return doc;
}
- DocumentModel model = new DocumentModelBuilder( project, getDefaultDecorationModel() ).getDocumentModel();
+ DocumentModel model = new DocumentModelBuilder(project, getDefaultDecorationModel()).getDocumentModel();
- model.getMeta().setGenerator( getDefaultGenerator() );
- model.getMeta().setLanguage( locale.getLanguage() );
- model.getCover().setCoverType( i18n.getString( "pdf-plugin", getDefaultLocale(), "toc.type" ) );
- model.getToc().setName( i18n.getString( "pdf-plugin", getDefaultLocale(), "toc.title" ) );
+ model.getMeta().setGenerator(getDefaultGenerator());
+ model.getMeta().setLanguage(locale.getLanguage());
+ model.getCover().setCoverType(i18n.getString("pdf-plugin", getDefaultLocale(), "toc.type"));
+ model.getToc().setName(i18n.getString("pdf-plugin", getDefaultLocale(), "toc.title"));
- appendGeneratedReports( model, locale );
+ appendGeneratedReports(model, locale);
- saveTOC( model.getToc(), locale );
+ saveTOC(model.getToc(), locale);
- debugLogGeneratedModel( model );
+ debugLogGeneratedModel(model);
return model;
}
@@ -667,38 +625,28 @@ public class PdfMojo
* @return the DocumentModel read from the configured document descriptor.
* @throws org.apache.maven.plugin.MojoExecutionException if the model could not be read.
*/
- private DocumentModel getDocumentModelFromDescriptor( Locale locale )
- throws MojoExecutionException
- {
+ private DocumentModel getDocumentModelFromDescriptor(Locale locale) throws MojoExecutionException {
DocumentModel model;
- try
- {
- model = new DocumentDescriptorReader( project, getLog(),
- locale ).readAndFilterDocumentDescriptor( docDescriptor );
- }
- catch ( XmlPullParserException ex )
- {
- throw new MojoExecutionException( "Error reading DocumentDescriptor!", ex );
- }
- catch ( IOException io )
- {
- throw new MojoExecutionException( "Error opening DocumentDescriptor!", io );
+ try {
+ model = new DocumentDescriptorReader(project, getLog(), locale)
+ .readAndFilterDocumentDescriptor(docDescriptor);
+ } catch (XmlPullParserException ex) {
+ throw new MojoExecutionException("Error reading DocumentDescriptor!", ex);
+ } catch (IOException io) {
+ throw new MojoExecutionException("Error opening DocumentDescriptor!", io);
}
- if ( model.getMeta() == null )
- {
- model.setMeta( new DocumentMeta() );
+ if (model.getMeta() == null) {
+ model.setMeta(new DocumentMeta());
}
- if ( StringUtils.isEmpty( model.getMeta().getLanguage() ) )
- {
- model.getMeta().setLanguage( locale.getLanguage() );
+ if (StringUtils.isEmpty(model.getMeta().getLanguage())) {
+ model.getMeta().setLanguage(locale.getLanguage());
}
- if ( StringUtils.isEmpty( model.getMeta().getGenerator() ) )
- {
- model.getMeta().setGenerator( getDefaultGenerator() );
+ if (StringUtils.isEmpty(model.getMeta().getGenerator())) {
+ model.getMeta().setGenerator(getDefaultGenerator());
}
return model;
@@ -711,25 +659,21 @@ public class PdfMojo
* @param locale a Locale.
* @return File.
*/
- private File getLocaleDirectory( File basedir, Locale locale )
- {
- if ( locale.getLanguage().equals( getDefaultLocale().getLanguage() ) )
- {
+ private File getLocaleDirectory(File basedir, Locale locale) {
+ if (locale.getLanguage().equals(getDefaultLocale().getLanguage())) {
return basedir;
}
- return new File( basedir, locale.getLanguage() );
+ return new File(basedir, locale.getLanguage());
}
/**
* @return the default locale from <code>siteTool</code>.
* @see #getAvailableLocales()
*/
- private Locale getDefaultLocale()
- {
- if ( this.defaultLocale == null )
- {
- this.defaultLocale = getAvailableLocales().get( 0 );
+ private Locale getDefaultLocale() {
+ if (this.defaultLocale == null) {
+ this.defaultLocale = getAvailableLocales().get(0);
}
return this.defaultLocale;
@@ -738,11 +682,9 @@ public class PdfMojo
/**
* @return the available locales from <code>siteTool</code>.
*/
- private List<Locale> getAvailableLocales()
- {
- if ( this.localesList == null )
- {
- this.localesList = siteTool.getSiteLocales( locales );
+ private List<Locale> getAvailableLocales() {
+ if (this.localesList == null) {
+ this.localesList = siteTool.getSiteLocales(locales);
}
return this.localesList;
@@ -752,39 +694,27 @@ public class PdfMojo
* @return the DecorationModel instance from <code>site.xml</code>
* @throws MojoExecutionException if any
*/
- private DecorationModel getDefaultDecorationModel()
- throws MojoExecutionException
- {
- if ( this.defaultDecorationModel == null )
- {
+ private DecorationModel getDefaultDecorationModel() throws MojoExecutionException {
+ if (this.defaultDecorationModel == null) {
final Locale locale = getDefaultLocale();
- final File descriptorFile = siteTool.getSiteDescriptor( siteDirectory, locale );
+ final File descriptorFile = siteTool.getSiteDescriptor(siteDirectory, locale);
DecorationModel decoration = null;
- if ( descriptorFile.exists() )
- {
- try ( XmlStreamReader reader = new XmlStreamReader( descriptorFile ) )
- {
- String siteDescriptorContent = IOUtil.toString( reader );
+ if (descriptorFile.exists()) {
+ try (XmlStreamReader reader = new XmlStreamReader(descriptorFile)) {
+ String siteDescriptorContent = IOUtil.toString(reader);
- siteDescriptorContent =
- siteTool.getInterpolatedSiteDescriptorContent( new HashMap<>( 2 ), project,
- siteDescriptorContent );
+ siteDescriptorContent = siteTool.getInterpolatedSiteDescriptorContent(
+ new HashMap<>(2), project, siteDescriptorContent);
- decoration = new DecorationXpp3Reader().read( new StringReader( siteDescriptorContent ) );
- }
- catch ( XmlPullParserException e )
- {
- throw new MojoExecutionException( "Error parsing site descriptor", e );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error reading site descriptor", e );
- }
- catch ( SiteToolException e )
- {
- throw new MojoExecutionException( "Error when interpoling site descriptor", e );
+ decoration = new DecorationXpp3Reader().read(new StringReader(siteDescriptorContent));
+ } catch (XmlPullParserException e) {
+ throw new MojoExecutionException("Error parsing site descriptor", e);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error reading site descriptor", e);
+ } catch (SiteToolException e) {
+ throw new MojoExecutionException("Error when interpoling site descriptor", e);
}
}
@@ -801,53 +731,38 @@ public class PdfMojo
* @throws MojoExecutionException if any
* @see #getDefaultDecorationModel()
*/
- private void copyResources( Locale locale )
- throws MojoExecutionException
- {
+ private void copyResources(Locale locale) throws MojoExecutionException {
final DecorationModel decorationModel = getDefaultDecorationModel();
- if ( decorationModel == null )
- {
+ if (decorationModel == null) {
return;
}
Artifact skinArtifact;
- try
- {
- skinArtifact =
- siteTool.getSkinArtifactFromRepository( localRepository, project.getRemoteArtifactRepositories(),
- decorationModel );
- }
- catch ( SiteToolException e )
- {
- throw new MojoExecutionException( "SiteToolException: " + e.getMessage(), e );
+ try {
+ skinArtifact = siteTool.getSkinArtifactFromRepository(
+ localRepository, project.getRemoteArtifactRepositories(), decorationModel);
+ } catch (SiteToolException e) {
+ throw new MojoExecutionException("SiteToolException: " + e.getMessage(), e);
}
- if ( skinArtifact == null )
- {
+ if (skinArtifact == null) {
return;
}
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "Copy resources from skin artifact: '" + skinArtifact.getId() + "'..." );
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Copy resources from skin artifact: '" + skinArtifact.getId() + "'...");
}
- try
- {
- final SiteRenderingContext context =
- siteRenderer.createContextForSkin( skinArtifact, new HashMap<>( 2 ), decorationModel,
- project.getName(), locale );
- context.addSiteDirectory( new File( siteDirectory, locale.getLanguage() ) );
+ try {
+ final SiteRenderingContext context = siteRenderer.createContextForSkin(
+ skinArtifact, new HashMap<>(2), decorationModel, project.getName(), locale);
+ context.addSiteDirectory(new File(siteDirectory, locale.getLanguage()));
- siteRenderer.copyResources( context, getWorkingDirectory() );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "IOException: " + e.getMessage(), e );
- }
- catch ( RendererException e )
- {
- throw new MojoExecutionException( "RendererException: " + e.getMessage(), e );
+ siteRenderer.copyResources(context, getWorkingDirectory());
+ } catch (IOException e) {
+ throw new MojoExecutionException("IOException: " + e.getMessage(), e);
+ } catch (RendererException e) {
+ throw new MojoExecutionException("RendererException: " + e.getMessage(), e);
}
}
@@ -856,8 +771,7 @@ public class PdfMojo
*
* @return A String in the form <code>Maven PDF Plugin v. 1.1.1, 'fo' implementation</code>.
*/
- private String getDefaultGenerator()
- {
+ private String getDefaultGenerator() {
return "Maven PDF Plugin v. " + pluginVersion + ", '" + implementation + "' implementation.";
}
@@ -866,29 +780,23 @@ public class PdfMojo
*
* @param docModel the model to write.
*/
- private void debugLogGeneratedModel( final DocumentModel docModel )
- {
- if ( getLog().isDebugEnabled() && project != null )
- {
- final File outputDir = new File( project.getBuild().getDirectory(), "pdf" );
+ private void debugLogGeneratedModel(final DocumentModel docModel) {
+ if (getLog().isDebugEnabled() && project != null) {
+ final File outputDir = new File(project.getBuild().getDirectory(), "pdf");
- if ( !outputDir.exists() )
- {
+ if (!outputDir.exists()) {
outputDir.mkdirs();
}
- final File doc = FileUtils.createTempFile( "pdf", ".xml", outputDir );
+ final File doc = FileUtils.createTempFile("pdf", ".xml", outputDir);
final DocumentXpp3Writer xpp3 = new DocumentXpp3Writer();
- try ( Writer writer = WriterFactory.newXmlWriter( doc ) )
- {
- xpp3.write( writer, docModel );
- getLog().debug( "Generated a default document model: " + doc.getAbsolutePath() );
- }
- catch ( IOException e )
- {
- getLog().error( "Failed to write document model: " + e.getMessage() );
- getLog().debug( e );
+ try (Writer writer = WriterFactory.newXmlWriter(doc)) {
+ xpp3.write(writer, docModel);
+ getLog().debug("Generated a default document model: " + doc.getAbsolutePath());
+ } catch (IOException e) {
+ getLog().error("Failed to write document model: " + e.getMessage());
+ getLog().debug(e);
}
}
}
@@ -902,30 +810,25 @@ public class PdfMojo
* @throws IOException if any
* @since 1.1
*/
- private void generateMavenReports( Locale locale )
- throws MojoExecutionException, IOException
- {
- if ( !isIncludeReports() )
- {
- getLog().info( "Skipped report generation." );
+ private void generateMavenReports(Locale locale) throws MojoExecutionException, IOException {
+ if (!isIncludeReports()) {
+ getLog().info("Skipped report generation.");
return;
}
- if ( project.getReporting() == null )
- {
- getLog().info( "No report was specified." );
+ if (project.getReporting() == null) {
+ getLog().info("No report was specified.");
return;
}
List<MavenReportExecution> reportExecutions = getReports();
- for ( MavenReportExecution reportExecution : reportExecutions )
- {
- generateMavenReport( reportExecution, locale );
+ for (MavenReportExecution reportExecution : reportExecutions) {
+ generateMavenReport(reportExecution, locale);
}
// copy generated site
- copySiteDir( getGeneratedSiteDirectoryTmp(), getSiteDirectoryTmp() );
- copySiteDir( generatedSiteDirectory, getSiteDirectoryTmp() );
+ copySiteDir(getGeneratedSiteDirectoryTmp(), getSiteDirectoryTmp());
+ copySiteDir(generatedSiteDirectory, getSiteDirectoryTmp());
}
/**
@@ -938,119 +841,105 @@ public class PdfMojo
* @throws MojoExecutionException if any
* @since 1.1
*/
- private void generateMavenReport( MavenReportExecution reportExecution, Locale locale )
- throws IOException, MojoExecutionException
- {
+ private void generateMavenReport(MavenReportExecution reportExecution, Locale locale)
+ throws IOException, MojoExecutionException {
MavenReport report = reportExecution.getMavenReport();
- String localReportName = report.getName( locale );
+ String localReportName = report.getName(locale);
- if ( !reportExecution.canGenerateReport() )
- {
- getLog().info( "Skipped \"" + localReportName + "\" report." );
- getLog().debug( "canGenerateReport() was false." );
+ if (!reportExecution.canGenerateReport()) {
+ getLog().info("Skipped \"" + localReportName + "\" report.");
+ getLog().debug("canGenerateReport() was false.");
return;
}
- if ( report.isExternalReport() )
- {
- getLog().info( "Skipped external \"" + localReportName + "\" report (not supported by pdf plugin)." );
- getLog().debug( "isExternalReport() was false." );
+ if (report.isExternalReport()) {
+ getLog().info("Skipped external \"" + localReportName + "\" report (not supported by pdf plugin).");
+ getLog().debug("isExternalReport() was false.");
return;
}
- for ( final MavenReport generatedReport : getGeneratedMavenReports( locale ) )
- {
- if ( report.getName( locale ).equals( generatedReport.getName( locale ) ) )
- {
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( report.getName( locale ) + " was already generated." );
+ for (final MavenReport generatedReport : getGeneratedMavenReports(locale)) {
+ if (report.getName(locale).equals(generatedReport.getName(locale))) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(report.getName(locale) + " was already generated.");
}
return;
}
}
- File outDir = new File( getGeneratedSiteDirectoryTmp(), "xdoc" );
- if ( !locale.getLanguage().equals( defaultLocale.getLanguage() ) )
- {
- outDir = new File( new File( getGeneratedSiteDirectoryTmp(), locale.getLanguage() ), "xdoc" );
+ File outDir = new File(getGeneratedSiteDirectoryTmp(), "xdoc");
+ if (!locale.getLanguage().equals(defaultLocale.getLanguage())) {
+ outDir = new File(new File(getGeneratedSiteDirectoryTmp(), locale.getLanguage()), "xdoc");
}
outDir.mkdirs();
- File generatedReport = new File( outDir, report.getOutputName() + ".xml" );
+ File generatedReport = new File(outDir, report.getOutputName() + ".xml");
- if ( siteDirectory.exists() )
- {
- String excludes = getDefaultExcludesWithLocales( getAvailableLocales(), getDefaultLocale() );
+ if (siteDirectory.exists()) {
+ String excludes = getDefaultExcludesWithLocales(getAvailableLocales(), getDefaultLocale());
List<String> files =
- FileUtils.getFileNames( siteDirectory, "*/" + report.getOutputName() + ".*", excludes, false );
- if ( !locale.getLanguage().equals( defaultLocale.getLanguage() ) )
- {
- files =
- FileUtils.getFileNames( new File( siteDirectory, locale.getLanguage() ), "*/"
- + report.getOutputName() + ".*", excludes, false );
+ FileUtils.getFileNames(siteDirectory, "*/" + report.getOutputName() + ".*", excludes, false);
+ if (!locale.getLanguage().equals(defaultLocale.getLanguage())) {
+ files = FileUtils.getFileNames(
+ new File(siteDirectory, locale.getLanguage()),
+ "*/" + report.getOutputName() + ".*",
+ excludes,
+ false);
}
- if ( files.size() != 0 )
- {
- String displayLanguage = locale.getDisplayLanguage( Locale.ENGLISH );
-
- if ( getLog().isInfoEnabled() )
- {
- getLog().info(
- "Skipped \"" + report.getName( locale ) + "\" report, file \""
- + report.getOutputName() + "\" already exists for the " + displayLanguage
- + " version." );
+ if (files.size() != 0) {
+ String displayLanguage = locale.getDisplayLanguage(Locale.ENGLISH);
+
+ if (getLog().isInfoEnabled()) {
+ getLog().info("Skipped \"" + report.getName(locale) + "\" report, file \""
+ + report.getOutputName() + "\" already exists for the " + displayLanguage
+ + " version.");
}
return;
}
}
- if ( getLog().isInfoEnabled() )
- {
- getLog().info( "Generating \"" + localReportName + "\" report." );
+ if (getLog().isInfoEnabled()) {
+ getLog().info("Generating \"" + localReportName + "\" report.");
}
// The report will eventually generate output by itself, so we set its output directory anyway.
- report.setReportOutputDirectory( outDir );
+ report.setReportOutputDirectory(outDir);
StringWriter sw = new StringWriter();
PdfXdocSink pdfXdocSink = null;
- try
- {
- pdfXdocSink = new PdfXdocSink( sw );
- renderReportToSink( reportExecution, locale, pdfXdocSink );
- }
- catch ( MavenReportException e )
- {
- String goal = reportExecution.getPlugin().getArtifactId() + ':' + reportExecution.getPlugin().getVersion()
- + ':' + reportExecution.getGoal();
- throw new MojoExecutionException( "Error generating " + goal + " report", e );
- }
- finally
- {
- if ( pdfXdocSink != null )
- {
+ try {
+ pdfXdocSink = new PdfXdocSink(sw);
+ renderReportToSink(reportExecution, locale, pdfXdocSink);
+ } catch (MavenReportException e) {
+ String goal = reportExecution.getPlugin().getArtifactId()
+ + ':'
+ + reportExecution.getPlugin().getVersion()
+ + ':'
+ + reportExecution.getGoal();
+ throw new MojoExecutionException("Error generating " + goal + " report", e);
+ } finally {
+ if (pdfXdocSink != null) {
pdfXdocSink.close();
}
}
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "Writing generated xdoc to " + generatedReport );
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Writing generated xdoc to " + generatedReport);
}
- writeGeneratedReport( sw.toString(), generatedReport );
+ writeGeneratedReport(sw.toString(), generatedReport);
// keep generated report xdoc only if it is valid
- if ( isValidGeneratedReportXdoc( reportExecution.getPlugin().getId() + ':' + reportExecution.getGoal(),
- generatedReport, localReportName ) )
- {
- getGeneratedMavenReports( locale ).add( report );
+ if (isValidGeneratedReportXdoc(
+ reportExecution.getPlugin().getId() + ':' + reportExecution.getGoal(),
+ generatedReport,
+ localReportName)) {
+ getGeneratedMavenReports(locale).add(report);
}
}
@@ -1062,15 +951,12 @@ public class PdfMojo
* @param sink
* @throws MavenReportException
*/
- private void renderReportToSink( MavenReportExecution reportExec, Locale locale, PdfXdocSink sink )
- throws MavenReportException
- {
+ private void renderReportToSink(MavenReportExecution reportExec, Locale locale, PdfXdocSink sink)
+ throws MavenReportException {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- if ( reportExec.getClassLoader() != null )
- {
- Thread.currentThread().setContextClassLoader( reportExec.getClassLoader() );
+ try {
+ if (reportExec.getClassLoader() != null) {
+ Thread.currentThread().setContextClassLoader(reportExec.getClassLoader());
}
MavenReport report = reportExec.getMavenReport();
@@ -1087,14 +973,11 @@ public class PdfMojo
else
{*/
// old single-page-only API
- report.generate( sink, locale );
- //}
- }
- finally
- {
- if ( reportExec.getClassLoader() != null )
- {
- Thread.currentThread().setContextClassLoader( originalClassLoader );
+ report.generate(sink, locale);
+ // }
+ } finally {
+ if (reportExec.getClassLoader() != null) {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
}
@@ -1104,16 +987,14 @@ public class PdfMojo
* @return the generated reports
* @since 1.1
*/
- private List<MavenReport> getGeneratedMavenReports( Locale locale )
- {
- if ( this.generatedMavenReports == null )
- {
- this.generatedMavenReports = new HashMap<>( 2 );
+ private List<MavenReport> getGeneratedMavenReports(Locale locale) {
+ if (this.generatedMavenReports == null) {
+ this.generatedMavenReports = new HashMap<>(2);
}
- this.generatedMavenReports.computeIfAbsent( locale, k -> new ArrayList<>( 2 ) );
+ this.generatedMavenReports.computeIfAbsent(locale, k -> new ArrayList<>(2));
- return this.generatedMavenReports.get( locale );
+ return this.generatedMavenReports.get(locale);
}
/**
@@ -1132,99 +1013,79 @@ public class PdfMojo
* @see #generateMavenReports(Locale)
* @since 1.1
*/
- protected void appendGeneratedReports( DocumentModel model, Locale locale )
- {
- if ( !isIncludeReports() )
- {
+ protected void appendGeneratedReports(DocumentModel model, Locale locale) {
+ if (!isIncludeReports()) {
return;
}
- if ( getGeneratedMavenReports( locale ).isEmpty() )
- {
+ if (getGeneratedMavenReports(locale).isEmpty()) {
return;
}
final DocumentTOCItem documentTOCItem = new DocumentTOCItem();
- documentTOCItem.setName( i18n.getString( "pdf-plugin", locale, "toc.project-info.item" ) );
- documentTOCItem.setRef( "project-info" ); // see #generateMavenReports(Locale)
+ documentTOCItem.setName(i18n.getString("pdf-plugin", locale, "toc.project-info.item"));
+ documentTOCItem.setRef("project-info"); // see #generateMavenReports(Locale)
- List<String> addedRef = new ArrayList<>( 4 );
+ List<String> addedRef = new ArrayList<>(4);
- List<DocumentTOCItem> items = new ArrayList<>( 4 );
+ List<DocumentTOCItem> items = new ArrayList<>(4);
// append generated report defined as MavenReport
- for ( final MavenReport report : getGeneratedMavenReports( locale ) )
- {
+ for (final MavenReport report : getGeneratedMavenReports(locale)) {
final DocumentTOCItem reportItem = new DocumentTOCItem();
- reportItem.setName( report.getName( locale ) );
- reportItem.setRef( report.getOutputName() );
+ reportItem.setName(report.getName(locale));
+ reportItem.setRef(report.getOutputName());
- items.add( reportItem );
+ items.add(reportItem);
- addedRef.add( report.getOutputName() );
+ addedRef.add(report.getOutputName());
}
// append all generated reports from generated-site
- try
- {
- if ( generatedSiteDirectory.exists() )
- {
- String excludes = getDefaultExcludesWithLocales( getAvailableLocales(), getDefaultLocale() );
- List<String> generatedDirs = FileUtils.getDirectoryNames( generatedSiteDirectory, "*", excludes,
- true );
- if ( !locale.getLanguage().equals( getDefaultLocale().getLanguage() ) )
- {
- generatedDirs =
- FileUtils.getFileNames( new File( generatedSiteDirectory, locale.getLanguage() ), "*",
- excludes, true );
+ try {
+ if (generatedSiteDirectory.exists()) {
+ String excludes = getDefaultExcludesWithLocales(getAvailableLocales(), getDefaultLocale());
+ List<String> generatedDirs = FileUtils.getDirectoryNames(generatedSiteDirectory, "*", excludes, true);
+ if (!locale.getLanguage().equals(getDefaultLocale().getLanguage())) {
+ generatedDirs = FileUtils.getFileNames(
+ new File(generatedSiteDirectory, locale.getLanguage()), "*", excludes, true);
}
- for ( final String generatedDir : generatedDirs )
- {
+ for (final String generatedDir : generatedDirs) {
List<String> generatedFiles =
- FileUtils.getFileNames( new File( generatedDir ), "**.*", excludes, false );
+ FileUtils.getFileNames(new File(generatedDir), "**.*", excludes, false);
- for ( final String generatedFile : generatedFiles )
- {
- final String ref = generatedFile.substring( 0, generatedFile.lastIndexOf( '.' ) );
+ for (final String generatedFile : generatedFiles) {
+ final String ref = generatedFile.substring(0, generatedFile.lastIndexOf('.'));
- if ( !addedRef.contains( ref ) )
- {
- final String title =
- getGeneratedDocumentTitle( new File( generatedDir, generatedFile ) );
+ if (!addedRef.contains(ref)) {
+ final String title = getGeneratedDocumentTitle(new File(generatedDir, generatedFile));
- if ( title != null )
- {
+ if (title != null) {
final DocumentTOCItem reportItem = new DocumentTOCItem();
- reportItem.setName( title );
- reportItem.setRef( ref );
+ reportItem.setName(title);
+ reportItem.setRef(ref);
- items.add( reportItem );
+ items.add(reportItem);
}
}
}
}
}
- }
- catch ( IOException e )
- {
- getLog().error( "IOException: " + e.getMessage() );
- getLog().debug( e );
+ } catch (IOException e) {
+ getLog().error("IOException: " + e.getMessage());
+ getLog().debug(e);
}
// append to Toc
- documentTOCItem.setItems( items );
- model.getToc().addItem( documentTOCItem );
+ documentTOCItem.setItems(items);
+ model.getToc().addItem(documentTOCItem);
}
- private void saveTOC( DocumentTOC toc, Locale locale )
- {
- try
- {
- TocFileHelper.saveTOC( getWorkingDirectory(), toc, locale );
- }
- catch ( IOException e )
- {
- getLog().error( "Error while writing table of contents", e );
+ private void saveTOC(DocumentTOC toc, Locale locale) {
+ try {
+ TocFileHelper.saveTOC(getWorkingDirectory(), toc, locale);
+ } catch (IOException e) {
+ getLog().error("Error while writing table of contents", e);
}
}
@@ -1236,26 +1097,19 @@ public class PdfMojo
* @throws IOException if any
* @since 1.1
*/
- private String getGeneratedDocumentTitle( final File f )
- throws IOException
- {
- final IndexEntry entry = new IndexEntry( "index" );
- final IndexingSink titleSink = new IndexingSink( entry );
-
- try ( Reader reader = ReaderFactory.newXmlReader( f ) )
- {
- doxia.parse( reader, f.getParentFile().getName(), titleSink );
- }
- catch ( ParseException e )
- {
- getLog().error( "ParseException: " + e.getMessage() );
- getLog().debug( e );
+ private String getGeneratedDocumentTitle(final File f) throws IOException {
+ final IndexEntry entry = new IndexEntry("index");
+ final IndexingSink titleSink = new IndexingSink(entry);
+
+ try (Reader reader = ReaderFactory.newXmlReader(f)) {
+ doxia.parse(reader, f.getParentFile().getName(), titleSink);
+ } catch (ParseException e) {
+ getLog().error("ParseException: " + e.getMessage());
+ getLog().debug(e);
return null;
- }
- catch ( ParserNotFoundException e )
- {
- getLog().error( "ParserNotFoundException: " + e.getMessage() );
- getLog().debug( e );
+ } catch (ParserNotFoundException e) {
+ getLog().error("ParserNotFoundException: " + e.getMessage());
+ getLog().debug(e);
return null;
}
@@ -1271,15 +1125,11 @@ public class PdfMojo
* @return <code>true</code> if Doxia is able to parse the generated report, <code>false</code> otherwise.
* @since 1.1
*/
- private boolean isValidGeneratedReportXdoc( String fullGoal, File generatedReport, String localReportName )
- {
+ private boolean isValidGeneratedReportXdoc(String fullGoal, File generatedReport, String localReportName) {
SinkAdapter sinkAdapter = new SinkAdapter();
- try ( Reader reader = ReaderFactory.newXmlReader( generatedReport ) )
- {
- doxia.parse( reader, "xdoc", sinkAdapter );
- }
- catch ( ParseException e )
- {
+ try (Reader reader = ReaderFactory.newXmlReader(generatedReport)) {
+ doxia.parse(reader, "xdoc", sinkAdapter);
+ } catch (ParseException e) {
String sb = EOL
+ "Error when parsing the generated report xdoc file: "
+ generatedReport.getAbsolutePath() + EOL
@@ -1291,22 +1141,18 @@ public class PdfMojo
+ " from the <reporting/> part. To not affect the site generation, "
+ "you could create a PDF profile." + EOL
+ "Ignoring the \"" + localReportName + "\" report in the PDF." + EOL;
- getLog().error( sb );
- getLog().debug( e );
+ getLog().error(sb);
+ getLog().debug(e);
return false;
- }
- catch ( ParserNotFoundException e )
- {
- getLog().error( "ParserNotFoundException: " + e.getMessage() );
- getLog().debug( e );
+ } catch (ParserNotFoundException e) {
+ getLog().error("ParserNotFoundException: " + e.getMessage());
+ getLog().debug(e);
return false;
- }
- catch ( IOException e )
- {
- getLog().error( "IOException: " + e.getMessage() );
- getLog().debug( e );
+ } catch (IOException e) {
+ getLog().error("IOException: " + e.getMessage());
+ getLog().debug(e);
return false;
}
@@ -1314,25 +1160,20 @@ public class PdfMojo
return true;
}
- protected List<MavenReportExecution> getReports()
- throws MojoExecutionException
- {
+ protected List<MavenReportExecution> getReports() throws MojoExecutionException {
MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
- mavenReportExecutorRequest.setLocalRepository( localRepository );
- mavenReportExecutorRequest.setMavenSession( session );
- mavenReportExecutorRequest.setProject( project );
- mavenReportExecutorRequest.setReportPlugins( getReportingPlugins() );
+ mavenReportExecutorRequest.setLocalRepository(localRepository);
+ mavenReportExecutorRequest.setMavenSession(session);
+ mavenReportExecutorRequest.setProject(project);
+ mavenReportExecutorRequest.setReportPlugins(getReportingPlugins());
MavenReportExecutor mavenReportExecutor;
- try
- {
- mavenReportExecutor = (MavenReportExecutor) container.lookup( MavenReportExecutor.class.getName() );
- }
- catch ( ComponentLookupException e )
- {
- throw new MojoExecutionException( "could not get MavenReportExecutor component", e );
+ try {
+ mavenReportExecutor = (MavenReportExecutor) container.lookup(MavenReportExecutor.class.getName());
+ } catch (ComponentLookupException e) {
+ throw new MojoExecutionException("could not get MavenReportExecutor component", e);
}
- return mavenReportExecutor.buildMavenReports( mavenReportExecutorRequest );
+ return mavenReportExecutor.buildMavenReports(mavenReportExecutorRequest);
}
/**
@@ -1342,29 +1183,25 @@ public class PdfMojo
* @return the effective list of reports
* @since 1.5
*/
- private ReportPlugin[] getReportingPlugins()
- {
+ private ReportPlugin[] getReportingPlugins() {
List<ReportPlugin> reportingPlugins = reporting.getPlugins();
// MSITE-806: add default report plugin like done in maven-model-builder DefaultReportingConverter
boolean hasMavenProjectInfoReportsPlugin = false;
- for ( ReportPlugin plugin : reportingPlugins )
- {
- if ( "org.apache.maven.plugins".equals( plugin.getGroupId() )
- && "maven-project-info-reports-plugin".equals( plugin.getArtifactId() ) )
- {
+ for (ReportPlugin plugin : reportingPlugins) {
+ if ("org.apache.maven.plugins".equals(plugin.getGroupId())
+ && "maven-project-info-reports-plugin".equals(plugin.getArtifactId())) {
hasMavenProjectInfoReportsPlugin = true;
break;
}
}
- if ( !reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin )
- {
+ if (!reporting.isExcludeDefaults() && !hasMavenProjectInfoReportsPlugin) {
ReportPlugin mpir = new ReportPlugin();
- mpir.setArtifactId( "maven-project-info-reports-plugin" );
- reportingPlugins.add( mpir );
+ mpir.setArtifactId("maven-project-info-reports-plugin");
+ reportingPlugins.add(mpir);
}
- return reportingPlugins.toArray( new ReportPlugin[0] );
+ return reportingPlugins.toArray(new ReportPlugin[0]);
}
/**
@@ -1378,18 +1215,14 @@ public class PdfMojo
* @throws IOException if any
* @since 1.1
*/
- private static void writeGeneratedReport( String content, File toFile )
- throws IOException
- {
- if ( StringUtils.isEmpty( content ) )
- {
+ private static void writeGeneratedReport(String content, File toFile) throws IOException {
+ if (StringUtils.isEmpty(content)) {
return;
}
- try ( Writer writer = WriterFactory.newXmlWriter( toFile ) )
- {
+ try (Writer writer = WriterFactory.newXmlWriter(toFile)) {
// see PdfSink#table()
- writer.write( StringUtils.replace( content, "<table><table", "<table" ) );
+ writer.write(StringUtils.replace(content, "<table><table", "<table"));
}
}
@@ -1400,14 +1233,11 @@ public class PdfMojo
* @see FileUtils#getDefaultExcludesAsString()
* @since 1.1
*/
- private static String getDefaultExcludesWithLocales( List<Locale> locales, Locale defaultLocale )
- {
- StringBuilder excludesLocales = new StringBuilder( FileUtils.getDefaultExcludesAsString() );
- for ( final Locale locale : locales )
- {
- if ( !locale.getLanguage().equals( defaultLocale.getLanguage() ) )
- {
- excludesLocales.append( ",**/" ).append( locale.getLanguage() ).append( "/*" );
+ private static String getDefaultExcludesWithLocales(List<Locale> locales, Locale defaultLocale) {
+ StringBuilder excludesLocales = new StringBuilder(FileUtils.getDefaultExcludesAsString());
+ for (final Locale locale : locales) {
+ if (!locale.getLanguage().equals(defaultLocale.getLanguage())) {
+ excludesLocales.append(",**/").append(locale.getLanguage()).append("/*");
}
}
@@ -1419,31 +1249,23 @@ public class PdfMojo
*
* @since 1.1
*/
- private static class PdfXdocSink
- extends XdocSink
- implements org.codehaus.doxia.sink.Sink
- {
- protected PdfXdocSink( Writer writer )
- {
- super( writer );
+ private static class PdfXdocSink extends XdocSink implements org.codehaus.doxia.sink.Sink {
+ protected PdfXdocSink(Writer writer) {
+ super(writer);
}
/** {@inheritDoc} */
- public void text( String text )
- {
+ public void text(String text) {
// workaround to fix quotes introduced with MPIR-59 (then removed in MPIR-136)
- super.text( StringUtils.replace( text, "\u0092", "'" ) );
+ super.text(StringUtils.replace(text, "\u0092", "'"));
}
- public void tableRow()
- {
+ public void tableRow() {
// To be backward compatible: TODO add to XdocSink
- if ( !this.tableRows )
- {
- tableRows( null, false );
+ if (!this.tableRows) {
+ tableRows(null, false);
}
- super.tableRow( null );
+ super.tableRow(null);
}
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/pdf/TocFileHelper.java b/src/main/java/org/apache/maven/plugins/pdf/TocFileHelper.java
index c005b91..6b92aa4 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/TocFileHelper.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/TocFileHelper.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -37,40 +55,32 @@ import org.kopitubruk.util.json.JSONUtil;
/**
* Helper to save then reload TOC content (to a json file), to be able to aggregate TOCs.
- *
+ *
* @author anthony-beurive
* @since 1.5
*/
-class TocFileHelper
-{
+class TocFileHelper {
private static final String FILENAME = "toc.json";
- static void saveTOC( File workingDirectory, DocumentTOC toc, Locale locale )
- throws IOException
- {
+ static void saveTOC(File workingDirectory, DocumentTOC toc, Locale locale) throws IOException {
// FIXME: manage locales.
JSONConfig jsonConfig = new JSONConfig();
- jsonConfig.setIndentPadding( new IndentPadding( " ", "\n" ) );
- jsonConfig.addReflectClass( DocumentTOC.class );
- jsonConfig.addReflectClass( DocumentTOCItem.class );
+ jsonConfig.setIndentPadding(new IndentPadding(" ", "\n"));
+ jsonConfig.addReflectClass(DocumentTOC.class);
+ jsonConfig.addReflectClass(DocumentTOCItem.class);
- try ( Writer writer = WriterFactory.newWriter( getTocFile( workingDirectory ), "UTF-8" ) )
- {
- JSONUtil.toJSON( toc, jsonConfig, writer );
+ try (Writer writer = WriterFactory.newWriter(getTocFile(workingDirectory), "UTF-8")) {
+ JSONUtil.toJSON(toc, jsonConfig, writer);
}
}
- static Map<String, Object> loadToc( File workingDirectory )
- throws IOException
- {
- try ( Reader reader = ReaderFactory.newReader( getTocFile( workingDirectory ), "UTF-8" ) )
- {
- return (Map) JSONParser.parseJSON( reader );
+ static Map<String, Object> loadToc(File workingDirectory) throws IOException {
+ try (Reader reader = ReaderFactory.newReader(getTocFile(workingDirectory), "UTF-8")) {
+ return (Map) JSONParser.parseJSON(reader);
}
}
- private static File getTocFile( File workingDirectory )
- {
- return new File( workingDirectory, FILENAME );
+ private static File getTocFile(File workingDirectory) {
+ return new File(workingDirectory, FILENAME);
}
}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java b/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java
index 1e29e1a..471bdfa 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/DateBeanTest.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -20,32 +38,30 @@ package org.apache.maven.plugins.pdf;
*/
import java.util.Date;
+
import junit.framework.TestCase;
/**
*
* @author ltheussl
*/
-public class DateBeanTest
- extends TestCase
-{
+public class DateBeanTest extends TestCase {
/**
* Test DateBean.
*/
- public void testDateBean()
- {
+ public void testDateBean() {
DateBean date = new DateBean();
- date.setDate( new Date( 0L ) );
+ date.setDate(new Date(0L));
- assertEquals( "1970-01-01", date.getDate() );
- assertEquals( "1970-01-01T00:00:00Z", date.getDateTime() );
- assertEquals( "01", date.getDay() );
- assertEquals( "00", date.getHour() );
- assertEquals( "000", date.getMillisecond() );
- assertEquals( "00", date.getMinute() );
- assertEquals( "01", date.getMonth() );
- assertEquals( "00", date.getSecond() );
- assertEquals( "00:00:00Z", date.getTime() );
- assertEquals( "1970", date.getYear() );
+ assertEquals("1970-01-01", date.getDate());
+ assertEquals("1970-01-01T00:00:00Z", date.getDateTime());
+ assertEquals("01", date.getDay());
+ assertEquals("00", date.getHour());
+ assertEquals("000", date.getMillisecond());
+ assertEquals("00", date.getMinute());
+ assertEquals("01", date.getMonth());
+ assertEquals("00", date.getSecond());
+ assertEquals("00:00:00Z", date.getTime());
+ assertEquals("1970", date.getYear());
}
}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java b/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java
index ab07d3f..036a4b6 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/DocumentDescriptorReaderTest.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -23,55 +41,46 @@ import java.io.File;
import org.apache.maven.doxia.document.DocumentModel;
import org.apache.maven.plugins.pdf.stubs.FilteringMavenProjectStub;
-
import org.codehaus.plexus.PlexusTestCase;
/**
*
* @author ltheussl
*/
-public class DocumentDescriptorReaderTest
- extends PlexusTestCase
-{
-/**
+public class DocumentDescriptorReaderTest extends PlexusTestCase {
+ /**
* Test of readAndFilterDocumentDescriptor method, of class DocumentDescriptorReader.
* @throws Exception if something happens.
*/
- public void testReaderNoProject()
- throws Exception
- {
+ public void testReaderNoProject() throws Exception {
DocumentDescriptorReader reader = new DocumentDescriptorReader();
- File descriptorFile = new File( testBaseDir() + "src/site/", "model_builder_site.xml" );
- DocumentModel model = reader.readAndFilterDocumentDescriptor( descriptorFile );
- assertNotNull( model );
- assertNull( model.getCover() );
- assertNull( model.getMeta() );
- assertNull( model.getToc() );
+ File descriptorFile = new File(testBaseDir() + "src/site/", "model_builder_site.xml");
+ DocumentModel model = reader.readAndFilterDocumentDescriptor(descriptorFile);
+ assertNotNull(model);
+ assertNull(model.getCover());
+ assertNull(model.getMeta());
+ assertNull(model.getToc());
}
/**
* Test of readAndFilterDocumentDescriptor method, of class DocumentDescriptorReader.
* @throws Exception if something happens.
*/
- public void testFiltering()
- throws Exception
- {
- DocumentDescriptorReader reader = new DocumentDescriptorReader( new FilteringMavenProjectStub() );
- File descriptorFile = new File( testBaseDir() + "src/site/", "pdf_filtering.xml" );
- DocumentModel model = reader.readAndFilterDocumentDescriptor( descriptorFile );
- assertNotNull( model );
- assertNull( model.getCover() );
- assertNotNull( model.getToc() );
- assertEquals( "Table of Contents", model.getToc().getName() );
- assertEquals( 5, model.getToc().getItems().size() );
- assertNotNull( model.getMeta() );
- assertEquals( 0, model.getMeta().getTitle().indexOf(
- "User guide in en of Test filtering version 1.0-SNAPSHOT" ) );
- assertEquals( "vsiveton@apache.org ltheussl@apache.org", model.getMeta().getAuthor() );
+ public void testFiltering() throws Exception {
+ DocumentDescriptorReader reader = new DocumentDescriptorReader(new FilteringMavenProjectStub());
+ File descriptorFile = new File(testBaseDir() + "src/site/", "pdf_filtering.xml");
+ DocumentModel model = reader.readAndFilterDocumentDescriptor(descriptorFile);
+ assertNotNull(model);
+ assertNull(model.getCover());
+ assertNotNull(model.getToc());
+ assertEquals("Table of Contents", model.getToc().getName());
+ assertEquals(5, model.getToc().getItems().size());
+ assertNotNull(model.getMeta());
+ assertEquals(0, model.getMeta().getTitle().indexOf("User guide in en of Test filtering version 1.0-SNAPSHOT"));
+ assertEquals("vsiveton@apache.org ltheussl@apache.org", model.getMeta().getAuthor());
}
- private String testBaseDir()
- {
+ private String testBaseDir() {
return getBasedir() + "/src/test/resources/unit/pdf/";
}
}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java b/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
index bb50bfb..e2f3a9b 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/DocumentModelBuilderTest.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -31,7 +49,6 @@ import org.apache.maven.doxia.document.DocumentTOC;
import org.apache.maven.doxia.site.decoration.DecorationModel;
import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader;
import org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub;
-
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -40,91 +57,79 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
*
* @author ltheussl
*/
-public class DocumentModelBuilderTest
- extends PlexusTestCase
-{
+public class DocumentModelBuilderTest extends PlexusTestCase {
/**
* Test of getDocumentModel method, of class DocumentModelBuilder.
*/
- public void testEmptyDocumentModel()
- {
- DocumentModel model = new DocumentModelBuilder( null ).getDocumentModel();
-
- assertNotNull( model );
- assertNull( model.getModelEncoding() );
- assertEquals( "unnamed", model.getOutputName() );
- assertNotNull( model.getCover() );
- assertNotNull( model.getMeta() );
- assertNotNull( model.getToc() );
+ public void testEmptyDocumentModel() {
+ DocumentModel model = new DocumentModelBuilder(null).getDocumentModel();
+
+ assertNotNull(model);
+ assertNull(model.getModelEncoding());
+ assertEquals("unnamed", model.getOutputName());
+ assertNotNull(model.getCover());
+ assertNotNull(model.getMeta());
+ assertNotNull(model.getToc());
}
/**
* Test of getDocumentModel method, of class DocumentModelBuilder.
*/
- public void testGetDocumentModel()
- {
- DocumentModel model = new DocumentModelBuilder( new ModelBuilderMavenProjectStub() ).getDocumentModel();
+ public void testGetDocumentModel() {
+ DocumentModel model = new DocumentModelBuilder(new ModelBuilderMavenProjectStub()).getDocumentModel();
- assertEquals( "UTF-8", model.getModelEncoding() );
- assertEquals( "Test ArtifactId", model.getOutputName() );
+ assertEquals("UTF-8", model.getModelEncoding());
+ assertEquals("Test ArtifactId", model.getOutputName());
DocumentCover cover = model.getCover();
- assertEquals( "Test Version", cover.getCoverVersion() );
- assertEquals( "Test Name", cover.getProjectName() );
- assertEquals( "Test Name", cover.getCoverTitle() );
- assertEquals( "v. Test Version", cover.getCoverSubTitle() );
- assertEquals( "Test Organization", cover.getCompanyName() );
- assertEquals( 2, cover.getAuthors().size() );
- assertFirstDocumentAuthor(cover.getAuthors().get( 0 ));
+ assertEquals("Test Version", cover.getCoverVersion());
+ assertEquals("Test Name", cover.getProjectName());
+ assertEquals("Test Name", cover.getCoverTitle());
+ assertEquals("v. Test Version", cover.getCoverSubTitle());
+ assertEquals("Test Organization", cover.getCompanyName());
+ assertEquals(2, cover.getAuthors().size());
+ assertFirstDocumentAuthor(cover.getAuthors().get(0));
DocumentMeta meta = model.getMeta();
- assertEquals( "Test Description", meta.getDescription() );
- assertEquals( 2, meta.getAuthors().size() );
- assertFirstDocumentAuthor(meta.getAuthors().get( 0 ));
- assertEquals( "Test Name", meta.getSubject() );
- assertEquals( "Test Name", meta.getTitle() );
+ assertEquals("Test Description", meta.getDescription());
+ assertEquals(2, meta.getAuthors().size());
+ assertFirstDocumentAuthor(meta.getAuthors().get(0));
+ assertEquals("Test Name", meta.getSubject());
+ assertEquals("Test Name", meta.getTitle());
DocumentTOC toc = model.getToc();
- assertEquals( 0, toc.getItems().size() );
+ assertEquals(0, toc.getItems().size());
}
/**
* Test of getDocumentModel method, of class DocumentModelBuilder.
* @throws Exception if something happens.
*/
- public void testGetDocumentModelWithSiteDescriptor()
- throws Exception
- {
- File descriptorFile = new File( testBaseDir() + "src/site/", "model_builder_site.xml" );
- DecorationModel dModel = getDecorationModelFromFile( descriptorFile );
- DocumentModel model =
- new DocumentModelBuilder( new ModelBuilderMavenProjectStub(), dModel ).getDocumentModel();
+ public void testGetDocumentModelWithSiteDescriptor() throws Exception {
+ File descriptorFile = new File(testBaseDir() + "src/site/", "model_builder_site.xml");
+ DecorationModel dModel = getDecorationModelFromFile(descriptorFile);
+ DocumentModel model = new DocumentModelBuilder(new ModelBuilderMavenProjectStub(), dModel).getDocumentModel();
DocumentTOC toc = model.getToc();
- assertEquals( 1, toc.getItems().size() );
- assertEquals( "Intro", toc.getItems().get( 0 ).getName() );
- assertEquals( "index.html", toc.getItems().get( 0 ).getRef() );
+ assertEquals(1, toc.getItems().size());
+ assertEquals("Intro", toc.getItems().get(0).getName());
+ assertEquals("index.html", toc.getItems().get(0).getRef());
}
- private void assertFirstDocumentAuthor( DocumentAuthor author )
- {
- assertEquals( "dev name", author.getName() );
- assertEquals( "dev@email", author.getEmail() );
- assertEquals( "dev broetchengeber", author.getCompanyName() );
- assertEquals( "dev main role, dev second role", author.getPosition() );
+ private void assertFirstDocumentAuthor(DocumentAuthor author) {
+ assertEquals("dev name", author.getName());
+ assertEquals("dev@email", author.getEmail());
+ assertEquals("dev broetchengeber", author.getCompanyName());
+ assertEquals("dev main role, dev second role", author.getPosition());
}
- private DecorationModel getDecorationModelFromFile( File descriptorFile )
- throws IOException, XmlPullParserException
- {
- try ( Reader reader = ReaderFactory.newXmlReader( descriptorFile ) )
- {
- return new DecorationXpp3Reader().read( reader );
+ private DecorationModel getDecorationModelFromFile(File descriptorFile) throws IOException, XmlPullParserException {
+ try (Reader reader = ReaderFactory.newXmlReader(descriptorFile)) {
+ return new DecorationXpp3Reader().read(reader);
}
}
- private String testBaseDir()
- {
+ private String testBaseDir() {
return getBasedir() + "/src/test/resources/unit/pdf/";
}
}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java b/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java
index e6e77ad..bd84848 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/PdfMojoTest.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf;
/*
@@ -19,104 +37,91 @@ package org.apache.maven.plugins.pdf;
* under the License.
*/
+import java.io.File;
+import java.io.Reader;
+
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineUtils;
-import java.io.File;
-import java.io.Reader;
-
/**
* @author ltheussl
*/
-public class PdfMojoTest
- extends AbstractMojoTestCase
-{
+public class PdfMojoTest extends AbstractMojoTestCase {
/**
* Tests the basic functioning of the pdf generation using the FO implementation.
*
*/
- public void testPdfMojo()
- {
- executePdfMojo( "pom.xml", "fo/maven-pdf-plugin-doc.pdf" );
+ public void testPdfMojo() {
+ executePdfMojo("pom.xml", "fo/maven-pdf-plugin-doc.pdf");
}
/**
* Tests the basic functioning of the pdf generation with iText.
*
*/
- public void testITextImpl()
- {
- executePdfMojo( "iText_pom.xml", "itext/maven-pdf-plugin-doc.pdf" );
- }
+ public void testITextImpl() {
+ executePdfMojo("iText_pom.xml", "itext/maven-pdf-plugin-doc.pdf");
+ }
/**
* Tests the basic functioning of the pdf generation using the FO implementation.
*
*/
- public void testPdfMojoNoDocDesriptor()
- {
- executePdfMojo( "no_docdescriptor_pom.xml", "no/unnamed.pdf" );
+ public void testPdfMojoNoDocDesriptor() {
+ executePdfMojo("no_docdescriptor_pom.xml", "no/unnamed.pdf");
}
/**
* @throws Exception if any.
*/
public void _testPdfFilterMojo() // MPDF-78: test desactivated because injection of PlexusContainer fails
- throws Exception
- {
- executePdfMojo( "pom_filtering.xml", "filtering/maven-pdf-plugin-doc-1.0-SNAPSHOT.pdf" );
+ throws Exception {
+ executePdfMojo("pom_filtering.xml", "filtering/maven-pdf-plugin-doc-1.0-SNAPSHOT.pdf");
- File foFile = new File( getBasedir(), "/target/test-output/pdf/filtering/maven-pdf-plugin-doc-1.0-SNAPSHOT.fo" );
- assertTrue( "FO: Fo file not created!", foFile.exists() );
- assertTrue( "FO: Fo file has no content!", foFile.length() > 0 );
+ File foFile = new File(getBasedir(), "/target/test-output/pdf/filtering/maven-pdf-plugin-doc-1.0-SNAPSHOT.fo");
+ assertTrue("FO: Fo file not created!", foFile.exists());
+ assertTrue("FO: Fo file has no content!", foFile.length() > 0);
String foContent;
- try ( Reader reader = ReaderFactory.newXmlReader( foFile ) )
- {
- foContent = IOUtil.toString( reader );
+ try (Reader reader = ReaderFactory.newXmlReader(foFile)) {
+ foContent = IOUtil.toString(reader);
}
// ${pom.name}
- assertTrue( foContent.indexOf( "Test filtering" ) > 0 );
- assertTrue( foContent.indexOf( "1.0-SNAPSHOT" ) > 0 );
+ assertTrue(foContent.indexOf("Test filtering") > 0);
+ assertTrue(foContent.indexOf("1.0-SNAPSHOT") > 0);
// env ${M2_HOME}
- String m2Home = CommandLineUtils.getSystemEnvVars().getProperty( "M2_HOME" );
- if ( StringUtils.isNotEmpty( m2Home ) )
- {
- assertTrue( foContent.indexOf( m2Home ) > 0 );
+ String m2Home = CommandLineUtils.getSystemEnvVars().getProperty("M2_HOME");
+ if (StringUtils.isNotEmpty(m2Home)) {
+ assertTrue(foContent.indexOf(m2Home) > 0);
}
// ${project.developers[0].email}
- assertTrue( foContent.indexOf( "vsiveton@apache.org ltheussl@apache.org" ) > 0 );
+ assertTrue(foContent.indexOf("vsiveton@apache.org ltheussl@apache.org") > 0);
// ${date}
// TODO: this might fail on NewYear's eve! :)
- assertTrue( foContent.indexOf( new DateBean().getDate() ) > 0 );
+ assertTrue(foContent.indexOf(new DateBean().getDate()) > 0);
}
- protected PdfMojo lookupPdfMojo( String pom )
- throws Exception
- {
- File testPom = new File( getBasedir(), "target/test-classes/unit/pdf/" + pom );
- assertTrue( "testPom does not exist!", testPom.exists() );
- PdfMojo mojo = (PdfMojo) lookupMojo( "pdf", testPom );
- assertNotNull( "pdf mojo not found!", mojo );
+ protected PdfMojo lookupPdfMojo(String pom) throws Exception {
+ File testPom = new File(getBasedir(), "target/test-classes/unit/pdf/" + pom);
+ assertTrue("testPom does not exist!", testPom.exists());
+ PdfMojo mojo = (PdfMojo) lookupMojo("pdf", testPom);
+ assertNotNull("pdf mojo not found!", mojo);
return mojo;
}
- protected File prepareOutputPdf( String filename )
- {
- File pdfFile = new File( getBasedir(), "target/test-output/pdf/" + filename );
- if ( pdfFile.exists() )
- {
+ protected File prepareOutputPdf(String filename) {
+ File pdfFile = new File(getBasedir(), "target/test-output/pdf/" + filename);
+ if (pdfFile.exists()) {
pdfFile.delete();
}
return pdfFile;
}
- protected void executePdfMojo( String pom, String pdfFilename )
- {
+ protected void executePdfMojo(String pom, String pdfFilename) {
// MPDF-78: test desactivated because injection of PlexusContainer fails
return;
/*
@@ -129,4 +134,4 @@ public class PdfMojoTest
assertTrue( "FO: Pdf file has no content!", pdfFile.length() > 0 );
*/
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java
index 1975fb9..a8f0b3b 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/DefaultMavenProjectStub.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf.stubs;
/*
@@ -35,48 +53,38 @@ import org.codehaus.plexus.util.ReaderFactory;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-public class DefaultMavenProjectStub
- extends MavenProjectStub
-{
- public DefaultMavenProjectStub()
- {
+public class DefaultMavenProjectStub extends MavenProjectStub {
+ public DefaultMavenProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
- try ( Reader reader = ReaderFactory.newXmlReader( getFile() ) )
- {
- final Model model = pomReader.read( reader );
- setModel( model );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e );
+ try (Reader reader = ReaderFactory.newXmlReader(getFile())) {
+ final Model model = pomReader.read(reader);
+ setModel(model);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
/** {@inheritDoc} */
- public String getName()
- {
+ public String getName() {
return getModel().getName();
}
/** {@inheritDoc} */
- public File getBasedir()
- {
- return new File( super.getBasedir(), "target/test-classes/unit/pdf/" );
+ public File getBasedir() {
+ return new File(super.getBasedir(), "target/test-classes/unit/pdf/");
}
/** {@inheritDoc} */
- public List<ArtifactRepository> getRemoteArtifactRepositories()
- {
- ArtifactRepository repository = new MavenArtifactRepository( "central", "https://repo.maven.apache.org/maven2",
- new DefaultRepositoryLayout(), null, null );
+ public List<ArtifactRepository> getRemoteArtifactRepositories() {
+ ArtifactRepository repository = new MavenArtifactRepository(
+ "central", "https://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), null, null);
- return Collections.singletonList( repository );
+ return Collections.singletonList(repository);
}
/** {@inheritDoc} */
- public File getFile()
- {
- return new File( getBasedir(), "pom.xml" );
+ public File getFile() {
+ return new File(getBasedir(), "pom.xml");
}
}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java
index 27467b5..bbd4dba 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/FilteringMavenProjectStub.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf.stubs;
/*
@@ -37,66 +55,52 @@ import org.codehaus.plexus.util.ReaderFactory;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-public class FilteringMavenProjectStub
- extends MavenProjectStub
-{
- public FilteringMavenProjectStub()
- {
+public class FilteringMavenProjectStub extends MavenProjectStub {
+ public FilteringMavenProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
- try ( Reader reader = ReaderFactory.newXmlReader( getFile() ) )
- {
- final Model model = pomReader.read( reader );
- setModel( model );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e );
+ try (Reader reader = ReaderFactory.newXmlReader(getFile())) {
+ final Model model = pomReader.read(reader);
+ setModel(model);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
/** {@inheritDoc} */
- public String getName()
- {
+ public String getName() {
return getModel().getName();
}
/** {@inheritDoc} */
- public String getVersion()
- {
+ public String getVersion() {
return getModel().getVersion();
}
/** {@inheritDoc} */
- public File getBasedir()
- {
- return new File( super.getBasedir(), "target/test-classes/unit/pdf/" );
+ public File getBasedir() {
+ return new File(super.getBasedir(), "target/test-classes/unit/pdf/");
}
/** {@inheritDoc} */
- public List<Developer> getDevelopers()
- {
+ public List<Developer> getDevelopers() {
return getModel().getDevelopers();
}
/** {@inheritDoc} */
- public Properties getProperties()
- {
+ public Properties getProperties() {
return getModel().getProperties();
}
/** {@inheritDoc} */
- public List<ArtifactRepository> getRemoteArtifactRepositories()
- {
- ArtifactRepository repository =
- new MavenArtifactRepository( "central", "https://repo.maven.apache.org/maven2",
- new DefaultRepositoryLayout(), null,null );
+ public List<ArtifactRepository> getRemoteArtifactRepositories() {
+ ArtifactRepository repository = new MavenArtifactRepository(
+ "central", "https://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), null, null);
- return Collections.singletonList( repository );
+ return Collections.singletonList(repository);
}
/** {@inheritDoc} */
- public File getFile()
- {
- return new File( getBasedir(), "pom_filtering.xml" );
+ public File getFile() {
+ return new File(getBasedir(), "pom_filtering.xml");
}
}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java
index b988477..e67b3e8 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/ITextMavenProjectStub.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf.stubs;
/*
@@ -35,43 +53,33 @@ import org.codehaus.plexus.util.ReaderFactory;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-public class ITextMavenProjectStub
- extends MavenProjectStub
-{
- public ITextMavenProjectStub()
- {
+public class ITextMavenProjectStub extends MavenProjectStub {
+ public ITextMavenProjectStub() {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
- try ( Reader reader = ReaderFactory.newXmlReader( getFile() ) )
- {
- final Model model = pomReader.read( reader );
- setModel( model );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e );
+ try (Reader reader = ReaderFactory.newXmlReader(getFile())) {
+ final Model model = pomReader.read(reader);
+ setModel(model);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
/** {@inheritDoc} */
- public File getBasedir()
- {
- return new File( super.getBasedir(), "target/test-classes/unit/pdf/" );
+ public File getBasedir() {
+ return new File(super.getBasedir(), "target/test-classes/unit/pdf/");
}
/** {@inheritDoc} */
- public List<ArtifactRepository> getRemoteArtifactRepositories()
- {
- ArtifactRepository repository =
- new MavenArtifactRepository( "central", "https://repo.maven.apache.org/maven2",
- new DefaultRepositoryLayout(), null, null );
+ public List<ArtifactRepository> getRemoteArtifactRepositories() {
+ ArtifactRepository repository = new MavenArtifactRepository(
+ "central", "https://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), null, null);
- return Collections.singletonList( repository );
+ return Collections.singletonList(repository);
}
/** {@inheritDoc} */
- public File getFile()
- {
- return new File( getBasedir(), "iText_pom.xml" );
+ public File getFile() {
+ return new File(getBasedir(), "iText_pom.xml");
}
}
diff --git a/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java b/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
index 0883c6c..d3190b2 100644
--- a/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/pdf/stubs/ModelBuilderMavenProjectStub.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.maven.plugins.pdf.stubs;
/*
@@ -22,82 +40,69 @@ package org.apache.maven.plugins.pdf.stubs;
import java.io.File;
import java.util.List;
+import org.apache.commons.io.input.XmlStreamReader;
import org.apache.maven.model.Developer;
import org.apache.maven.model.Model;
import org.apache.maven.model.Organization;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.apache.commons.io.input.XmlStreamReader;
/**
* @author ltheussl
*/
-public class ModelBuilderMavenProjectStub
- extends MavenProjectStub
-{
+public class ModelBuilderMavenProjectStub extends MavenProjectStub {
/**
* Stub to test the DocumentModelBuilder.
*/
- public ModelBuilderMavenProjectStub()
- {
- try ( XmlStreamReader reader = new XmlStreamReader( getFile() ) )
- {
- final Model model = new MavenXpp3Reader().read( reader );
- setModel( model );
+ public ModelBuilderMavenProjectStub() {
+ try (XmlStreamReader reader = new XmlStreamReader(getFile())) {
+ final Model model = new MavenXpp3Reader().read(reader);
+ setModel(model);
- setGroupId( model.getGroupId() );
- setArtifactId( model.getArtifactId() );
- setVersion( model.getVersion() );
- setName( model.getName() );
- setDescription( model.getDescription() );
- setDevelopers( model.getDevelopers() );
- setOrganization( model.getOrganization() );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e );
+ setGroupId(model.getGroupId());
+ setArtifactId(model.getArtifactId());
+ setVersion(model.getVersion());
+ setName(model.getName());
+ setDescription(model.getDescription());
+ setDevelopers(model.getDevelopers());
+ setOrganization(model.getOrganization());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
/** {@inheritDoc} */
- public File getBasedir()
- {
- return new File( super.getBasedir(), "target/test-classes/unit/pdf/" );
+ public File getBasedir() {
+ return new File(super.getBasedir(), "target/test-classes/unit/pdf/");
}
/** {@inheritDoc} */
- public void addDeveloper( Developer developer )
- {
- getModel().addDeveloper( developer );
+ public void addDeveloper(Developer developer) {
+ getModel().addDeveloper(developer);
}
/** {@inheritDoc} */
- public List<Developer> getDevelopers()
- {
+ public List<Developer> getDevelopers() {
return getModel().getDevelopers();
}
/** {@inheritDoc} */
- public Organization getOrganization()
- {
+ public Organization getOrganization() {
return getModel().getOrganization();
}
/** {@inheritDoc} */
- public void setDevelopers( List<Developer> list )
- {
- getModel().setDevelopers( list );
+ public void setDevelopers(List<Developer> list) {
+ getModel().setDevelopers(list);
}
/** {@inheritDoc} */
- public void setOrganization( Organization organization )
- {
- getModel().setOrganization( organization );
+ public void setOrganization(Organization organization) {
+ getModel().setOrganization(organization);
}
/** {@inheritDoc} */
- public File getFile()
- {
- return new File( getBasedir(), "pom_model_builder.xml" );
+ public File getFile() {
+ return new File(getBasedir(), "pom_model_builder.xml");
}
}