You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2023/01/31 16:35:33 UTC
[maven-doxia-sitetools] branch master updated: [DOXIASITETOOLS-286] Upgrade Parent to 39
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git
The following commit(s) were added to refs/heads/master by this push:
new 227317e [DOXIASITETOOLS-286] Upgrade Parent to 39
227317e is described below
commit 227317e1a749d49c988e3da45fdb4006fe4eba57
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Jan 31 17:34:49 2023 +0100
[DOXIASITETOOLS-286] Upgrade Parent to 39
---
.../doxia/site/decoration/DecorationUtils.java | 66 +-
.../DecorationModelInheritanceAssembler.java | 12 +-
...DefaultDecorationModelInheritanceAssembler.java | 373 +++---
.../decoration/inheritance/URIPathDescriptor.java | 129 +-
.../doxia/site/decoration/DecorationUtilsTest.java | 78 +-
.../DecorationModelInheritanceAssemblerTest.java | 975 ++++++++-------
.../inheritance/URIPathDescriptorTest.java | 346 +++---
.../apache/maven/doxia/tools/DefaultSiteTool.java | 1251 ++++++++------------
.../apache/maven/doxia/tools/ReportComparator.java | 19 +-
.../org/apache/maven/doxia/tools/SiteTool.java | 52 +-
.../maven/doxia/tools/SiteToolException.java | 22 +-
.../maven/doxia/tools/DefaultSiteToolTest.java | 81 +-
.../org/apache/maven/doxia/tools/SiteToolTest.java | 558 +++++----
.../maven/doxia/tools/stubs/MavenProjectStub.java | 583 +++------
.../tools/stubs/SiteToolMavenProjectStub.java | 98 +-
.../doxia/siterenderer/DefaultSiteRenderer.java | 926 ++++++---------
.../maven/doxia/siterenderer/DocumentContent.java | 6 +-
.../maven/doxia/siterenderer/DocumentRenderer.java | 14 +-
.../doxia/siterenderer/DoxiaDocumentRenderer.java | 30 +-
.../siterenderer/ExtraDoxiaModuleReference.java | 15 +-
.../apache/maven/doxia/siterenderer/Renderer.java | 31 +-
.../doxia/siterenderer/RendererException.java | 17 +-
.../maven/doxia/siterenderer/RenderingContext.java | 103 +-
.../doxia/siterenderer/SiteRenderingContext.java | 142 +--
.../doxia/siterenderer/sink/SiteRendererSink.java | 113 +-
.../maven/doxia/siterenderer/AbstractVerifier.java | 31 +-
.../maven/doxia/siterenderer/AptVerifier.java | 123 +-
.../doxia/siterenderer/AttributesVerifier.java | 160 ++-
.../maven/doxia/siterenderer/CommentsVerifier.java | 18 +-
.../siterenderer/DefaultSiteRendererTest.java | 475 +++-----
.../maven/doxia/siterenderer/EntitiesVerifier.java | 94 +-
.../maven/doxia/siterenderer/FaqVerifier.java | 126 +-
.../doxia/siterenderer/JavascriptVerifier.java | 73 +-
.../doxia/siterenderer/MultipleBlockVerifier.java | 68 +-
.../doxia/siterenderer/NestedItemsVerifier.java | 286 ++---
.../doxia/siterenderer/RenderingContextTest.java | 49 +-
pom.xml | 2 +-
37 files changed, 3342 insertions(+), 4203 deletions(-)
diff --git a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/DecorationUtils.java b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/DecorationUtils.java
index 20dd732..1afe0c0 100644
--- a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/DecorationUtils.java
+++ b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/DecorationUtils.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.site.decoration;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,44 +16,37 @@ package org.apache.maven.doxia.site.decoration;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.site.decoration;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* Decoration model utilities.
- *
+ *
* @since 1.7
*/
-public class DecorationUtils
-{
- public static boolean isLink( String href )
- {
- return StringUtils.isNotBlank( href )
- && ( startsWithAnyIgnoreCase( href, "http:/", "https:/", "ftp:/", "mailto:", "file:/" )
- || href.contains( "://" ) );
+public class DecorationUtils {
+ public static boolean isLink(String href) {
+ return StringUtils.isNotBlank(href)
+ && (startsWithAnyIgnoreCase(href, "http:/", "https:/", "ftp:/", "mailto:", "file:/")
+ || href.contains("://"));
}
- private static boolean startsWithIgnoreCase( String str, String prefix )
- {
- if ( str == null || prefix == null )
- {
- return ( str == null && prefix == null );
+ private static boolean startsWithIgnoreCase(String str, String prefix) {
+ if (str == null || prefix == null) {
+ return (str == null && prefix == null);
}
- if ( prefix.length() > str.length() )
- {
+ if (prefix.length() > str.length()) {
return false;
}
- return str.regionMatches( true, 0, prefix, 0, prefix.length() );
+ return str.regionMatches(true, 0, prefix, 0, prefix.length());
}
- public static boolean startsWithAnyIgnoreCase( String string, String... searchStrings )
- {
- for ( int i = 0; i < searchStrings.length; i++ )
- {
+ public static boolean startsWithAnyIgnoreCase(String string, String... searchStrings) {
+ for (int i = 0; i < searchStrings.length; i++) {
String searchString = searchStrings[i];
- if ( startsWithIgnoreCase( string, searchString ) )
- {
+ if (startsWithIgnoreCase(string, searchString)) {
return true;
}
}
@@ -70,16 +61,13 @@ public class DecorationUtils
* @return <code>null</code> if any element in the path does not exist
* @since 1.8
*/
- public static Xpp3Dom getCustomChild( Xpp3Dom custom, String path )
- {
- String[] elements = path.split( "\\." );
- for ( String element : elements )
- {
- if ( custom == null )
- {
+ public static Xpp3Dom getCustomChild(Xpp3Dom custom, String path) {
+ String[] elements = path.split("\\.");
+ for (String element : elements) {
+ if (custom == null) {
return null;
}
- custom = custom.getChild( element );
+ custom = custom.getChild(element);
}
return custom;
}
@@ -92,10 +80,9 @@ public class DecorationUtils
* @return the element value or <code>null</code> if any element in the path does not exist
* @since 1.8
*/
- public static String getCustomValue( Xpp3Dom custom, String path )
- {
- custom = getCustomChild( custom, path );
- return ( custom == null ) ? null : custom.getValue();
+ public static String getCustomValue(Xpp3Dom custom, String path) {
+ custom = getCustomChild(custom, path);
+ return (custom == null) ? null : custom.getValue();
}
/**
@@ -107,9 +94,8 @@ public class DecorationUtils
* @return the element value or the default value if any element in the path does not exist
* @since 1.8
*/
- public static String getCustomValue( Xpp3Dom custom, String path, String defaultValue )
- {
- custom = getCustomChild( custom, path );
- return ( custom == null ) ? defaultValue : custom.getValue();
+ public static String getCustomValue(Xpp3Dom custom, String path, String defaultValue) {
+ custom = getCustomChild(custom, path);
+ return (custom == null) ? defaultValue : custom.getValue();
}
}
diff --git a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssembler.java b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssembler.java
index aa1de8e..4a022db 100644
--- a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssembler.java
+++ b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssembler.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.site.decoration.inheritance;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.site.decoration.inheritance;
import org.apache.maven.doxia.site.decoration.DecorationModel;
@@ -26,8 +25,7 @@ import org.apache.maven.doxia.site.decoration.DecorationModel;
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
-public interface DecorationModelInheritanceAssembler
-{
+public interface DecorationModelInheritanceAssembler {
/**
* Manage inheritance of the decoration model between a parent and child.
*
@@ -49,8 +47,8 @@ public interface DecorationModelInheritanceAssembler
* May be null, in which case relative links inherited from the parent
* will not be resolved in the merged child.
*/
- void assembleModelInheritance( String name, DecorationModel child, DecorationModel parent,
- String childBaseUrl, String parentBaseUrl );
+ void assembleModelInheritance(
+ String name, DecorationModel child, DecorationModel parent, String childBaseUrl, String parentBaseUrl);
/**
* Resolve relative paths for a DecorationModel given a base URL.
@@ -65,5 +63,5 @@ public interface DecorationModelInheritanceAssembler
* @param baseUrl the base URL.
* May be null in which case the decoration model is unchanged.
*/
- void resolvePaths( DecorationModel decoration, String baseUrl );
+ void resolvePaths(DecorationModel decoration, String baseUrl);
}
diff --git a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
index 6b59afe..fb4f1b7 100644
--- a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
+++ b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.site.decoration.inheritance;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.site.decoration.inheritance;
import javax.inject.Named;
import javax.inject.Singleton;
@@ -32,7 +31,6 @@ import org.apache.maven.doxia.site.decoration.LinkItem;
import org.apache.maven.doxia.site.decoration.Logo;
import org.apache.maven.doxia.site.decoration.Menu;
import org.apache.maven.doxia.site.decoration.MenuItem;
-
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
@@ -43,119 +41,96 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
*/
@Singleton
@Named
-public class DefaultDecorationModelInheritanceAssembler
- implements DecorationModelInheritanceAssembler
-{
+public class DefaultDecorationModelInheritanceAssembler implements DecorationModelInheritanceAssembler {
/** {@inheritDoc} */
- public void assembleModelInheritance( String name, DecorationModel child, DecorationModel parent,
- String childBaseUrl, String parentBaseUrl )
- {
- if ( parent == null || !child.isMergeParent() )
- {
+ public void assembleModelInheritance(
+ String name, DecorationModel child, DecorationModel parent, String childBaseUrl, String parentBaseUrl) {
+ if (parent == null || !child.isMergeParent()) {
return;
}
- child.setCombineSelf( parent.getCombineSelf() );
+ child.setCombineSelf(parent.getCombineSelf());
- URLRebaser urlContainer = new URLRebaser( parentBaseUrl, childBaseUrl );
+ URLRebaser urlContainer = new URLRebaser(parentBaseUrl, childBaseUrl);
- if ( child.getBannerLeft() == null && parent.getBannerLeft() != null )
- {
- child.setBannerLeft( parent.getBannerLeft().clone() );
- rebaseBannerPaths( child.getBannerLeft(), urlContainer );
+ if (child.getBannerLeft() == null && parent.getBannerLeft() != null) {
+ child.setBannerLeft(parent.getBannerLeft().clone());
+ rebaseBannerPaths(child.getBannerLeft(), urlContainer);
}
- if ( child.getBannerRight() == null && parent.getBannerRight() != null )
- {
- child.setBannerRight( parent.getBannerRight().clone() );
- rebaseBannerPaths( child.getBannerRight(), urlContainer );
+ if (child.getBannerRight() == null && parent.getBannerRight() != null) {
+ child.setBannerRight(parent.getBannerRight().clone());
+ rebaseBannerPaths(child.getBannerRight(), urlContainer);
}
- if ( child.isDefaultPublishDate() && parent.getPublishDate() != null )
- {
- child.setPublishDate( parent.getPublishDate().clone() );
+ if (child.isDefaultPublishDate() && parent.getPublishDate() != null) {
+ child.setPublishDate(parent.getPublishDate().clone());
}
- if ( child.isDefaultVersion() && parent.getVersion() != null )
- {
- child.setVersion( parent.getVersion().clone() );
+ if (child.isDefaultVersion() && parent.getVersion() != null) {
+ child.setVersion(parent.getVersion().clone());
}
- if ( child.getEdit() == null && parent.getEdit() != null )
- {
- child.setEdit( parent.getEdit() );
+ if (child.getEdit() == null && parent.getEdit() != null) {
+ child.setEdit(parent.getEdit());
}
- if ( child.getSkin() == null && parent.getSkin() != null )
- {
- child.setSkin( parent.getSkin().clone() );
+ if (child.getSkin() == null && parent.getSkin() != null) {
+ child.setSkin(parent.getSkin().clone());
}
- child.setPoweredBy( mergePoweredByLists( child.getPoweredBy(), parent.getPoweredBy(), urlContainer ) );
+ child.setPoweredBy(mergePoweredByLists(child.getPoweredBy(), parent.getPoweredBy(), urlContainer));
- if ( parent.getLastModified() > child.getLastModified() )
- {
- child.setLastModified( parent.getLastModified() );
+ if (parent.getLastModified() > child.getLastModified()) {
+ child.setLastModified(parent.getLastModified());
}
- if ( child.getGoogleAdSenseClient() == null && parent.getGoogleAdSenseClient() != null )
- {
- child.setGoogleAdSenseClient( parent.getGoogleAdSenseClient() );
+ if (child.getGoogleAdSenseClient() == null && parent.getGoogleAdSenseClient() != null) {
+ child.setGoogleAdSenseClient(parent.getGoogleAdSenseClient());
}
- if ( child.getGoogleAdSenseSlot() == null && parent.getGoogleAdSenseSlot() != null )
- {
- child.setGoogleAdSenseSlot( parent.getGoogleAdSenseSlot() );
+ if (child.getGoogleAdSenseSlot() == null && parent.getGoogleAdSenseSlot() != null) {
+ child.setGoogleAdSenseSlot(parent.getGoogleAdSenseSlot());
}
- if ( child.getGoogleAnalyticsAccountId() == null && parent.getGoogleAnalyticsAccountId() != null )
- {
- child.setGoogleAnalyticsAccountId( parent.getGoogleAnalyticsAccountId() );
+ if (child.getGoogleAnalyticsAccountId() == null && parent.getGoogleAnalyticsAccountId() != null) {
+ child.setGoogleAnalyticsAccountId(parent.getGoogleAnalyticsAccountId());
}
- assembleBodyInheritance( name, child, parent, urlContainer );
+ assembleBodyInheritance(name, child, parent, urlContainer);
- assembleCustomInheritance( child, parent );
+ assembleCustomInheritance(child, parent);
}
/** {@inheritDoc} */
- public void resolvePaths( final DecorationModel decoration, final String baseUrl )
- {
- if ( baseUrl == null )
- {
+ public void resolvePaths(final DecorationModel decoration, final String baseUrl) {
+ if (baseUrl == null) {
return;
}
- if ( decoration.getBannerLeft() != null )
- {
- relativizeBannerPaths( decoration.getBannerLeft(), baseUrl );
+ if (decoration.getBannerLeft() != null) {
+ relativizeBannerPaths(decoration.getBannerLeft(), baseUrl);
}
- if ( decoration.getBannerRight() != null )
- {
- relativizeBannerPaths( decoration.getBannerRight(), baseUrl );
+ if (decoration.getBannerRight() != null) {
+ relativizeBannerPaths(decoration.getBannerRight(), baseUrl);
}
- for ( Logo logo : decoration.getPoweredBy() )
- {
- relativizeLogoPaths( logo, baseUrl );
+ for (Logo logo : decoration.getPoweredBy()) {
+ relativizeLogoPaths(logo, baseUrl);
}
- if ( decoration.getBody() != null )
- {
- for ( LinkItem linkItem : decoration.getBody().getLinks() )
- {
- relativizeLinkItemPaths( linkItem, baseUrl );
+ if (decoration.getBody() != null) {
+ for (LinkItem linkItem : decoration.getBody().getLinks()) {
+ relativizeLinkItemPaths(linkItem, baseUrl);
}
- for ( LinkItem linkItem : decoration.getBody().getBreadcrumbs() )
- {
- relativizeLinkItemPaths( linkItem, baseUrl );
+ for (LinkItem linkItem : decoration.getBody().getBreadcrumbs()) {
+ relativizeLinkItemPaths(linkItem, baseUrl);
}
- for ( Menu menu : decoration.getBody().getMenus() )
- {
- relativizeMenuPaths( menu.getItems(), baseUrl );
+ for (Menu menu : decoration.getBody().getMenus()) {
+ relativizeMenuPaths(menu.getItems(), baseUrl);
}
}
}
@@ -167,175 +142,148 @@ public class DefaultDecorationModelInheritanceAssembler
* @param banner
* @param baseUrl
*/
- private void relativizeBannerPaths( final Banner banner, final String baseUrl )
- {
+ private void relativizeBannerPaths(final Banner banner, final String baseUrl) {
// banner has been checked to be not null, both href and src may be empty or null
- banner.setHref( relativizeLink( banner.getHref(), baseUrl ) );
- banner.setSrc( relativizeLink( banner.getSrc(), baseUrl ) );
+ banner.setHref(relativizeLink(banner.getHref(), baseUrl));
+ banner.setSrc(relativizeLink(banner.getSrc(), baseUrl));
}
- private void rebaseBannerPaths( final Banner banner, final URLRebaser urlContainer )
- {
- if ( banner.getHref() != null ) // it may be empty
+ private void rebaseBannerPaths(final Banner banner, final URLRebaser urlContainer) {
+ if (banner.getHref() != null) // it may be empty
{
- banner.setHref( urlContainer.rebaseLink( banner.getHref() ) );
+ banner.setHref(urlContainer.rebaseLink(banner.getHref()));
}
- if ( banner.getSrc() != null )
- {
- banner.setSrc( urlContainer.rebaseLink( banner.getSrc() ) );
+ if (banner.getSrc() != null) {
+ banner.setSrc(urlContainer.rebaseLink(banner.getSrc()));
}
}
- private void assembleCustomInheritance( final DecorationModel child, final DecorationModel parent )
- {
- if ( child.getCustom() == null )
- {
- child.setCustom( parent.getCustom() );
- }
- else
- {
- child.setCustom( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) child.getCustom(), (Xpp3Dom) parent.getCustom() ) );
+ private void assembleCustomInheritance(final DecorationModel child, final DecorationModel parent) {
+ if (child.getCustom() == null) {
+ child.setCustom(parent.getCustom());
+ } else {
+ child.setCustom(Xpp3Dom.mergeXpp3Dom((Xpp3Dom) child.getCustom(), (Xpp3Dom) parent.getCustom()));
}
}
- private void assembleBodyInheritance( final String name, final DecorationModel child, final DecorationModel parent,
- final URLRebaser urlContainer )
- {
+ private void assembleBodyInheritance(
+ final String name,
+ final DecorationModel child,
+ final DecorationModel parent,
+ final URLRebaser urlContainer) {
Body cBody = child.getBody();
Body pBody = parent.getBody();
- if ( cBody != null || pBody != null )
- {
- if ( cBody == null )
- {
+ if (cBody != null || pBody != null) {
+ if (cBody == null) {
cBody = new Body();
- child.setBody( cBody );
+ child.setBody(cBody);
}
- if ( pBody == null )
- {
+ if (pBody == null) {
pBody = new Body();
}
- if ( cBody.getHead() == null && pBody.getHead() != null )
- {
- cBody.setHead( pBody.getHead() );
+ if (cBody.getHead() == null && pBody.getHead() != null) {
+ cBody.setHead(pBody.getHead());
}
- cBody.setLinks( mergeLinkItemLists( cBody.getLinks(), pBody.getLinks(), urlContainer, false ) );
+ cBody.setLinks(mergeLinkItemLists(cBody.getLinks(), pBody.getLinks(), urlContainer, false));
- if ( cBody.getBreadcrumbs().isEmpty() && !pBody.getBreadcrumbs().isEmpty() )
- {
+ if (cBody.getBreadcrumbs().isEmpty() && !pBody.getBreadcrumbs().isEmpty()) {
LinkItem breadcrumb = new LinkItem();
- breadcrumb.setName( name );
- breadcrumb.setHref( "index.html" );
- cBody.getBreadcrumbs().add( breadcrumb );
+ breadcrumb.setName(name);
+ breadcrumb.setHref("index.html");
+ cBody.getBreadcrumbs().add(breadcrumb);
}
- cBody.setBreadcrumbs( mergeLinkItemLists( cBody.getBreadcrumbs(), pBody.getBreadcrumbs(), urlContainer,
- true ) );
+ cBody.setBreadcrumbs(
+ mergeLinkItemLists(cBody.getBreadcrumbs(), pBody.getBreadcrumbs(), urlContainer, true));
- cBody.setMenus( mergeMenus( cBody.getMenus(), pBody.getMenus(), urlContainer ) );
+ cBody.setMenus(mergeMenus(cBody.getMenus(), pBody.getMenus(), urlContainer));
- if ( cBody.getFooter() == null && pBody.getFooter() != null )
- {
- cBody.setFooter( pBody.getFooter() );
+ if (cBody.getFooter() == null && pBody.getFooter() != null) {
+ cBody.setFooter(pBody.getFooter());
}
}
}
- private List<Menu> mergeMenus( final List<Menu> childMenus, final List<Menu> parentMenus,
- final URLRebaser urlContainer )
- {
- List<Menu> menus = new ArrayList<Menu>( childMenus.size() + parentMenus.size() );
+ private List<Menu> mergeMenus(
+ final List<Menu> childMenus, final List<Menu> parentMenus, final URLRebaser urlContainer) {
+ List<Menu> menus = new ArrayList<Menu>(childMenus.size() + parentMenus.size());
- for ( Menu menu : childMenus )
- {
- menus.add( menu );
+ for (Menu menu : childMenus) {
+ menus.add(menu);
}
int topCounter = 0;
- for ( Menu menu : parentMenus )
- {
- if ( "top".equals( menu.getInherit() ) )
- {
+ for (Menu menu : parentMenus) {
+ if ("top".equals(menu.getInherit())) {
final Menu clone = menu.clone();
- rebaseMenuPaths( clone.getItems(), urlContainer );
+ rebaseMenuPaths(clone.getItems(), urlContainer);
- menus.add( topCounter, clone );
+ menus.add(topCounter, clone);
topCounter++;
- }
- else if ( "bottom".equals( menu.getInherit() ) )
- {
+ } else if ("bottom".equals(menu.getInherit())) {
final Menu clone = menu.clone();
- rebaseMenuPaths( clone.getItems(), urlContainer );
+ rebaseMenuPaths(clone.getItems(), urlContainer);
- menus.add( clone );
+ menus.add(clone);
}
}
return menus;
}
- private void relativizeMenuPaths( final List<MenuItem> items, final String baseUrl )
- {
- for ( MenuItem item : items )
- {
- relativizeLinkItemPaths( item, baseUrl );
- relativizeMenuPaths( item.getItems(), baseUrl );
+ private void relativizeMenuPaths(final List<MenuItem> items, final String baseUrl) {
+ for (MenuItem item : items) {
+ relativizeLinkItemPaths(item, baseUrl);
+ relativizeMenuPaths(item.getItems(), baseUrl);
}
}
- private void rebaseMenuPaths( final List<MenuItem> items, final URLRebaser urlContainer )
- {
- for ( MenuItem item : items )
- {
- rebaseLinkItemPaths( item, urlContainer );
- rebaseMenuPaths( item.getItems(), urlContainer );
+ private void rebaseMenuPaths(final List<MenuItem> items, final URLRebaser urlContainer) {
+ for (MenuItem item : items) {
+ rebaseLinkItemPaths(item, urlContainer);
+ rebaseMenuPaths(item.getItems(), urlContainer);
}
}
- private void relativizeLinkItemPaths( final LinkItem item, final String baseUrl )
- {
- item.setHref( relativizeLink( item.getHref(), baseUrl ) );
+ private void relativizeLinkItemPaths(final LinkItem item, final String baseUrl) {
+ item.setHref(relativizeLink(item.getHref(), baseUrl));
}
- private void rebaseLinkItemPaths( final LinkItem item, final URLRebaser urlContainer )
- {
- item.setHref( urlContainer.rebaseLink( item.getHref() ) );
+ private void rebaseLinkItemPaths(final LinkItem item, final URLRebaser urlContainer) {
+ item.setHref(urlContainer.rebaseLink(item.getHref()));
}
- private void relativizeLogoPaths( final Logo logo, final String baseUrl )
- {
- logo.setImg( relativizeLink( logo.getImg(), baseUrl ) );
- relativizeLinkItemPaths( logo, baseUrl );
+ private void relativizeLogoPaths(final Logo logo, final String baseUrl) {
+ logo.setImg(relativizeLink(logo.getImg(), baseUrl));
+ relativizeLinkItemPaths(logo, baseUrl);
}
- private void rebaseLogoPaths( final Logo logo, final URLRebaser urlContainer )
- {
- logo.setImg( urlContainer.rebaseLink( logo.getImg() ) );
- rebaseLinkItemPaths( logo, urlContainer );
+ private void rebaseLogoPaths(final Logo logo, final URLRebaser urlContainer) {
+ logo.setImg(urlContainer.rebaseLink(logo.getImg()));
+ rebaseLinkItemPaths(logo, urlContainer);
}
- private List<LinkItem> mergeLinkItemLists( final List<LinkItem> childList, final List<LinkItem> parentList,
- final URLRebaser urlContainer, boolean cutParentAfterDuplicate )
- {
- List<LinkItem> items = new ArrayList<LinkItem>( childList.size() + parentList.size() );
+ private List<LinkItem> mergeLinkItemLists(
+ final List<LinkItem> childList,
+ final List<LinkItem> parentList,
+ final URLRebaser urlContainer,
+ boolean cutParentAfterDuplicate) {
+ List<LinkItem> items = new ArrayList<LinkItem>(childList.size() + parentList.size());
- for ( LinkItem item : parentList )
- {
- if ( !items.contains( item ) && !childList.contains( item ) )
- {
+ for (LinkItem item : parentList) {
+ if (!items.contains(item) && !childList.contains(item)) {
final LinkItem clone = item.clone();
- rebaseLinkItemPaths( clone, urlContainer );
+ rebaseLinkItemPaths(clone, urlContainer);
- items.add( clone );
- }
- else if ( cutParentAfterDuplicate )
- {
+ items.add(clone);
+ } else if (cutParentAfterDuplicate) {
// if a parent item is found in child, ignore next items (case for breadcrumbs)
// merge ( "B > E", "A > B > C > D" ) -> "A > B > E" (notice missing "C > D")
// see https://issues.apache.org/jira/browse/DOXIASITETOOLS-62
@@ -343,39 +291,32 @@ public class DefaultDecorationModelInheritanceAssembler
}
}
- for ( LinkItem item : childList )
- {
- if ( !items.contains( item ) )
- {
- items.add( item );
+ for (LinkItem item : childList) {
+ if (!items.contains(item)) {
+ items.add(item);
}
}
return items;
}
- private List<Logo> mergePoweredByLists( final List<Logo> childList, final List<Logo> parentList,
- final URLRebaser urlContainer )
- {
- List<Logo> logos = new ArrayList<Logo>( childList.size() + parentList.size() );
+ private List<Logo> mergePoweredByLists(
+ final List<Logo> childList, final List<Logo> parentList, final URLRebaser urlContainer) {
+ List<Logo> logos = new ArrayList<Logo>(childList.size() + parentList.size());
- for ( Logo logo : parentList )
- {
- if ( !logos.contains( logo ) )
- {
+ for (Logo logo : parentList) {
+ if (!logos.contains(logo)) {
final Logo clone = logo.clone();
- rebaseLogoPaths( clone, urlContainer );
+ rebaseLogoPaths(clone, urlContainer);
- logos.add( clone );
+ logos.add(clone);
}
}
- for ( Logo logo : childList )
- {
- if ( !logos.contains( logo ) )
- {
- logos.add( logo );
+ for (Logo logo : childList) {
+ if (!logos.contains(logo)) {
+ logos.add(logo);
}
}
@@ -384,22 +325,17 @@ public class DefaultDecorationModelInheritanceAssembler
// relativize only affects absolute links, if the link has the same scheme, host and port
// as the base, it is made into a relative link as viewed from the base
- private String relativizeLink( final String link, final String baseUri )
- {
- if ( link == null || baseUri == null )
- {
+ private String relativizeLink(final String link, final String baseUri) {
+ if (link == null || baseUri == null) {
return link;
}
// this shouldn't be necessary, just to swallow mal-formed hrefs
- try
- {
- final URIPathDescriptor path = new URIPathDescriptor( baseUri, link );
+ try {
+ final URIPathDescriptor path = new URIPathDescriptor(baseUri, link);
return path.relativizeLink().toString();
- }
- catch ( IllegalArgumentException e )
- {
+ } catch (IllegalArgumentException e) {
return link;
}
}
@@ -408,8 +344,7 @@ public class DefaultDecorationModelInheritanceAssembler
* URL rebaser: based on an old and a new path, can rebase a link based on old path to a value based on the new
* path.
*/
- private static class URLRebaser
- {
+ private static class URLRebaser {
private final String oldPath;
@@ -421,8 +356,7 @@ public class DefaultDecorationModelInheritanceAssembler
* @param oldPath the old path.
* @param newPath the new path.
*/
- URLRebaser( final String oldPath, final String newPath )
- {
+ URLRebaser(final String oldPath, final String newPath) {
this.oldPath = oldPath;
this.newPath = newPath;
}
@@ -432,8 +366,7 @@ public class DefaultDecorationModelInheritanceAssembler
*
* @return the new path.
*/
- public String getNewPath()
- {
+ public String getNewPath() {
return this.newPath;
}
@@ -442,8 +375,7 @@ public class DefaultDecorationModelInheritanceAssembler
*
* @return the old path.
*/
- public String getOldPath()
- {
+ public String getOldPath() {
return this.oldPath;
}
@@ -451,22 +383,19 @@ public class DefaultDecorationModelInheritanceAssembler
* Rebase only affects relative links, a relative link wrt an old base gets translated,
* so it points to the same location as viewed from a new base
*/
- public String rebaseLink( final String link )
- {
- if ( link == null || getOldPath() == null )
- {
+ public String rebaseLink(final String link) {
+ if (link == null || getOldPath() == null) {
return link;
}
- if ( link.contains( "${project." ) )
- {
- throw new IllegalArgumentException( "site.xml late interpolation ${project.*} expression found"
- + " in link: '" + link + "'. Use early interpolation ${this.*}" );
+ if (link.contains("${project.")) {
+ throw new IllegalArgumentException("site.xml late interpolation ${project.*} expression found"
+ + " in link: '" + link + "'. Use early interpolation ${this.*}");
}
- final URIPathDescriptor oldPath = new URIPathDescriptor( getOldPath(), link );
+ final URIPathDescriptor oldPath = new URIPathDescriptor(getOldPath(), link);
- return oldPath.rebaseLink( getNewPath() ).toString();
+ return oldPath.rebaseLink(getNewPath()).toString();
}
}
}
diff --git a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptor.java b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptor.java
index 1bf75a5..edd6736 100644
--- a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptor.java
+++ b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptor.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.site.decoration.inheritance;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.site.decoration.inheritance;
import java.net.URI;
import java.net.URISyntaxException;
@@ -31,8 +30,7 @@ import org.codehaus.plexus.util.PathTool;
*
* @since 1.2
*/
-public class URIPathDescriptor
-{
+public class URIPathDescriptor {
private final URI baseURI;
private final URI link;
@@ -60,17 +58,15 @@ public class URIPathDescriptor
* @throws IllegalArgumentException if either argument is not parsable as a URI,
* or if baseURI is not absolute.
*/
- public URIPathDescriptor( final String baseURI, final String link )
- {
- final String llink = sanitizeLink( link );
- final String bbase = sanitizeBase( baseURI );
+ public URIPathDescriptor(final String baseURI, final String link) {
+ final String llink = sanitizeLink(link);
+ final String bbase = sanitizeBase(baseURI);
- this.baseURI = URI.create( bbase ).normalize();
- this.link = URI.create( llink ).normalize();
+ this.baseURI = URI.create(bbase).normalize();
+ this.link = URI.create(llink).normalize();
- if ( !this.baseURI.isAbsolute() )
- {
- throw new IllegalArgumentException( "Base URI is not absolute: " + baseURI );
+ if (!this.baseURI.isAbsolute()) {
+ throw new IllegalArgumentException("Base URI is not absolute: " + baseURI);
}
}
@@ -80,8 +76,7 @@ public class URIPathDescriptor
*
* @return the normalized base URI.
*/
- public URI getBaseURI()
- {
+ public URI getBaseURI() {
return baseURI;
}
@@ -91,8 +86,7 @@ public class URIPathDescriptor
*
* @return the normalized link URI.
*/
- public URI getLink()
- {
+ public URI getLink() {
return link;
}
@@ -103,9 +97,8 @@ public class URIPathDescriptor
* @return the resolved link. This is equivalent to calling
* {@link #getBaseURI()}.{@link URI#resolve(java.net.URI) resolve}( {@link #getLink()} ).
*/
- public URI resolveLink()
- {
- return baseURI.resolve( link );
+ public URI resolveLink() {
+ return baseURI.resolve(link);
}
/**
@@ -116,30 +109,26 @@ public class URIPathDescriptor
*
* @return the link as a relative URI.
*/
- public URI relativizeLink()
- {
- return relativizeLink( baseURI.toString(), link );
+ public URI relativizeLink() {
+ return relativizeLink(baseURI.toString(), link);
}
// NOTE: URI.relativize does not work as expected, see
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6226081
- private static URI relativizeLink( final String base, final URI link )
- {
- if ( !link.isAbsolute() )
- {
+ private static URI relativizeLink(final String base, final URI link) {
+ if (!link.isAbsolute()) {
return link;
}
- final URI newBaseURI = URI.create( base );
+ final URI newBaseURI = URI.create(base);
- if ( !sameSite( link, newBaseURI ) )
- {
+ if (!sameSite(link, newBaseURI)) {
return link;
}
- final String relativePath = PathTool.getRelativeWebPath( newBaseURI.toString(), link.toString() );
+ final String relativePath = PathTool.getRelativeWebPath(newBaseURI.toString(), link.toString());
- return URI.create( correctRelativePath( relativePath ) );
+ return URI.create(correctRelativePath(relativePath));
}
/**
@@ -156,47 +145,36 @@ public class URIPathDescriptor
* @return a new relative link or the original link {@link #resolveLink() resolved},
* i.e. as an absolute link, if the link cannot be re-based.
*/
- public URI rebaseLink( final String newBase )
- {
- if ( link.isAbsolute() )
- {
+ public URI rebaseLink(final String newBase) {
+ if (link.isAbsolute()) {
return link;
}
- if ( newBase == null )
- {
+ if (newBase == null) {
return resolveLink();
}
final URI newBaseURI;
- try
- {
- newBaseURI = new URI( newBase );
- }
- catch ( URISyntaxException ex )
- {
+ try {
+ newBaseURI = new URI(newBase);
+ } catch (URISyntaxException ex) {
return resolveLink();
}
- if ( !sameSite( newBaseURI ) )
- {
+ if (!sameSite(newBaseURI)) {
return resolveLink();
}
- final String relativeBasePath = PathTool.getRelativeWebPath( newBaseURI.getPath(), baseURI.getPath() );
+ final String relativeBasePath = PathTool.getRelativeWebPath(newBaseURI.getPath(), baseURI.getPath());
- return URI.create( correctRelativePath( relativeBasePath ) ).resolve( link );
+ return URI.create(correctRelativePath(relativeBasePath)).resolve(link);
}
- private static String correctRelativePath( final String relativePath )
- {
- if ( "".equals( relativePath ) || "/".equals( relativePath ) )
- {
+ private static String correctRelativePath(final String relativePath) {
+ if ("".equals(relativePath) || "/".equals(relativePath)) {
return "./";
- }
- else
- {
+ } else {
return relativePath;
}
}
@@ -210,21 +188,19 @@ public class URIPathDescriptor
* @return true if {@link #getBaseURI()} shares the same scheme, host and port with the given URI
* where null values are allowed.
*/
- public boolean sameSite( final URI uri )
- {
- return ( uri != null ) && sameSite( this.baseURI, uri );
+ public boolean sameSite(final URI uri) {
+ return (uri != null) && sameSite(this.baseURI, uri);
}
- private static boolean sameSite( final URI baseURI, final URI newBaseURI )
- {
+ private static boolean sameSite(final URI baseURI, final URI newBaseURI) {
final boolean sameScheme =
- ( newBaseURI.getScheme() == null ? false : baseURI.getScheme().equalsIgnoreCase( newBaseURI.getScheme() ) );
- final boolean sameHost =
- ( baseURI.getHost() == null ? newBaseURI.getHost() == null
- : baseURI.getHost().equalsIgnoreCase( newBaseURI.getHost() ) );
- final boolean samePort = ( baseURI.getPort() == newBaseURI.getPort() );
+ (newBaseURI.getScheme() == null ? false : baseURI.getScheme().equalsIgnoreCase(newBaseURI.getScheme()));
+ final boolean sameHost = (baseURI.getHost() == null
+ ? newBaseURI.getHost() == null
+ : baseURI.getHost().equalsIgnoreCase(newBaseURI.getHost()));
+ final boolean samePort = (baseURI.getPort() == newBaseURI.getPort());
- return ( sameScheme && samePort && sameHost );
+ return (sameScheme && samePort && sameHost);
}
/**
@@ -234,30 +210,25 @@ public class URIPathDescriptor
* @return this URIPathDescriptor as a String.
*/
@Override
- public String toString()
- {
+ public String toString() {
return resolveLink().toString();
}
- private static String sanitizeBase( final String base )
- {
- String sane = base.replace( '\\', '/' );
+ private static String sanitizeBase(final String base) {
+ String sane = base.replace('\\', '/');
- if ( !sane.endsWith( "/" ) )
- {
+ if (!sane.endsWith("/")) {
sane += "/";
}
return sane;
}
- private static String sanitizeLink( final String link )
- {
- String sane = link.replace( '\\', '/' );
+ private static String sanitizeLink(final String link) {
+ String sane = link.replace('\\', '/');
- if ( sane.startsWith( "/" ) )
- {
- sane = sane.substring( 1 );
+ if (sane.startsWith("/")) {
+ sane = sane.substring(1);
}
return sane;
diff --git a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/DecorationUtilsTest.java b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/DecorationUtilsTest.java
index 1969d8c..8f4616b 100644
--- a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/DecorationUtilsTest.java
+++ b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/DecorationUtilsTest.java
@@ -1,13 +1,3 @@
-package org.apache.maven.doxia.site.decoration;
-
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -26,44 +16,50 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.site.decoration;
+
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-public class DecorationUtilsTest
-{
+public class DecorationUtilsTest {
@Test
- public void testIsLink()
- {
- assertFalse( DecorationUtils.isLink( null ) );
- assertFalse( DecorationUtils.isLink( "" ) );
- assertFalse( DecorationUtils.isLink( " " ) );
- assertTrue( DecorationUtils.isLink( "http://maven.apache.org/" ) );
- assertTrue( DecorationUtils.isLink( "https://maven.apache.org/" ) );
- assertTrue( DecorationUtils.isLink( "ftp://maven.apache.org/pub/" ) );
- assertTrue( DecorationUtils.isLink( "file:///home" ) );
- assertTrue( DecorationUtils.isLink( "mailto:toto@maven.org" ) );
- assertTrue( DecorationUtils.isLink( "any-protocol://" ) );
+ public void testIsLink() {
+ assertFalse(DecorationUtils.isLink(null));
+ assertFalse(DecorationUtils.isLink(""));
+ assertFalse(DecorationUtils.isLink(" "));
+ assertTrue(DecorationUtils.isLink("http://maven.apache.org/"));
+ assertTrue(DecorationUtils.isLink("https://maven.apache.org/"));
+ assertTrue(DecorationUtils.isLink("ftp://maven.apache.org/pub/"));
+ assertTrue(DecorationUtils.isLink("file:///home"));
+ assertTrue(DecorationUtils.isLink("mailto:toto@maven.org"));
+ assertTrue(DecorationUtils.isLink("any-protocol://"));
}
@Test
- public void testGetCustomChild()
- {
- Xpp3Dom dom = new Xpp3Dom( "root" );
- Xpp3Dom level1 = new Xpp3Dom( "level1" );
- dom.addChild( level1 );
- Xpp3Dom level2 = new Xpp3Dom( "level2" );
- level2.setValue( "value" );
- level1.addChild( level2 );
+ public void testGetCustomChild() {
+ Xpp3Dom dom = new Xpp3Dom("root");
+ Xpp3Dom level1 = new Xpp3Dom("level1");
+ dom.addChild(level1);
+ Xpp3Dom level2 = new Xpp3Dom("level2");
+ level2.setValue("value");
+ level1.addChild(level2);
- assertEquals( level1, DecorationUtils.getCustomChild( dom, "level1" ) );
- assertEquals( level2, DecorationUtils.getCustomChild( dom, "level1.level2" ) );
- assertNull( DecorationUtils.getCustomChild( dom, "no.level2" ) );
- assertNull( DecorationUtils.getCustomChild( dom, "level1.no" ) );
+ assertEquals(level1, DecorationUtils.getCustomChild(dom, "level1"));
+ assertEquals(level2, DecorationUtils.getCustomChild(dom, "level1.level2"));
+ assertNull(DecorationUtils.getCustomChild(dom, "no.level2"));
+ assertNull(DecorationUtils.getCustomChild(dom, "level1.no"));
- assertEquals( "value", DecorationUtils.getCustomValue( dom, "level1.level2" ) );
- assertNull( DecorationUtils.getCustomValue( dom, "no.level2" ) );
- assertNull( DecorationUtils.getCustomValue( dom, "level1.no" ) );
+ assertEquals("value", DecorationUtils.getCustomValue(dom, "level1.level2"));
+ assertNull(DecorationUtils.getCustomValue(dom, "no.level2"));
+ assertNull(DecorationUtils.getCustomValue(dom, "level1.no"));
- assertEquals( "value", DecorationUtils.getCustomValue( dom, "level1.level2", "default" ) );
- assertEquals( "default", DecorationUtils.getCustomValue( dom, "no.level2", "default" ) );
- assertEquals( "default", DecorationUtils.getCustomValue( dom, "level1.no", "default" ) );
+ assertEquals("value", DecorationUtils.getCustomValue(dom, "level1.level2", "default"));
+ assertEquals("default", DecorationUtils.getCustomValue(dom, "no.level2", "default"));
+ assertEquals("default", DecorationUtils.getCustomValue(dom, "level1.no", "default"));
}
}
diff --git a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssemblerTest.java b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssemblerTest.java
index f50bd61..10abbc4 100644
--- a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssemblerTest.java
+++ b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/DecorationModelInheritanceAssemblerTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.site.decoration.inheritance;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,10 +16,10 @@ package org.apache.maven.doxia.site.decoration.inheritance;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.site.decoration.inheritance;
import java.io.IOException;
import java.io.Reader;
-
import java.util.List;
import org.apache.maven.doxia.site.decoration.Banner;
@@ -45,9 +43,8 @@ import static org.junit.jupiter.api.Assertions.fail;
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
-@SuppressWarnings( "javadoc" )
-public class DecorationModelInheritanceAssemblerTest
-{
+@SuppressWarnings("javadoc")
+public class DecorationModelInheritanceAssemblerTest {
private final DecorationModelInheritanceAssembler assembler = new DefaultDecorationModelInheritanceAssembler();
private static final String NAME = "Name";
@@ -58,38 +55,33 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testInheritance()
- throws IOException, XmlPullParserException
- {
- DecorationModel childModel = readModel( "inheritance-child.xml" );
- DecorationModel parentModel = readModel( "inheritance-parent.xml" );
+ public void testInheritance() throws IOException, XmlPullParserException {
+ DecorationModel childModel = readModel("inheritance-child.xml");
+ DecorationModel parentModel = readModel("inheritance-parent.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
- DecorationModel expectedModel = readModel( "inheritance-expected.xml" );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia", "http://maven.apache.org");
+ DecorationModel expectedModel = readModel("inheritance-expected.xml");
- assertEquals( expectedModel, childModel, "Check result" );
+ assertEquals(expectedModel, childModel, "Check result");
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "inheritance-child.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/doxia",
- "scp://people.apache.org" );
- assertEquals( expectedModel, childModel, "Check scp result" );
+ childModel = readModel("inheritance-child.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/doxia", "scp://people.apache.org");
+ assertEquals(expectedModel, childModel, "Check scp result");
- assertEquals( readModel( "inheritance-parent.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("inheritance-parent.xml"), parentModel, "Modified parent!");
// late inheritance in links can't be rebased: check friendly message
- parentModel.getBannerLeft().setHref( "${project.url}" );
- childModel = readModel( "inheritance-child.xml" );
- try
- {
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/doxia",
- "scp://people.apache.org" );
- fail( "late interpolation in link should cause IllegalArgumentException" );
- }
- catch ( IllegalArgumentException iae )
- {
- assertTrue( iae.getMessage().startsWith( "site.xml late interpolation" ) );
+ parentModel.getBannerLeft().setHref("${project.url}");
+ childModel = readModel("inheritance-child.xml");
+ try {
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/doxia", "scp://people.apache.org");
+ fail("late interpolation in link should cause IllegalArgumentException");
+ } catch (IllegalArgumentException iae) {
+ assertTrue(iae.getMessage().startsWith("site.xml late interpolation"));
}
}
@@ -99,25 +91,29 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testSuppressedInheritance()
- throws IOException, XmlPullParserException
- {
- DecorationModel unassembledChildModel = readModel( "inheritance-child-no-inheritance.xml" );
- DecorationModel childModel = readModel( "inheritance-child-no-inheritance.xml" );
- DecorationModel parentModel = readModel( "inheritance-parent.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
- assertEquals( unassembledChildModel, childModel, "Check result" );
+ public void testSuppressedInheritance() throws IOException, XmlPullParserException {
+ DecorationModel unassembledChildModel = readModel("inheritance-child-no-inheritance.xml");
+ DecorationModel childModel = readModel("inheritance-child-no-inheritance.xml");
+ DecorationModel parentModel = readModel("inheritance-parent.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia", "http://maven.apache.org");
+ assertEquals(unassembledChildModel, childModel, "Check result");
// 2 levels of inheritance
DecorationModel childOfchildModel = new DecorationModel();
- assembler.assembleModelInheritance( "Child of Child", childOfchildModel, childModel,
- "http://maven.apache.org/doxia/child", "http://maven.apache.org/doxia" );
- assembler.assembleModelInheritance( NAME, childOfchildModel, parentModel, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
+ assembler.assembleModelInheritance(
+ "Child of Child",
+ childOfchildModel,
+ childModel,
+ "http://maven.apache.org/doxia/child",
+ "http://maven.apache.org/doxia");
+ assembler.assembleModelInheritance(
+ NAME, childOfchildModel, parentModel, "http://maven.apache.org/doxia", "http://maven.apache.org");
// check that the 3 breadcrumb items from parent.xml are not inherited
- assertEquals( 0, childOfchildModel.getBody().getBreadcrumbs().size(),
- "child of child no inheritance: breadcrumbs count" );
+ assertEquals(
+ 0,
+ childOfchildModel.getBody().getBreadcrumbs().size(),
+ "child of child no inheritance: breadcrumbs count");
}
/**
@@ -126,26 +122,24 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsResolvedWhenEmpty()
- throws IOException, XmlPullParserException
- {
+ public void testPathsResolvedWhenEmpty() throws IOException, XmlPullParserException {
// Test an empty model avoids NPEs
- DecorationModel childModel = readModel( "empty.xml" );
- DecorationModel parentModel = readModel( "empty.xml" );
+ DecorationModel childModel = readModel("empty.xml");
+ DecorationModel parentModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
- DecorationModel mergedModel = readModel( "empty.xml" );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia", "http://maven.apache.org");
+ DecorationModel mergedModel = readModel("empty.xml");
- assertEquals( mergedModel, childModel, "Check result" );
+ assertEquals(mergedModel, childModel, "Check result");
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/doxia",
- "scp://people.apache.org" );
- assertEquals( mergedModel, childModel, "Check scp result" );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/doxia", "scp://people.apache.org");
+ assertEquals(mergedModel, childModel, "Check scp result");
- assertEquals( readModel( "empty.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("empty.xml"), parentModel, "Modified parent!");
}
/**
@@ -154,46 +148,52 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsNotResolvedForExternalUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel parentModel = readModel( "external-urls.xml" );
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testPathsNotResolvedForExternalUrls() throws IOException, XmlPullParserException {
+ DecorationModel parentModel = readModel("external-urls.xml");
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
- assertPathsNotResolvedForExternalUrls( childModel );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia", "http://maven.apache.org");
+ assertPathsNotResolvedForExternalUrls(childModel);
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/doxia",
- "scp://people.apache.org" );
- assertPathsNotResolvedForExternalUrls( childModel );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/doxia", "scp://people.apache.org");
+ assertPathsNotResolvedForExternalUrls(childModel);
- assertEquals( readModel( "external-urls.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("external-urls.xml"), parentModel, "Modified parent!");
}
- private static void assertPathsNotResolvedForExternalUrls( final DecorationModel childModel )
- {
- assertEquals( "http://jakarta.apache.org/", childModel.getBannerLeft().getHref(), "check left banner href" );
- assertEquals( "http://jakarta.apache.org/images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image" );
+ private static void assertPathsNotResolvedForExternalUrls(final DecorationModel childModel) {
+ assertEquals("http://jakarta.apache.org/", childModel.getBannerLeft().getHref(), "check left banner href");
+ assertEquals(
+ "http://jakarta.apache.org/images/jakarta-logo.gif",
+ childModel.getBannerLeft().getSrc(),
+ "check left banner image");
- assertEquals( "http://jakarta.apache.org/commons/sandbox", childModel.getBannerRight().getHref(), "check right banner href" );
- assertEquals( "http://jakarta.apache.org/commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image" );
+ assertEquals(
+ "http://jakarta.apache.org/commons/sandbox",
+ childModel.getBannerRight().getHref(),
+ "check right banner href");
+ assertEquals(
+ "http://jakarta.apache.org/commons/images/logo.png",
+ childModel.getBannerRight().getSrc(),
+ "check right banner image");
- Logo poweredBy = childModel.getPoweredBy().get( 0 );
- assertEquals( "http://tomcat.apache.org/", poweredBy.getHref(), "check powered by logo href" );
- assertEquals( "http://tomcat.apache.org/logo.gif", poweredBy.getImg(), "check powered by logo image" );
+ Logo poweredBy = childModel.getPoweredBy().get(0);
+ assertEquals("http://tomcat.apache.org/", poweredBy.getHref(), "check powered by logo href");
+ assertEquals("http://tomcat.apache.org/logo.gif", poweredBy.getImg(), "check powered by logo image");
- LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get( 0 );
- assertEquals( "http://www.apache.org/", breadcrumb.getHref(), "check breadcrumb href" );
+ LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get(0);
+ assertEquals("http://www.apache.org/", breadcrumb.getHref(), "check breadcrumb href");
- LinkItem link = childModel.getBody().getLinks().get( 0 );
- assertEquals( "http://www.bouncycastle.org", link.getHref(), "check link href" );
+ LinkItem link = childModel.getBody().getLinks().get(0);
+ assertEquals("http://www.bouncycastle.org", link.getHref(), "check link href");
- Menu menu = childModel.getBody().getMenus().get( 0 );
- LinkItem menuItem = menu.getItems().get( 0 );
- assertEquals( "http://www.apache.org/special/", menuItem.getHref(), "check menu item href" );
+ Menu menu = childModel.getBody().getMenus().get(0);
+ LinkItem menuItem = menu.getItems().get(0);
+ assertEquals("http://www.apache.org/special/", menuItem.getHref(), "check menu item href");
}
/**
@@ -202,46 +202,43 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsResolvedForRelativeUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel parentModel = readModel( "relative-urls.xml" );
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testPathsResolvedForRelativeUrls() throws IOException, XmlPullParserException {
+ DecorationModel parentModel = readModel("relative-urls.xml");
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia/",
- "http://maven.apache.org" );
- assertPathsResolvedForRelativeUrls( childModel );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia/", "http://maven.apache.org");
+ assertPathsResolvedForRelativeUrls(childModel);
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/doxia",
- "scp://people.apache.org" );
- assertPathsResolvedForRelativeUrls( childModel );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/doxia", "scp://people.apache.org");
+ assertPathsResolvedForRelativeUrls(childModel);
- assertEquals( readModel( "relative-urls.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("relative-urls.xml"), parentModel, "Modified parent!");
}
- private static void assertPathsResolvedForRelativeUrls( final DecorationModel childModel )
- {
- assertEquals( "../banner/left", childModel.getBannerLeft().getHref(), "check left banner href" );
- assertEquals( "../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image" );
+ private static void assertPathsResolvedForRelativeUrls(final DecorationModel childModel) {
+ assertEquals("../banner/left", childModel.getBannerLeft().getHref(), "check left banner href");
+ assertEquals("../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image");
- assertEquals( "../banner/right/", childModel.getBannerRight().getHref(), "check right banner href" );
- assertEquals( "../commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image" );
+ assertEquals("../banner/right/", childModel.getBannerRight().getHref(), "check right banner href");
+ assertEquals("../commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image");
- Logo poweredBy = childModel.getPoweredBy().get( 0 );
- assertEquals( "../tomcat", poweredBy.getHref(), "check powered by logo href" );
- assertEquals( "../tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image" );
+ Logo poweredBy = childModel.getPoweredBy().get(0);
+ assertEquals("../tomcat", poweredBy.getHref(), "check powered by logo href");
+ assertEquals("../tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image");
- LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get( 0 );
- assertEquals( "../apache", breadcrumb.getHref(), "check breadcrumb href" );
+ LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get(0);
+ assertEquals("../apache", breadcrumb.getHref(), "check breadcrumb href");
- LinkItem link = childModel.getBody().getLinks().get( 0 );
- assertEquals( "../bouncycastle/", link.getHref(), "check link href" );
+ LinkItem link = childModel.getBody().getLinks().get(0);
+ assertEquals("../bouncycastle/", link.getHref(), "check link href");
- Menu menu = childModel.getBody().getMenus().get( 0 );
- LinkItem menuItem = menu.getItems().get( 0 );
- assertEquals( "../special/", menuItem.getHref(), "check menu item href" );
+ Menu menu = childModel.getBody().getMenus().get(0);
+ LinkItem menuItem = menu.getItems().get(0);
+ assertEquals("../special/", menuItem.getHref(), "check menu item href");
}
/**
@@ -250,49 +247,46 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsResolvedForSubsiteUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel parentModel = readModel( "subsite-urls.xml" );
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testPathsResolvedForSubsiteUrls() throws IOException, XmlPullParserException {
+ DecorationModel parentModel = readModel("subsite-urls.xml");
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia/",
- "http://maven.apache.org" );
- assembler.resolvePaths( childModel, "http://maven.apache.org/doxia" );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia/", "http://maven.apache.org");
+ assembler.resolvePaths(childModel, "http://maven.apache.org/doxia");
- assertPathsResolvedForSubsiteUrls( childModel );
+ assertPathsResolvedForSubsiteUrls(childModel);
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/doxia",
- "scp://people.apache.org" );
- assembler.resolvePaths( childModel, "http://maven.apache.org/doxia" );
- assertPathsResolvedForSubsiteUrls( childModel );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/doxia", "scp://people.apache.org");
+ assembler.resolvePaths(childModel, "http://maven.apache.org/doxia");
+ assertPathsResolvedForSubsiteUrls(childModel);
- assertEquals( readModel( "subsite-urls.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("subsite-urls.xml"), parentModel, "Modified parent!");
}
- private static void assertPathsResolvedForSubsiteUrls( final DecorationModel childModel )
- {
- assertEquals( "../banner/left", childModel.getBannerLeft().getHref(), "check left banner href" );
- assertEquals( "../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image" );
+ private static void assertPathsResolvedForSubsiteUrls(final DecorationModel childModel) {
+ assertEquals("../banner/left", childModel.getBannerLeft().getHref(), "check left banner href");
+ assertEquals("../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image");
- assertEquals( "../banner/right/", childModel.getBannerRight().getHref(), "check right banner href" );
- assertEquals( "../commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image" );
+ assertEquals("../banner/right/", childModel.getBannerRight().getHref(), "check right banner href");
+ assertEquals("../commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image");
- Logo poweredBy = childModel.getPoweredBy().get( 0 );
- assertEquals( "../tomcat", poweredBy.getHref(), "check powered by logo href" );
- assertEquals( "../tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image" );
+ Logo poweredBy = childModel.getPoweredBy().get(0);
+ assertEquals("../tomcat", poweredBy.getHref(), "check powered by logo href");
+ assertEquals("../tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image");
- LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get( 0 );
- assertEquals( "../apache", breadcrumb.getHref(), "check breadcrumb href" );
+ LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get(0);
+ assertEquals("../apache", breadcrumb.getHref(), "check breadcrumb href");
- LinkItem link = childModel.getBody().getLinks().get( 0 );
- assertEquals( "../bouncycastle/", link.getHref(), "check link href" );
+ LinkItem link = childModel.getBody().getLinks().get(0);
+ assertEquals("../bouncycastle/", link.getHref(), "check link href");
- Menu menu = childModel.getBody().getMenus().get( 0 );
- LinkItem menuItem = menu.getItems().get( 0 );
- assertEquals( "../special/", menuItem.getHref(), "check menu item href" );
+ Menu menu = childModel.getBody().getMenus().get(0);
+ LinkItem menuItem = menu.getItems().get(0);
+ assertEquals("../special/", menuItem.getHref(), "check menu item href");
}
/**
@@ -301,46 +295,44 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsResolvedForRelativeUrlsDepthOfTwo()
- throws IOException, XmlPullParserException
- {
- DecorationModel parentModel = readModel( "relative-urls.xml" );
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testPathsResolvedForRelativeUrlsDepthOfTwo() throws IOException, XmlPullParserException {
+ DecorationModel parentModel = readModel("relative-urls.xml");
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia/core",
- "http://maven.apache.org" );
- assertPathsResolvedForRelativeUrlsDepthOfTwo( childModel );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia/core", "http://maven.apache.org");
+ assertPathsResolvedForRelativeUrlsDepthOfTwo(childModel);
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/doxia/core",
- "scp://people.apache.org" );
- assertPathsResolvedForRelativeUrlsDepthOfTwo( childModel );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/doxia/core", "scp://people.apache.org");
+ assertPathsResolvedForRelativeUrlsDepthOfTwo(childModel);
- assertEquals( readModel( "relative-urls.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("relative-urls.xml"), parentModel, "Modified parent!");
}
- private static void assertPathsResolvedForRelativeUrlsDepthOfTwo( final DecorationModel childModel )
- {
- assertEquals( "../../banner/left", childModel.getBannerLeft().getHref(), "check left banner href" );
- assertEquals( "../../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image" );
+ private static void assertPathsResolvedForRelativeUrlsDepthOfTwo(final DecorationModel childModel) {
+ assertEquals("../../banner/left", childModel.getBannerLeft().getHref(), "check left banner href");
+ assertEquals("../../images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image");
- assertEquals( "../../banner/right/", childModel.getBannerRight().getHref(), "check right banner href" );
- assertEquals( "../../commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image" );
+ assertEquals("../../banner/right/", childModel.getBannerRight().getHref(), "check right banner href");
+ assertEquals(
+ "../../commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image");
- Logo poweredBy = childModel.getPoweredBy().get( 0 );
- assertEquals( "../../tomcat", poweredBy.getHref(), "check powered by logo href" );
- assertEquals( "../../tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image" );
+ Logo poweredBy = childModel.getPoweredBy().get(0);
+ assertEquals("../../tomcat", poweredBy.getHref(), "check powered by logo href");
+ assertEquals("../../tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image");
- LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get( 0 );
- assertEquals( "../../apache", breadcrumb.getHref(), "check breadcrumb href" );
+ LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get(0);
+ assertEquals("../../apache", breadcrumb.getHref(), "check breadcrumb href");
- LinkItem link = childModel.getBody().getLinks().get( 0 );
- assertEquals( "../../bouncycastle/", link.getHref(), "check link href" );
+ LinkItem link = childModel.getBody().getLinks().get(0);
+ assertEquals("../../bouncycastle/", link.getHref(), "check link href");
- Menu menu = childModel.getBody().getMenus().get( 0 );
- LinkItem menuItem = menu.getItems().get( 0 );
- assertEquals( "../../special/", menuItem.getHref(), "check menu item href" );
+ Menu menu = childModel.getBody().getMenus().get(0);
+ LinkItem menuItem = menu.getItems().get(0);
+ assertEquals("../../special/", menuItem.getHref(), "check menu item href");
}
/**
@@ -349,46 +341,44 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsResolvedForReverseRelativeUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel parentModel = readModel( "relative-urls.xml" );
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testPathsResolvedForReverseRelativeUrls() throws IOException, XmlPullParserException {
+ DecorationModel parentModel = readModel("relative-urls.xml");
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/",
- "http://maven.apache.org/doxia/" );
- assertPathsResolvedForReverseRelativeUrls( childModel );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/", "http://maven.apache.org/doxia/");
+ assertPathsResolvedForReverseRelativeUrls(childModel);
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/",
- "scp://people.apache.org/doxia/" );
- assertPathsResolvedForReverseRelativeUrls( childModel );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/", "scp://people.apache.org/doxia/");
+ assertPathsResolvedForReverseRelativeUrls(childModel);
- assertEquals( readModel( "relative-urls.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("relative-urls.xml"), parentModel, "Modified parent!");
}
- private static void assertPathsResolvedForReverseRelativeUrls( final DecorationModel childModel )
- {
- assertEquals( "doxia/banner/left", childModel.getBannerLeft().getHref(), "check left banner href" );
- assertEquals( "doxia/images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image" );
+ private static void assertPathsResolvedForReverseRelativeUrls(final DecorationModel childModel) {
+ assertEquals("doxia/banner/left", childModel.getBannerLeft().getHref(), "check left banner href");
+ assertEquals("doxia/images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image");
- assertEquals( "doxia/banner/right/", childModel.getBannerRight().getHref(), "check right banner href" );
- assertEquals( "doxia/commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image" );
+ assertEquals("doxia/banner/right/", childModel.getBannerRight().getHref(), "check right banner href");
+ assertEquals(
+ "doxia/commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image");
- Logo poweredBy = childModel.getPoweredBy().get( 0 );
- assertEquals( "doxia/tomcat", poweredBy.getHref(), "check powered by logo href" );
- assertEquals( "doxia/tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image" );
+ Logo poweredBy = childModel.getPoweredBy().get(0);
+ assertEquals("doxia/tomcat", poweredBy.getHref(), "check powered by logo href");
+ assertEquals("doxia/tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image");
- LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get( 0 );
- assertEquals( "doxia/apache", breadcrumb.getHref(), "check breadcrumb href" );
+ LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get(0);
+ assertEquals("doxia/apache", breadcrumb.getHref(), "check breadcrumb href");
- LinkItem link = childModel.getBody().getLinks().get( 0 );
- assertEquals( "doxia/bouncycastle/", link.getHref(), "check link href" );
+ LinkItem link = childModel.getBody().getLinks().get(0);
+ assertEquals("doxia/bouncycastle/", link.getHref(), "check link href");
- Menu menu = childModel.getBody().getMenus().get( 0 );
- LinkItem menuItem = menu.getItems().get( 0 );
- assertEquals( "doxia/special/", menuItem.getHref(), "check menu item href" );
+ Menu menu = childModel.getBody().getMenus().get(0);
+ LinkItem menuItem = menu.getItems().get(0);
+ assertEquals("doxia/special/", menuItem.getHref(), "check menu item href");
}
/**
@@ -397,46 +387,47 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsResolvedForReverseRelativeUrlsDepthOfTwo()
- throws IOException, XmlPullParserException
- {
- DecorationModel parentModel = readModel( "relative-urls.xml" );
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testPathsResolvedForReverseRelativeUrlsDepthOfTwo() throws IOException, XmlPullParserException {
+ DecorationModel parentModel = readModel("relative-urls.xml");
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/",
- "http://maven.apache.org/doxia/core/" );
- assertPathsResolvedForReverseRelativeUrlsDepthOfTwo( childModel );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/", "http://maven.apache.org/doxia/core/");
+ assertPathsResolvedForReverseRelativeUrlsDepthOfTwo(childModel);
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/",
- "scp://people.apache.org/doxia/core/" );
- assertPathsResolvedForReverseRelativeUrlsDepthOfTwo( childModel );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/", "scp://people.apache.org/doxia/core/");
+ assertPathsResolvedForReverseRelativeUrlsDepthOfTwo(childModel);
- assertEquals( readModel( "relative-urls.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("relative-urls.xml"), parentModel, "Modified parent!");
}
- private static void assertPathsResolvedForReverseRelativeUrlsDepthOfTwo( final DecorationModel childModel )
- {
- assertEquals( "doxia/core/banner/left", childModel.getBannerLeft().getHref(), "check left banner href" );
- assertEquals( "doxia/core/images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image" );
+ private static void assertPathsResolvedForReverseRelativeUrlsDepthOfTwo(final DecorationModel childModel) {
+ assertEquals("doxia/core/banner/left", childModel.getBannerLeft().getHref(), "check left banner href");
+ assertEquals(
+ "doxia/core/images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image");
- assertEquals( "doxia/core/banner/right/", childModel.getBannerRight().getHref(), "check right banner href" );
- assertEquals( "doxia/core/commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image" );
+ assertEquals("doxia/core/banner/right/", childModel.getBannerRight().getHref(), "check right banner href");
+ assertEquals(
+ "doxia/core/commons/images/logo.png",
+ childModel.getBannerRight().getSrc(),
+ "check right banner image");
- Logo poweredBy = childModel.getPoweredBy().get( 0 );
- assertEquals( "doxia/core/tomcat", poweredBy.getHref(), "check powered by logo href" );
- assertEquals( "doxia/core/tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image" );
+ Logo poweredBy = childModel.getPoweredBy().get(0);
+ assertEquals("doxia/core/tomcat", poweredBy.getHref(), "check powered by logo href");
+ assertEquals("doxia/core/tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image");
- LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get( 0 );
- assertEquals( "doxia/core/apache", breadcrumb.getHref(), "check breadcrumb href" );
+ LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get(0);
+ assertEquals("doxia/core/apache", breadcrumb.getHref(), "check breadcrumb href");
- LinkItem link = childModel.getBody().getLinks().get( 0 );
- assertEquals( "doxia/core/bouncycastle/", link.getHref(), "check link href" );
+ LinkItem link = childModel.getBody().getLinks().get(0);
+ assertEquals("doxia/core/bouncycastle/", link.getHref(), "check link href");
- Menu menu = childModel.getBody().getMenus().get( 0 );
- LinkItem menuItem = menu.getItems().get( 0 );
- assertEquals( "doxia/core/special/", menuItem.getHref(), "check menu item href" );
+ Menu menu = childModel.getBody().getMenus().get(0);
+ LinkItem menuItem = menu.getItems().get(0);
+ assertEquals("doxia/core/special/", menuItem.getHref(), "check menu item href");
}
/**
@@ -445,46 +436,55 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testPathsResolvedForUnrelatedRelativeUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel parentModel = readModel( "relative-urls.xml" );
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testPathsResolvedForUnrelatedRelativeUrls() throws IOException, XmlPullParserException {
+ DecorationModel parentModel = readModel("relative-urls.xml");
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org",
- "http://jakarta.apache.org" );
- assertPathsResolvedForUnrelatedRelativeUrls( childModel );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org", "http://jakarta.apache.org");
+ assertPathsResolvedForUnrelatedRelativeUrls(childModel);
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://people.apache.org/",
- "http://jakarta.apache.org" );
- assertPathsResolvedForUnrelatedRelativeUrls( childModel );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://people.apache.org/", "http://jakarta.apache.org");
+ assertPathsResolvedForUnrelatedRelativeUrls(childModel);
- assertEquals( readModel( "relative-urls.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("relative-urls.xml"), parentModel, "Modified parent!");
}
- private static void assertPathsResolvedForUnrelatedRelativeUrls( final DecorationModel childModel )
- {
- assertEquals( "http://jakarta.apache.org/banner/left", childModel.getBannerLeft().getHref(), "check left banner href" );
- assertEquals( "http://jakarta.apache.org/images/jakarta-logo.gif", childModel.getBannerLeft().getSrc(), "check left banner image" );
+ private static void assertPathsResolvedForUnrelatedRelativeUrls(final DecorationModel childModel) {
+ assertEquals(
+ "http://jakarta.apache.org/banner/left",
+ childModel.getBannerLeft().getHref(),
+ "check left banner href");
+ assertEquals(
+ "http://jakarta.apache.org/images/jakarta-logo.gif",
+ childModel.getBannerLeft().getSrc(),
+ "check left banner image");
- assertEquals( "http://jakarta.apache.org/banner/right/", childModel.getBannerRight().getHref(), "check right banner href" );
- assertEquals( "http://jakarta.apache.org/commons/images/logo.png", childModel.getBannerRight().getSrc(), "check right banner image" );
+ assertEquals(
+ "http://jakarta.apache.org/banner/right/",
+ childModel.getBannerRight().getHref(),
+ "check right banner href");
+ assertEquals(
+ "http://jakarta.apache.org/commons/images/logo.png",
+ childModel.getBannerRight().getSrc(),
+ "check right banner image");
- Logo poweredBy = childModel.getPoweredBy().get( 0 );
- assertEquals( "http://jakarta.apache.org/tomcat", poweredBy.getHref(), "check powered by logo href" );
- assertEquals( "http://jakarta.apache.org/tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image" );
+ Logo poweredBy = childModel.getPoweredBy().get(0);
+ assertEquals("http://jakarta.apache.org/tomcat", poweredBy.getHref(), "check powered by logo href");
+ assertEquals("http://jakarta.apache.org/tomcat/logo.gif", poweredBy.getImg(), "check powered by logo image");
- LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get( 0 );
- assertEquals( "http://jakarta.apache.org/apache", breadcrumb.getHref(), "check breadcrumb href" );
+ LinkItem breadcrumb = childModel.getBody().getBreadcrumbs().get(0);
+ assertEquals("http://jakarta.apache.org/apache", breadcrumb.getHref(), "check breadcrumb href");
- LinkItem link = childModel.getBody().getLinks().get( 0 );
- assertEquals( "http://jakarta.apache.org/bouncycastle/", link.getHref(), "check link href" );
+ LinkItem link = childModel.getBody().getLinks().get(0);
+ assertEquals("http://jakarta.apache.org/bouncycastle/", link.getHref(), "check link href");
- Menu menu = childModel.getBody().getMenus().get( 0 );
- LinkItem menuItem = menu.getItems().get( 0 );
- assertEquals( "http://jakarta.apache.org/special/", menuItem.getHref(), "check menu item href" );
+ Menu menu = childModel.getBody().getMenus().get(0);
+ LinkItem menuItem = menu.getItems().get(0);
+ assertEquals("http://jakarta.apache.org/special/", menuItem.getHref(), "check menu item href");
}
/**
@@ -493,22 +493,20 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testNullParent()
- throws IOException, XmlPullParserException
- {
- DecorationModel childModel = readModel( "empty.xml" );
+ public void testNullParent() throws IOException, XmlPullParserException {
+ DecorationModel childModel = readModel("empty.xml");
- assembler.assembleModelInheritance( NAME, childModel, null, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
- DecorationModel mergedModel = readModel( "empty.xml" );
+ assembler.assembleModelInheritance(
+ NAME, childModel, null, "http://maven.apache.org/doxia", "http://maven.apache.org");
+ DecorationModel mergedModel = readModel("empty.xml");
- assertEquals( mergedModel, childModel, "Check result" );
+ assertEquals(mergedModel, childModel, "Check result");
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, null, "scp://people.apache.org/doxia",
- "scp://people.apache.org" );
- assertEquals( mergedModel, childModel, "Check scp result" );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, null, "scp://people.apache.org/doxia", "scp://people.apache.org");
+ assertEquals(mergedModel, childModel, "Check scp result");
}
/**
@@ -517,25 +515,23 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testFullyPopulatedChild()
- throws IOException, XmlPullParserException
- {
- DecorationModel childModel = readModel( "fully-populated-child.xml" );
- DecorationModel parentModel = readModel( "fully-populated-child.xml" );
+ public void testFullyPopulatedChild() throws IOException, XmlPullParserException {
+ DecorationModel childModel = readModel("fully-populated-child.xml");
+ DecorationModel parentModel = readModel("fully-populated-child.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://foo.apache.org/doxia",
- "http://foo.apache.org" );
- DecorationModel mergedModel = readModel( "fully-populated-child.xml" );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://foo.apache.org/doxia", "http://foo.apache.org");
+ DecorationModel mergedModel = readModel("fully-populated-child.xml");
- assertEquals( mergedModel, childModel, "Check result" );
+ assertEquals(mergedModel, childModel, "Check result");
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "fully-populated-child.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://foo.apache.org/doxia",
- "scp://foo.apache.org" );
- assertEquals( mergedModel, childModel, "Check scp result" );
+ childModel = readModel("fully-populated-child.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://foo.apache.org/doxia", "scp://foo.apache.org");
+ assertEquals(mergedModel, childModel, "Check scp result");
- assertEquals( readModel( "fully-populated-child.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("fully-populated-child.xml"), parentModel, "Modified parent!");
}
/**
@@ -544,31 +540,29 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testFullyPopulatedParentAndEmptyChild()
- throws IOException, XmlPullParserException
- {
- DecorationModel childModel = readModel( "empty.xml" );
- DecorationModel parentModel = readModel( "fully-populated-child.xml" );
+ public void testFullyPopulatedParentAndEmptyChild() throws IOException, XmlPullParserException {
+ DecorationModel childModel = readModel("empty.xml");
+ DecorationModel parentModel = readModel("fully-populated-child.xml");
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "http://maven.apache.org/doxia", "http://maven.apache.org");
- DecorationModel unresolvedModel = readModel( "fully-populated-unresolved.xml" );
- assertEquals( unresolvedModel, childModel, "Check result" );
+ DecorationModel unresolvedModel = readModel("fully-populated-unresolved.xml");
+ assertEquals(unresolvedModel, childModel, "Check result");
- assembler.resolvePaths( childModel, "http://maven.apache.org/doxia" );
- DecorationModel mergedModel = readModel( "fully-populated-merged.xml" );
+ assembler.resolvePaths(childModel, "http://maven.apache.org/doxia");
+ DecorationModel mergedModel = readModel("fully-populated-merged.xml");
- assertEquals( mergedModel, childModel, "Check result" );
+ assertEquals(mergedModel, childModel, "Check result");
// same with scp url, DOXIASITETOOLS-47
- childModel = readModel( "empty.xml" );
- assembler.assembleModelInheritance( NAME, childModel, parentModel, "scp://maven.apache.org/doxia",
- "scp://maven.apache.org" );
- assembler.resolvePaths( childModel, "http://maven.apache.org/doxia" );
- assertEquals( mergedModel, childModel, "Check scp result" );
+ childModel = readModel("empty.xml");
+ assembler.assembleModelInheritance(
+ NAME, childModel, parentModel, "scp://maven.apache.org/doxia", "scp://maven.apache.org");
+ assembler.resolvePaths(childModel, "http://maven.apache.org/doxia");
+ assertEquals(mergedModel, childModel, "Check scp result");
- assertEquals( readModel( "fully-populated-child.xml" ), parentModel, "Modified parent!" );
+ assertEquals(readModel("fully-populated-child.xml"), parentModel, "Modified parent!");
}
/**
@@ -577,15 +571,13 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testResolvingAllExternalUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel model = readModel( "external-urls.xml" );
+ public void testResolvingAllExternalUrls() throws IOException, XmlPullParserException {
+ DecorationModel model = readModel("external-urls.xml");
- assembler.resolvePaths( model, "http://foo.com/" );
- DecorationModel mergedModel = readModel( "external-urls.xml" );
+ assembler.resolvePaths(model, "http://foo.com/");
+ DecorationModel mergedModel = readModel("external-urls.xml");
- assertEquals( mergedModel, model, "Check result" );
+ assertEquals(mergedModel, model, "Check result");
}
/**
@@ -594,16 +586,14 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testResolvingAllRelativeUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel model = readModel( "relative-urls.xml" );
+ public void testResolvingAllRelativeUrls() throws IOException, XmlPullParserException {
+ DecorationModel model = readModel("relative-urls.xml");
- assembler.resolvePaths( model, "http://foo.com/" );
+ assembler.resolvePaths(model, "http://foo.com/");
- DecorationModel resolvedModel = readModel( "relative-urls-resolved.xml" );
+ DecorationModel resolvedModel = readModel("relative-urls-resolved.xml");
- assertEquals( resolvedModel, model, "Check result" );
+ assertEquals(resolvedModel, model, "Check result");
}
/**
@@ -612,52 +602,50 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testResolvingAllSiteUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel model = readModel( "subsite-urls.xml" );
+ public void testResolvingAllSiteUrls() throws IOException, XmlPullParserException {
+ DecorationModel model = readModel("subsite-urls.xml");
- assembler.resolvePaths( model, "http://maven.apache.org/" );
+ assembler.resolvePaths(model, "http://maven.apache.org/");
- DecorationModel resolvedModel = readModel( "relative-urls-resolved.xml" );
- assertEquals( resolvedModel, model, "Check result" );
+ DecorationModel resolvedModel = readModel("relative-urls-resolved.xml");
+ assertEquals(resolvedModel, model, "Check result");
}
-/* [MSITE-62] This is to test the ../ relative paths, which I am inclined not to use
- public void testResolvingAllSiteChildUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel model = readModel( "subsite-urls.xml" );
+ /* [MSITE-62] This is to test the ../ relative paths, which I am inclined not to use
+ public void testResolvingAllSiteChildUrls()
+ throws IOException, XmlPullParserException
+ {
+ DecorationModel model = readModel( "subsite-urls.xml" );
- assembler.resolvePaths( model, "http://maven.apache.org/foo" );
+ assembler.resolvePaths( model, "http://maven.apache.org/foo" );
- DecorationModel resolvedModel = readModel( "subsite-relative-urls-resolved.xml" );
- assertEquals( resolvedModel, model, "Check result" );
- }
+ DecorationModel resolvedModel = readModel( "subsite-relative-urls-resolved.xml" );
+ assertEquals( resolvedModel, model, "Check result" );
+ }
- public void testResolvingAllSiteChildUrlsMultipleLevels()
- throws IOException, XmlPullParserException
- {
- DecorationModel model = readModel( "subsite-urls.xml" );
+ public void testResolvingAllSiteChildUrlsMultipleLevels()
+ throws IOException, XmlPullParserException
+ {
+ DecorationModel model = readModel( "subsite-urls.xml" );
- assembler.resolvePaths( model, "http://maven.apache.org/banner/right" );
+ assembler.resolvePaths( model, "http://maven.apache.org/banner/right" );
- DecorationModel resolvedModel = readModel( "subsite-relative-urls-multiple-resolved.xml" );
- assertEquals( resolvedModel, model, "Check result" );
- }
+ DecorationModel resolvedModel = readModel( "subsite-relative-urls-multiple-resolved.xml" );
+ assertEquals( resolvedModel, model, "Check result" );
+ }
- public void testResolvingAllSiteChildFilesystemUrls()
- throws IOException, XmlPullParserException
- {
- DecorationModel model = readModel( "subsite-urls-file.xml" );
+ public void testResolvingAllSiteChildFilesystemUrls()
+ throws IOException, XmlPullParserException
+ {
+ DecorationModel model = readModel( "subsite-urls-file.xml" );
- assembler.resolvePaths( model, "file://localhost/www/maven.apache.org/foo" );
+ assembler.resolvePaths( model, "file://localhost/www/maven.apache.org/foo" );
- DecorationModel resolvedModel = readModel( "subsite-relative-urls-resolved.xml" );
- assertEquals( resolvedModel, model, "Check result" );
- }
+ DecorationModel resolvedModel = readModel( "subsite-relative-urls-resolved.xml" );
+ assertEquals( resolvedModel, model, "Check result" );
+ }
-*/
+ */
/**
*
@@ -665,268 +653,257 @@ public class DecorationModelInheritanceAssemblerTest
* @throws XmlPullParserException
*/
@Test
- public void testResolvingEmptyDescriptor()
- throws IOException, XmlPullParserException
- {
- DecorationModel model = readModel( "empty.xml" );
- assembler.resolvePaths( model, "http://maven.apache.org" );
- DecorationModel mergedModel = readModel( "empty.xml" );
+ public void testResolvingEmptyDescriptor() throws IOException, XmlPullParserException {
+ DecorationModel model = readModel("empty.xml");
+ assembler.resolvePaths(model, "http://maven.apache.org");
+ DecorationModel mergedModel = readModel("empty.xml");
- assertEquals( mergedModel, model, "Check result" );
+ assertEquals(mergedModel, model, "Check result");
}
/**
*
*/
@Test
- public void testDuplicateParentElements()
- {
+ public void testDuplicateParentElements() {
DecorationModel model = new DecorationModel();
- model.setBody( new Body() );
- model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
- model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
+ model.setBody(new Body());
+ model.getBody().addLink(createLinkItem("Foo", "http://foo.apache.org"));
+ model.getBody().addLink(createLinkItem("Foo", "http://foo.apache.org"));
- model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
- model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
+ model.addPoweredBy(createLogo("Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg"));
+ model.addPoweredBy(createLogo("Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg"));
DecorationModel child = new DecorationModel();
- assembler.assembleModelInheritance( NAME, child, model, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
+ assembler.assembleModelInheritance(
+ NAME, child, model, "http://maven.apache.org/doxia", "http://maven.apache.org");
- assertEquals( 1, child.getBody().getLinks().size(), "Check size" );
- assertEquals( createLinkItem( "Foo", "http://foo.apache.org" ), child.getBody().getLinks().get( 0 ), "Check item" );
+ assertEquals(1, child.getBody().getLinks().size(), "Check size");
+ assertEquals(
+ createLinkItem("Foo", "http://foo.apache.org"),
+ child.getBody().getLinks().get(0),
+ "Check item");
- assertEquals( 1, child.getPoweredBy().size(), "Check size" );
- assertEquals( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ), child.getPoweredBy().get( 0 ), "Check item" );
+ assertEquals(1, child.getPoweredBy().size(), "Check size");
+ assertEquals(
+ createLogo("Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg"),
+ child.getPoweredBy().get(0),
+ "Check item");
}
/**
*
*/
@Test
- public void testDuplicateChildElements()
- {
+ public void testDuplicateChildElements() {
DecorationModel model = new DecorationModel();
- model.setBody( new Body() );
- model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
- model.getBody().addLink( createLinkItem( "Foo", "http://foo.apache.org" ) );
+ model.setBody(new Body());
+ model.getBody().addLink(createLinkItem("Foo", "http://foo.apache.org"));
+ model.getBody().addLink(createLinkItem("Foo", "http://foo.apache.org"));
- model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
- model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ) );
+ model.addPoweredBy(createLogo("Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg"));
+ model.addPoweredBy(createLogo("Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg"));
DecorationModel parent = new DecorationModel();
- assembler.assembleModelInheritance( NAME, model, parent, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
+ assembler.assembleModelInheritance(
+ NAME, model, parent, "http://maven.apache.org/doxia", "http://maven.apache.org");
- assertEquals( 1, model.getBody().getLinks().size(), "Check size" );
- assertEquals( createLinkItem( "Foo", "http://foo.apache.org" ), model.getBody().getLinks().get( 0 ), "Check item" );
+ assertEquals(1, model.getBody().getLinks().size(), "Check size");
+ assertEquals(
+ createLinkItem("Foo", "http://foo.apache.org"),
+ model.getBody().getLinks().get(0),
+ "Check item");
- assertEquals( 1, model.getPoweredBy().size(), "Check size" );
- assertEquals( createLogo( "Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg" ), model.getPoweredBy().get( 0 ), "Check item" );
+ assertEquals(1, model.getPoweredBy().size(), "Check size");
+ assertEquals(
+ createLogo("Foo", "http://foo.apache.org", "http://foo.apache.org/foo.jpg"),
+ model.getPoweredBy().get(0),
+ "Check item");
- assertEquals( new DecorationModel(), parent, "Modified parent!" );
+ assertEquals(new DecorationModel(), parent, "Modified parent!");
}
/**
*
*/
@Test
- public void testBadHref()
- {
+ public void testBadHref() {
final DecorationModel model = new DecorationModel();
- model.setBody( new Body() );
- model.getBody().addBreadcrumb( createLinkItem( "Foo", "http://foo.apache.org/${property}" ) );
- assembler.resolvePaths( model, "http://foo.apache.org" );
- assertEquals( 1, model.getBody().getBreadcrumbs().size(), "Check size" );
- assertEquals( createLinkItem( "Foo", "http://foo.apache.org/${property}" ), model.getBody().getBreadcrumbs().get( 0 ), "Check item" );
+ model.setBody(new Body());
+ model.getBody().addBreadcrumb(createLinkItem("Foo", "http://foo.apache.org/${property}"));
+ assembler.resolvePaths(model, "http://foo.apache.org");
+ assertEquals(1, model.getBody().getBreadcrumbs().size(), "Check size");
+ assertEquals(
+ createLinkItem("Foo", "http://foo.apache.org/${property}"),
+ model.getBody().getBreadcrumbs().get(0),
+ "Check item");
}
/**
*
*/
@Test
- public void testBreadcrumbWithoutHref()
- {
+ public void testBreadcrumbWithoutHref() {
DecorationModel model = new DecorationModel();
- model.setBody( new Body() );
- model.getBody().addBreadcrumb( createLinkItem( "Foo", null ) );
- assembler.resolvePaths( model, "http://foo.apache.org" );
- assertEquals( 1, model.getBody().getBreadcrumbs().size(), "Check size" );
- assertEquals( createLinkItem( "Foo", null ), model.getBody().getBreadcrumbs().get( 0 ), "Check item" );
+ model.setBody(new Body());
+ model.getBody().addBreadcrumb(createLinkItem("Foo", null));
+ assembler.resolvePaths(model, "http://foo.apache.org");
+ assertEquals(1, model.getBody().getBreadcrumbs().size(), "Check size");
+ assertEquals(
+ createLinkItem("Foo", null), model.getBody().getBreadcrumbs().get(0), "Check item");
}
/**
*
*/
@Test
- public void testBreadcrumbs()
- {
+ public void testBreadcrumbs() {
String parentHref = "http://parent.com/index.html";
final DecorationModel parent = new DecorationModel();
- parent.setBody( new Body() );
- parent.getBody().addBreadcrumb( createLinkItem( "Parent", parentHref ) );
+ parent.setBody(new Body());
+ parent.getBody().addBreadcrumb(createLinkItem("Parent", parentHref));
DecorationModel child = new DecorationModel();
- assembler.assembleModelInheritance( "childName", child, parent,
- "http://parent.com/child", "http://parent.com" );
- assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref );
-
+ assembler.assembleModelInheritance("childName", child, parent, "http://parent.com/child", "http://parent.com");
+ assertBreadcrumbsCorrect(child.getBody().getBreadcrumbs(), "childName", parentHref);
// same with trailing slash
child = new DecorationModel();
- assembler.assembleModelInheritance( "childName", child, parent,
- "http://parent.com/child/", "http://parent.com/" );
- assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref );
+ assembler.assembleModelInheritance(
+ "childName", child, parent, "http://parent.com/child/", "http://parent.com/");
+ assertBreadcrumbsCorrect(child.getBody().getBreadcrumbs(), "childName", parentHref);
// now mixed
child = new DecorationModel();
- assembler.assembleModelInheritance( "childName", child, parent,
- "http://parent.com/child/", "http://parent.com" );
- assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref );
+ assembler.assembleModelInheritance("childName", child, parent, "http://parent.com/child/", "http://parent.com");
+ assertBreadcrumbsCorrect(child.getBody().getBreadcrumbs(), "childName", parentHref);
// and other way round
child = new DecorationModel();
- assembler.assembleModelInheritance( "childName", child, parent,
- "http://parent.com/child", "http://parent.com/" );
- assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref );
-
+ assembler.assembleModelInheritance("childName", child, parent, "http://parent.com/child", "http://parent.com/");
+ assertBreadcrumbsCorrect(child.getBody().getBreadcrumbs(), "childName", parentHref);
// now with child breadcrumb
child = new DecorationModel();
- child.setBody( new Body() );
- child.getBody().addBreadcrumb( createLinkItem( "Child", "index.html" ) );
- assembler.assembleModelInheritance( "childName", child, parent,
- "http://parent.com/child/", "http://parent.com/" );
- assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "Child", parentHref );
-
+ child.setBody(new Body());
+ child.getBody().addBreadcrumb(createLinkItem("Child", "index.html"));
+ assembler.assembleModelInheritance(
+ "childName", child, parent, "http://parent.com/child/", "http://parent.com/");
+ assertBreadcrumbsCorrect(child.getBody().getBreadcrumbs(), "Child", parentHref);
// now with file url
parentHref = "file://parent.com/index.html";
- ( parent.getBody().getBreadcrumbs().get( 0 ) ).setHref( parentHref );
+ (parent.getBody().getBreadcrumbs().get(0)).setHref(parentHref);
child = new DecorationModel();
- assembler.assembleModelInheritance( "childName", child, parent,
- "file://parent.com/child/", "file://parent.com/" );
- assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref );
-
+ assembler.assembleModelInheritance(
+ "childName", child, parent, "file://parent.com/child/", "file://parent.com/");
+ assertBreadcrumbsCorrect(child.getBody().getBreadcrumbs(), "childName", parentHref);
// now with scp url
parentHref = "scp://parent.com/index.html";
- ( parent.getBody().getBreadcrumbs().get( 0 ) ).setHref( parentHref );
+ (parent.getBody().getBreadcrumbs().get(0)).setHref(parentHref);
child = new DecorationModel();
- assembler.assembleModelInheritance( "childName", child, parent,
- "scp://parent.com/child/", "scp://parent.com/" );
- assertBreadcrumbsCorrect( child.getBody().getBreadcrumbs(), "childName", parentHref );
+ assembler.assembleModelInheritance("childName", child, parent, "scp://parent.com/child/", "scp://parent.com/");
+ assertBreadcrumbsCorrect(child.getBody().getBreadcrumbs(), "childName", parentHref);
}
- private static void assertBreadcrumbsCorrect( final List<LinkItem> breadcrumbs, final String childName,
- final String parentHref )
- {
- assertEquals( 2, breadcrumbs.size(), "Check size" );
- assertEquals( createLinkItem( "Parent", parentHref ), breadcrumbs.get( 0 ), "Check parent item" );
- assertEquals( createLinkItem( childName, "index.html" ), breadcrumbs.get( 1 ), "Check child item" );
+ private static void assertBreadcrumbsCorrect(
+ final List<LinkItem> breadcrumbs, final String childName, final String parentHref) {
+ assertEquals(2, breadcrumbs.size(), "Check size");
+ assertEquals(createLinkItem("Parent", parentHref), breadcrumbs.get(0), "Check parent item");
+ assertEquals(createLinkItem(childName, "index.html"), breadcrumbs.get(1), "Check child item");
}
/**
* https://issues.apache.org/jira/browse/DOXIASITETOOLS-62
*/
@Test
- public void testBreadcrumbCutParentAfterDuplicate()
- {
+ public void testBreadcrumbCutParentAfterDuplicate() {
DecorationModel child = new DecorationModel(); // B > E
- child.setBody( new Body() );
- child.getBody().addBreadcrumb( createLinkItem( "B", null ) );
- child.getBody().addBreadcrumb( createLinkItem( "E", null ) );
+ child.setBody(new Body());
+ child.getBody().addBreadcrumb(createLinkItem("B", null));
+ child.getBody().addBreadcrumb(createLinkItem("E", null));
DecorationModel parent = new DecorationModel(); // A > B > C > D
- parent.setBody( new Body() );
- parent.getBody().addBreadcrumb( createLinkItem( "A", null ) );
- parent.getBody().addBreadcrumb( createLinkItem( "B", null ) );
- parent.getBody().addBreadcrumb( createLinkItem( "C", null ) );
- parent.getBody().addBreadcrumb( createLinkItem( "D", null ) );
+ parent.setBody(new Body());
+ parent.getBody().addBreadcrumb(createLinkItem("A", null));
+ parent.getBody().addBreadcrumb(createLinkItem("B", null));
+ parent.getBody().addBreadcrumb(createLinkItem("C", null));
+ parent.getBody().addBreadcrumb(createLinkItem("D", null));
- assembler.assembleModelInheritance( NAME, child, parent, "http://maven.apache.org/doxia",
- "http://maven.apache.org" );
+ assembler.assembleModelInheritance(
+ NAME, child, parent, "http://maven.apache.org/doxia", "http://maven.apache.org");
final List<LinkItem> breadcrumbs = child.getBody().getBreadcrumbs(); // expected: A > B > E
- assertEquals( 3, breadcrumbs.size(), "Check size" );
- assertEquals( createLinkItem( "A", null ), breadcrumbs.get( 0 ), "Check item" );
- assertEquals( createLinkItem( "B", null ), breadcrumbs.get( 1 ), "Check item" );
- assertEquals( createLinkItem( "E", null ), breadcrumbs.get( 2 ), "Check item" );
+ assertEquals(3, breadcrumbs.size(), "Check size");
+ assertEquals(createLinkItem("A", null), breadcrumbs.get(0), "Check item");
+ assertEquals(createLinkItem("B", null), breadcrumbs.get(1), "Check item");
+ assertEquals(createLinkItem("E", null), breadcrumbs.get(2), "Check item");
}
/**
*
*/
@Test
- public void testBannerWithoutHref()
- {
+ public void testBannerWithoutHref() {
DecorationModel model = new DecorationModel();
- model.setBody( new Body() );
+ model.setBody(new Body());
- Banner banner = createBanner( "Left", null, "/images/src.gif", "alt" );
+ Banner banner = createBanner("Left", null, "/images/src.gif", "alt");
- model.setBannerLeft( banner );
+ model.setBannerLeft(banner);
- assembler.resolvePaths( model, "http://foo.apache.org" );
+ assembler.resolvePaths(model, "http://foo.apache.org");
- assertEquals( createBanner( "Left", null, "images/src.gif", "alt" ), model.getBannerLeft(), "Check banner" );
+ assertEquals(createBanner("Left", null, "images/src.gif", "alt"), model.getBannerLeft(), "Check banner");
}
/**
*
*/
@Test
- public void testLogoWithoutImage()
- {
+ public void testLogoWithoutImage() {
// This should actually be validated in the model, it doesn't really make sense
DecorationModel model = new DecorationModel();
- model.setBody( new Body() );
- model.addPoweredBy( createLogo( "Foo", "http://foo.apache.org", null ) );
- assembler.resolvePaths( model, "http://foo.apache.org" );
- assertEquals( 1, model.getPoweredBy().size(), "Check size" );
- assertEquals( createLogo( "Foo", "./", null ), model.getPoweredBy().get( 0 ), "Check item" );
+ model.setBody(new Body());
+ model.addPoweredBy(createLogo("Foo", "http://foo.apache.org", null));
+ assembler.resolvePaths(model, "http://foo.apache.org");
+ assertEquals(1, model.getPoweredBy().size(), "Check size");
+ assertEquals(createLogo("Foo", "./", null), model.getPoweredBy().get(0), "Check item");
}
- private static Banner createBanner( String name, String href, String src, String alt )
- {
+ private static Banner createBanner(String name, String href, String src, String alt) {
Banner banner = new Banner();
- banner.setName( name );
- banner.setHref( href );
- banner.setSrc( src );
- banner.setAlt( alt );
+ banner.setName(name);
+ banner.setHref(href);
+ banner.setSrc(src);
+ banner.setAlt(alt);
return banner;
}
- private Logo createLogo( String name, String href, String img )
- {
+ private Logo createLogo(String name, String href, String img) {
Logo logo = new Logo();
- logo.setHref( href );
- logo.setImg( img );
- logo.setName( name );
+ logo.setHref(href);
+ logo.setImg(img);
+ logo.setName(name);
return logo;
}
- private static LinkItem createLinkItem( String name, String href )
- {
+ private static LinkItem createLinkItem(String name, String href) {
LinkItem item = new LinkItem();
- item.setName( name );
- item.setHref( href );
+ item.setName(name);
+ item.setHref(href);
return item;
}
- private DecorationModel readModel( String name )
- throws IOException, XmlPullParserException
- {
+ private DecorationModel readModel(String name) throws IOException, XmlPullParserException {
Reader reader = null;
- try
- {
- reader = ReaderFactory.newXmlReader( getClass().getResourceAsStream( "/" + name ) );
- return new DecorationXpp3Reader().read( reader );
- }
- finally
- {
- IOUtil.close( reader );
+ try {
+ reader = ReaderFactory.newXmlReader(getClass().getResourceAsStream("/" + name));
+ return new DecorationXpp3Reader().read(reader);
+ } finally {
+ IOUtil.close(reader);
}
}
}
diff --git a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptorTest.java b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptorTest.java
index 7aa258e..72ce969 100644
--- a/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptorTest.java
+++ b/doxia-decoration-model/src/test/java/org/apache/maven/doxia/site/decoration/inheritance/URIPathDescriptorTest.java
@@ -1,6 +1,3 @@
-
-package org.apache.maven.doxia.site.decoration.inheritance;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,6 +16,7 @@ package org.apache.maven.doxia.site.decoration.inheritance;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.site.decoration.inheritance;
import java.net.URI;
@@ -35,59 +33,59 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*
* @since 1.2
*/
-@SuppressWarnings( "javadoc" )
-public class URIPathDescriptorTest
-{
+@SuppressWarnings("javadoc")
+public class URIPathDescriptorTest {
private static final String BASE_URL = "http://maven.apache.org/";
/**
* Test of constructor, of class URIPathDescriptor.
*/
@Test
- public void testConstructor()
- {
+ public void testConstructor() {
final String expected = BASE_URL + "doxia";
- final URIPathDescriptor path = new URIPathDescriptor( BASE_URL, "doxia" );
- assertEquals( expected, path.toString() );
- assertEquals( BASE_URL, path.getBaseURI().toString() );
- assertEquals( "doxia", path.getLink().toString() );
+ final URIPathDescriptor path = new URIPathDescriptor(BASE_URL, "doxia");
+ assertEquals(expected, path.toString());
+ assertEquals(BASE_URL, path.getBaseURI().toString());
+ assertEquals("doxia", path.getLink().toString());
- URIPathDescriptor compare = new URIPathDescriptor( "http://maven.apache.org", "/doxia" );
- assertEquals( expected, compare.toString() );
+ URIPathDescriptor compare = new URIPathDescriptor("http://maven.apache.org", "/doxia");
+ assertEquals(expected, compare.toString());
- compare = new URIPathDescriptor( "http://maven.apache.org/./doxia/../", "/sub/./sub/../../doxia" );
- assertEquals( expected, compare.toString() );
+ compare = new URIPathDescriptor("http://maven.apache.org/./doxia/../", "/sub/./sub/../../doxia");
+ assertEquals(expected, compare.toString());
- compare = new URIPathDescriptor( "http://maven.apache.org/doxia", "" );
- assertEquals( expected + "/", compare.toString() );
+ compare = new URIPathDescriptor("http://maven.apache.org/doxia", "");
+ assertEquals(expected + "/", compare.toString());
- compare = new URIPathDescriptor( "file:///C:\\Foo\\bar1", "" );
- assertEquals( "file:///C:/Foo/bar1/", compare.getBaseURI().toString() );
+ compare = new URIPathDescriptor("file:///C:\\Foo\\bar1", "");
+ assertEquals("file:///C:/Foo/bar1/", compare.getBaseURI().toString());
// toString() calls resolve() which removes two slashes because authority is empty
- assertEquals( "file:/C:/Foo/bar1/", compare.toString() );
+ assertEquals("file:/C:/Foo/bar1/", compare.toString());
- compare = new URIPathDescriptor( "file:///C:/Documents%20and%20Settings/foo/", "bar" );
- assertEquals( "file:/C:/Documents%20and%20Settings/foo/bar", compare.toString() );
+ compare = new URIPathDescriptor("file:///C:/Documents%20and%20Settings/foo/", "bar");
+ assertEquals("file:/C:/Documents%20and%20Settings/foo/bar", compare.toString());
- compare = new URIPathDescriptor( "file:////Users/", "user" );
- assertEquals( "file:/Users/user", compare.toString() );
+ compare = new URIPathDescriptor("file:////Users/", "user");
+ assertEquals("file:/Users/user", compare.toString());
- compare = new URIPathDescriptor( "file:/C:/Documents%20and%20Settings/foo/", "bar" );
- assertEquals( "file:/C:/Documents%20and%20Settings/foo/bar", compare.toString() );
+ compare = new URIPathDescriptor("file:/C:/Documents%20and%20Settings/foo/", "bar");
+ assertEquals("file:/C:/Documents%20and%20Settings/foo/bar", compare.toString());
- compare = new URIPathDescriptor( "file://C:/Documents%20and%20Settings/foo/", "bar" );
+ compare = new URIPathDescriptor("file://C:/Documents%20and%20Settings/foo/", "bar");
// toString() calls resolve() which removes the colon if port is empty, C is the host here!
- assertEquals( "file://C/Documents%20and%20Settings/foo/bar", compare.toString() );
+ assertEquals("file://C/Documents%20and%20Settings/foo/bar", compare.toString());
- compare = new URIPathDescriptor( "file://C:8080/Documents%20and%20Settings/foo/", "bar" );
- assertEquals( "file://C:8080/Documents%20and%20Settings/foo/bar", compare.toString() );
+ compare = new URIPathDescriptor("file://C:8080/Documents%20and%20Settings/foo/", "bar");
+ assertEquals("file://C:8080/Documents%20and%20Settings/foo/bar", compare.toString());
- compare = new URIPathDescriptor( "C:\\Foo\\bar", "bar" );
- assertEquals( "C:/Foo/bar/bar", compare.toString() ); // NOTE: C: is the scheme here!
+ compare = new URIPathDescriptor("C:\\Foo\\bar", "bar");
+ assertEquals("C:/Foo/bar/bar", compare.toString()); // NOTE: C: is the scheme here!
- assertThrows( IllegalArgumentException.class, () -> new URIPathDescriptor( "/doxia", BASE_URL ) );
- assertThrows( IllegalArgumentException.class, () -> new URIPathDescriptor( "file:///C:/Documents and Settings/foo/", "bar" ) );
+ assertThrows(IllegalArgumentException.class, () -> new URIPathDescriptor("/doxia", BASE_URL));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new URIPathDescriptor("file:///C:/Documents and Settings/foo/", "bar"));
}
/**
@@ -96,146 +94,167 @@ public class URIPathDescriptorTest
* @throws Exception
*/
@Test
- public void testResolveLink()
- {
+ public void testResolveLink() {
final String expected = BASE_URL + "source";
- URIPathDescriptor oldPath = new URIPathDescriptor( BASE_URL, "source" );
- assertEquals( expected, oldPath.resolveLink().toString() );
+ URIPathDescriptor oldPath = new URIPathDescriptor(BASE_URL, "source");
+ assertEquals(expected, oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( BASE_URL, "source/" );
- assertEquals( expected + "/", oldPath.resolveLink().toString() );
+ oldPath = new URIPathDescriptor(BASE_URL, "source/");
+ assertEquals(expected + "/", oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( BASE_URL, "/source" );
- assertEquals( expected, oldPath.resolveLink().toString() );
+ oldPath = new URIPathDescriptor(BASE_URL, "/source");
+ assertEquals(expected, oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( "http://maven.apache.org", "source" );
- assertEquals( expected, oldPath.resolveLink().toString() );
+ oldPath = new URIPathDescriptor("http://maven.apache.org", "source");
+ assertEquals(expected, oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( BASE_URL, "source/index.html" );
- assertEquals( expected + "/index.html", oldPath.resolveLink().toString() );
+ oldPath = new URIPathDescriptor(BASE_URL, "source/index.html");
+ assertEquals(expected + "/index.html", oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( BASE_URL, "source/index.html?var=foo&var2=bar" );
- assertEquals( expected + "/index.html?var=foo&var2=bar", oldPath.resolveLink().toString() );
+ oldPath = new URIPathDescriptor(BASE_URL, "source/index.html?var=foo&var2=bar");
+ assertEquals(
+ expected + "/index.html?var=foo&var2=bar",
+ oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( "file:////Users/", "user" );
- assertEquals( "file:/Users/user", oldPath.resolveLink().toString() );
+ oldPath = new URIPathDescriptor("file:////Users/", "user");
+ assertEquals("file:/Users/user", oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( "file:///C:/Documents%20and%20Settings/", "source" );
+ oldPath = new URIPathDescriptor("file:///C:/Documents%20and%20Settings/", "source");
// resolve() removes two slashes because authority is empty
- assertEquals( "file:/C:/Documents%20and%20Settings/source", oldPath.resolveLink().toString() );
+ assertEquals(
+ "file:/C:/Documents%20and%20Settings/source",
+ oldPath.resolveLink().toString());
- oldPath = new URIPathDescriptor( "file://C:/Documents%20and%20Settings/", "source" );
+ oldPath = new URIPathDescriptor("file://C:/Documents%20and%20Settings/", "source");
// resolve() removes the colon if port is empty
- assertEquals( "file://C/Documents%20and%20Settings/source", oldPath.resolveLink().toString() );
-
- oldPath = new URIPathDescriptor( "file:/C:/Documents%20and%20Settings/", "source" );
- assertEquals( "file:/C:/Documents%20and%20Settings/source", oldPath.resolveLink().toString() );
+ assertEquals(
+ "file://C/Documents%20and%20Settings/source",
+ oldPath.resolveLink().toString());
+
+ oldPath = new URIPathDescriptor("file:/C:/Documents%20and%20Settings/", "source");
+ assertEquals(
+ "file:/C:/Documents%20and%20Settings/source",
+ oldPath.resolveLink().toString());
}
/**
* Test of rebaseLink method, of class URIPathDescriptor.
*/
@Test
- public void testRebaseLink()
- {
- URIPathDescriptor oldPath = new URIPathDescriptor( BASE_URL, "source" );
- assertEquals( "../source", oldPath.rebaseLink( "http://maven.apache.org/doxia/" ).toString() );
- assertEquals( "http://maven.apache.org/source", oldPath.rebaseLink( null ).toString() );
- assertEquals( "http://maven.apache.org/source",
- oldPath.rebaseLink( "C:/Documents and Settings/" ).toString() );
-
- oldPath = new URIPathDescriptor( BASE_URL, "./" );
- assertEquals( "", oldPath.rebaseLink( "http://maven.apache.org/" ).toString() );
-
- oldPath = new URIPathDescriptor( BASE_URL, "" );
- assertEquals( "", oldPath.rebaseLink( "http://maven.apache.org/" ).toString() );
-
- oldPath = new URIPathDescriptor( BASE_URL, "source/index.html" );
- assertEquals( "../source/index.html",
- oldPath.rebaseLink( "http://maven.apache.org/doxia/" ).toString() );
-
- oldPath = new URIPathDescriptor( BASE_URL, "source/index.html?var=foo&var2=bar" );
- assertEquals( "../source/index.html?var=foo&var2=bar",
- oldPath.rebaseLink( "http://maven.apache.org/doxia/" ).toString() );
-
- oldPath = new URIPathDescriptor( "scp://people.apache.org/", "source" );
- assertEquals( "../source", oldPath.rebaseLink( "scp://people.apache.org/doxia" ).toString() );
-
- oldPath = new URIPathDescriptor( BASE_URL, "banner/left" );
- assertEquals( "../banner/left", oldPath.rebaseLink( "http://maven.apache.org/doxia/" ).toString() );
-
- oldPath = new URIPathDescriptor( BASE_URL, "index.html?var=foo&var2=bar" );
- assertEquals( "../index.html?var=foo&var2=bar",
- oldPath.rebaseLink( "http://maven.apache.org/doxia/" ).toString() );
-
- oldPath = new URIPathDescriptor( "http://jakarta.apache.org/", "banner/left" );
- assertEquals( "http://jakarta.apache.org/banner/left", oldPath.rebaseLink( BASE_URL ).toString() );
-
- oldPath = new URIPathDescriptor( "file:////Users/", "user" );
- assertEquals( "../user", oldPath.rebaseLink( "file:////Users/target" ).toString() );
- assertEquals( "../user", oldPath.rebaseLink( "file:/Users/target" ).toString() );
-
- oldPath = new URIPathDescriptor( "file:///C:/Documents%20and%20Settings/", "source" );
- assertEquals( "../source",
- oldPath.rebaseLink( "file:///C:/Documents%20and%20Settings/target" ).toString() );
-
- oldPath = new URIPathDescriptor( "file://C:/Documents%20and%20Settings/", "source" );
- assertEquals( "../source",
- oldPath.rebaseLink( "file://C:/Documents%20and%20Settings/target" ).toString() );
-
- oldPath = new URIPathDescriptor( "file:/C:/Documents%20and%20Settings/", "source" );
- assertEquals( "../source",
- oldPath.rebaseLink( "file:/C:/Documents%20and%20Settings/target" ).toString() );
+ public void testRebaseLink() {
+ URIPathDescriptor oldPath = new URIPathDescriptor(BASE_URL, "source");
+ assertEquals(
+ "../source",
+ oldPath.rebaseLink("http://maven.apache.org/doxia/").toString());
+ assertEquals("http://maven.apache.org/source", oldPath.rebaseLink(null).toString());
+ assertEquals(
+ "http://maven.apache.org/source",
+ oldPath.rebaseLink("C:/Documents and Settings/").toString());
+
+ oldPath = new URIPathDescriptor(BASE_URL, "./");
+ assertEquals("", oldPath.rebaseLink("http://maven.apache.org/").toString());
+
+ oldPath = new URIPathDescriptor(BASE_URL, "");
+ assertEquals("", oldPath.rebaseLink("http://maven.apache.org/").toString());
+
+ oldPath = new URIPathDescriptor(BASE_URL, "source/index.html");
+ assertEquals(
+ "../source/index.html",
+ oldPath.rebaseLink("http://maven.apache.org/doxia/").toString());
+
+ oldPath = new URIPathDescriptor(BASE_URL, "source/index.html?var=foo&var2=bar");
+ assertEquals(
+ "../source/index.html?var=foo&var2=bar",
+ oldPath.rebaseLink("http://maven.apache.org/doxia/").toString());
+
+ oldPath = new URIPathDescriptor("scp://people.apache.org/", "source");
+ assertEquals(
+ "../source", oldPath.rebaseLink("scp://people.apache.org/doxia").toString());
+
+ oldPath = new URIPathDescriptor(BASE_URL, "banner/left");
+ assertEquals(
+ "../banner/left",
+ oldPath.rebaseLink("http://maven.apache.org/doxia/").toString());
+
+ oldPath = new URIPathDescriptor(BASE_URL, "index.html?var=foo&var2=bar");
+ assertEquals(
+ "../index.html?var=foo&var2=bar",
+ oldPath.rebaseLink("http://maven.apache.org/doxia/").toString());
+
+ oldPath = new URIPathDescriptor("http://jakarta.apache.org/", "banner/left");
+ assertEquals(
+ "http://jakarta.apache.org/banner/left",
+ oldPath.rebaseLink(BASE_URL).toString());
+
+ oldPath = new URIPathDescriptor("file:////Users/", "user");
+ assertEquals("../user", oldPath.rebaseLink("file:////Users/target").toString());
+ assertEquals("../user", oldPath.rebaseLink("file:/Users/target").toString());
+
+ oldPath = new URIPathDescriptor("file:///C:/Documents%20and%20Settings/", "source");
+ assertEquals(
+ "../source",
+ oldPath.rebaseLink("file:///C:/Documents%20and%20Settings/target")
+ .toString());
+
+ oldPath = new URIPathDescriptor("file://C:/Documents%20and%20Settings/", "source");
+ assertEquals(
+ "../source",
+ oldPath.rebaseLink("file://C:/Documents%20and%20Settings/target")
+ .toString());
+
+ oldPath = new URIPathDescriptor("file:/C:/Documents%20and%20Settings/", "source");
+ assertEquals(
+ "../source",
+ oldPath.rebaseLink("file:/C:/Documents%20and%20Settings/target").toString());
}
/**
* Test of relativizeLink method, of class URIPathDescriptor.
*/
@Test
- public void testRelativizeLink()
- {
- URIPathDescriptor path = new URIPathDescriptor( BASE_URL, "source" );
- assertEquals( "source", path.relativizeLink().toString() );
+ public void testRelativizeLink() {
+ URIPathDescriptor path = new URIPathDescriptor(BASE_URL, "source");
+ assertEquals("source", path.relativizeLink().toString());
- path = new URIPathDescriptor( BASE_URL, "http://maven.apache.org/source" );
- assertEquals( "source", path.relativizeLink().toString() );
+ path = new URIPathDescriptor(BASE_URL, "http://maven.apache.org/source");
+ assertEquals("source", path.relativizeLink().toString());
- path = new URIPathDescriptor( BASE_URL, "http://maven.apache.org/" );
- assertEquals( "./", path.relativizeLink().toString() );
+ path = new URIPathDescriptor(BASE_URL, "http://maven.apache.org/");
+ assertEquals("./", path.relativizeLink().toString());
- path = new URIPathDescriptor( BASE_URL, "http://maven.apache.org" );
- assertEquals( "./", path.relativizeLink().toString() );
+ path = new URIPathDescriptor(BASE_URL, "http://maven.apache.org");
+ assertEquals("./", path.relativizeLink().toString());
- path = new URIPathDescriptor( "http://maven.apache.org", BASE_URL );
- assertEquals( "./", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("http://maven.apache.org", BASE_URL);
+ assertEquals("./", path.relativizeLink().toString());
- path = new URIPathDescriptor( "http://maven.apache.org", "http://maven.apache.org" );
- assertEquals( "./", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("http://maven.apache.org", "http://maven.apache.org");
+ assertEquals("./", path.relativizeLink().toString());
- path = new URIPathDescriptor( "http://maven.apache.org/doxia/", "http://maven.apache.org/source/" );
- assertEquals( "../source/", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("http://maven.apache.org/doxia/", "http://maven.apache.org/source/");
+ assertEquals("../source/", path.relativizeLink().toString());
- path = new URIPathDescriptor( "http://maven.apache.org/doxia", "http://maven.apache.org/source" );
- assertEquals( "../source", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("http://maven.apache.org/doxia", "http://maven.apache.org/source");
+ assertEquals("../source", path.relativizeLink().toString());
- path = new URIPathDescriptor( BASE_URL, "http://maven.apache.org/index.html" );
- assertEquals( "index.html", path.relativizeLink().toString() );
+ path = new URIPathDescriptor(BASE_URL, "http://maven.apache.org/index.html");
+ assertEquals("index.html", path.relativizeLink().toString());
- path = new URIPathDescriptor( BASE_URL, "http://maven.apache.org/index.html?var=foo&var2=bar" );
- assertEquals( "index.html?var=foo&var2=bar", path.relativizeLink().toString() );
+ path = new URIPathDescriptor(BASE_URL, "http://maven.apache.org/index.html?var=foo&var2=bar");
+ assertEquals("index.html?var=foo&var2=bar", path.relativizeLink().toString());
- path = new URIPathDescriptor( "file:////Users/", "index.html" );
- assertEquals( "index.html", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("file:////Users/", "index.html");
+ assertEquals("index.html", path.relativizeLink().toString());
- path = new URIPathDescriptor( "file:///C:/Documents%20and%20Settings/", "index.html" );
- assertEquals( "index.html", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("file:///C:/Documents%20and%20Settings/", "index.html");
+ assertEquals("index.html", path.relativizeLink().toString());
- path = new URIPathDescriptor( "file://C:/Documents%20and%20Settings/", "index.html" );
- assertEquals( "index.html", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("file://C:/Documents%20and%20Settings/", "index.html");
+ assertEquals("index.html", path.relativizeLink().toString());
- path = new URIPathDescriptor( "file:/C:/Documents%20and%20Settings/", "index.html" );
- assertEquals( "index.html", path.relativizeLink().toString() );
+ path = new URIPathDescriptor("file:/C:/Documents%20and%20Settings/", "index.html");
+ assertEquals("index.html", path.relativizeLink().toString());
}
/**
@@ -244,33 +263,30 @@ public class URIPathDescriptorTest
* @throws Exception
*/
@Test
- public void testSameSite()
- throws Exception
- {
- final URIPathDescriptor path = new URIPathDescriptor( BASE_URL, "doxia" );
-
- assertTrue( path.sameSite( new URI( "http://maven.apache.org/" ) ) );
- assertTrue( path.sameSite( new URI( "http://maven.apache.org" ) ) );
- assertTrue( path.sameSite( new URI( "HTTP://maven.apache.org/" ) ) );
- assertTrue( path.sameSite( new URI( "http://MAVEN.apache.org/" ) ) );
- assertTrue( path.sameSite( new URI( "http://maven.apache.org/wagon/index.html" ) ) );
-
- assertFalse( path.sameSite( null ) );
- assertFalse( path.sameSite( new URI( "https://maven.apache.org/" ) ) );
- assertFalse( path.sameSite( new URI( "http://ant.apache.org/" ) ) );
- assertFalse( path.sameSite( new URI( "http://maven.apache.org:80" ) ) );
- assertFalse( path.sameSite( new URI( "/usr/share/bin/" ) ) );
- assertFalse( path.sameSite( new URI( "http:///maven.apache.org/" ) ) );
-
- final URIPathDescriptor nullHost = new URIPathDescriptor( "http:///maven.apache.org/", "doxia" );
- assertTrue( nullHost.sameSite( new URI( "http:///maven.apache.org/" ) ) );
- assertFalse( nullHost.sameSite( new URI( "http://maven.apache.org/" ) ) );
-
- URIPathDescriptor newPath = new URIPathDescriptor( "file:///C:/Documents%20and%20Settings/", "source" );
- assertTrue( newPath.sameSite( new URI( "file:///C:/Documents%20and%20Settings/" ) ) );
- assertFalse( newPath.sameSite( new URI( "file://C:/Documents%20and%20Settings/" ) ) );
+ public void testSameSite() throws Exception {
+ final URIPathDescriptor path = new URIPathDescriptor(BASE_URL, "doxia");
+
+ assertTrue(path.sameSite(new URI("http://maven.apache.org/")));
+ assertTrue(path.sameSite(new URI("http://maven.apache.org")));
+ assertTrue(path.sameSite(new URI("HTTP://maven.apache.org/")));
+ assertTrue(path.sameSite(new URI("http://MAVEN.apache.org/")));
+ assertTrue(path.sameSite(new URI("http://maven.apache.org/wagon/index.html")));
+
+ assertFalse(path.sameSite(null));
+ assertFalse(path.sameSite(new URI("https://maven.apache.org/")));
+ assertFalse(path.sameSite(new URI("http://ant.apache.org/")));
+ assertFalse(path.sameSite(new URI("http://maven.apache.org:80")));
+ assertFalse(path.sameSite(new URI("/usr/share/bin/")));
+ assertFalse(path.sameSite(new URI("http:///maven.apache.org/")));
+
+ final URIPathDescriptor nullHost = new URIPathDescriptor("http:///maven.apache.org/", "doxia");
+ assertTrue(nullHost.sameSite(new URI("http:///maven.apache.org/")));
+ assertFalse(nullHost.sameSite(new URI("http://maven.apache.org/")));
+
+ URIPathDescriptor newPath = new URIPathDescriptor("file:///C:/Documents%20and%20Settings/", "source");
+ assertTrue(newPath.sameSite(new URI("file:///C:/Documents%20and%20Settings/")));
+ assertFalse(newPath.sameSite(new URI("file://C:/Documents%20and%20Settings/")));
// authority is empty
- assertTrue( newPath.sameSite( new URI( "file:/C:/Documents%20and%20Settings/" ) ) );
+ assertTrue(newPath.sameSite(new URI("file:/C:/Documents%20and%20Settings/")));
}
-
}
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
index 17bf7d0..7b95cb8 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.tools;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.tools;
import javax.inject.Inject;
import javax.inject.Named;
@@ -67,15 +66,15 @@ import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingResult;
import org.apache.maven.reporting.MavenReport;
import org.codehaus.plexus.i18n.I18N;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.interpolation.EnvarBasedValueSource;
import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.MapBasedValueSource;
import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource;
import org.codehaus.plexus.interpolation.RegexBasedInterpolator;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.slf4j.Logger;
@@ -88,10 +87,8 @@ import org.slf4j.LoggerFactory;
*/
@Singleton
@Named
-public class DefaultSiteTool
- implements SiteTool
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( DefaultSiteTool.class );
+public class DefaultSiteTool implements SiteTool {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSiteTool.class);
// ----------------------------------------------------------------------
// Components
@@ -131,41 +128,33 @@ public class DefaultSiteTool
// Public methods
// ----------------------------------------------------------------------
- public Artifact getSkinArtifactFromRepository( ArtifactRepository localRepository,
- List<ArtifactRepository> remoteArtifactRepositories,
- DecorationModel decoration )
- throws SiteToolException
- {
- Objects.requireNonNull( localRepository, "localRepository cannot be null" );
- Objects.requireNonNull( remoteArtifactRepositories, "remoteArtifactRepositories cannot be null" );
- Objects.requireNonNull( decoration, "decoration cannot be null" );
- Skin skin = Objects.requireNonNull( decoration.getSkin(), "decoration.skin cannot be null" );
+ public Artifact getSkinArtifactFromRepository(
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteArtifactRepositories,
+ DecorationModel decoration)
+ throws SiteToolException {
+ Objects.requireNonNull(localRepository, "localRepository cannot be null");
+ Objects.requireNonNull(remoteArtifactRepositories, "remoteArtifactRepositories cannot be null");
+ Objects.requireNonNull(decoration, "decoration cannot be null");
+ Skin skin = Objects.requireNonNull(decoration.getSkin(), "decoration.skin cannot be null");
String version = skin.getVersion();
Artifact artifact;
- try
- {
- if ( version == null )
- {
+ try {
+ if (version == null) {
version = Artifact.RELEASE_VERSION;
}
- VersionRange versionSpec = VersionRange.createFromVersionSpec( version );
- artifact = artifactFactory.createDependencyArtifact( skin.getGroupId(), skin.getArtifactId(), versionSpec,
- "jar", null, null );
+ VersionRange versionSpec = VersionRange.createFromVersionSpec(version);
+ artifact = artifactFactory.createDependencyArtifact(
+ skin.getGroupId(), skin.getArtifactId(), versionSpec, "jar", null, null);
- artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository );
- }
- catch ( InvalidVersionSpecificationException e )
- {
- throw new SiteToolException( "The skin version '" + version + "' is not valid", e );
- }
- catch ( ArtifactResolutionException e )
- {
- throw new SiteToolException( "Unable to find skin", e );
- }
- catch ( ArtifactNotFoundException e )
- {
- throw new SiteToolException( "The skin does not exist", e );
+ artifactResolver.resolve(artifact, remoteArtifactRepositories, localRepository);
+ } catch (InvalidVersionSpecificationException e) {
+ throw new SiteToolException("The skin version '" + version + "' is not valid", e);
+ } catch (ArtifactResolutionException e) {
+ throw new SiteToolException("Unable to find skin", e);
+ } catch (ArtifactNotFoundException e) {
+ throw new SiteToolException("The skin does not exist", e);
}
return artifact;
@@ -177,17 +166,14 @@ public class DefaultSiteTool
* implemented method from a different library such as org.apache.http.client.utils.URIUtils#resolve.
*/
@Deprecated
- public String getRelativePath( String to, String from )
- {
- Objects.requireNonNull( to, "to cannot be null" );
- Objects.requireNonNull( from, "from cannot be null" );
-
- if ( to.contains( ":" ) && from.contains( ":" ) )
- {
- String toScheme = to.substring( 0, to.lastIndexOf( ':' ) );
- String fromScheme = from.substring( 0, from.lastIndexOf( ':' ) );
- if ( !toScheme.equals( fromScheme ) )
- {
+ public String getRelativePath(String to, String from) {
+ Objects.requireNonNull(to, "to cannot be null");
+ Objects.requireNonNull(from, "from cannot be null");
+
+ if (to.contains(":") && from.contains(":")) {
+ String toScheme = to.substring(0, to.lastIndexOf(':'));
+ String fromScheme = from.substring(0, from.lastIndexOf(':'));
+ if (!toScheme.equals(fromScheme)) {
return to;
}
}
@@ -198,62 +184,44 @@ public class DefaultSiteTool
String toPath = to;
String fromPath = from;
- try
- {
- toUrl = new URL( to );
- }
- catch ( MalformedURLException e )
- {
- try
- {
- toUrl = new File( getNormalizedPath( to ) ).toURI().toURL();
- }
- catch ( MalformedURLException e1 )
- {
- LOGGER.warn( "Unable to load a URL for '" + to + "'", e );
+ try {
+ toUrl = new URL(to);
+ } catch (MalformedURLException e) {
+ try {
+ toUrl = new File(getNormalizedPath(to)).toURI().toURL();
+ } catch (MalformedURLException e1) {
+ LOGGER.warn("Unable to load a URL for '" + to + "'", e);
return to;
}
}
- try
- {
- fromUrl = new URL( from );
- }
- catch ( MalformedURLException e )
- {
- try
- {
- fromUrl = new File( getNormalizedPath( from ) ).toURI().toURL();
- }
- catch ( MalformedURLException e1 )
- {
- LOGGER.warn( "Unable to load a URL for '" + from + "'", e );
+ try {
+ fromUrl = new URL(from);
+ } catch (MalformedURLException e) {
+ try {
+ fromUrl = new File(getNormalizedPath(from)).toURI().toURL();
+ } catch (MalformedURLException e1) {
+ LOGGER.warn("Unable to load a URL for '" + from + "'", e);
return to;
}
}
- if ( toUrl != null && fromUrl != null )
- {
+ if (toUrl != null && fromUrl != null) {
// URLs, determine if they share protocol and domain info
- if ( ( toUrl.getProtocol().equalsIgnoreCase( fromUrl.getProtocol() ) )
- && ( toUrl.getHost().equalsIgnoreCase( fromUrl.getHost() ) )
- && ( toUrl.getPort() == fromUrl.getPort() ) )
- {
+ if ((toUrl.getProtocol().equalsIgnoreCase(fromUrl.getProtocol()))
+ && (toUrl.getHost().equalsIgnoreCase(fromUrl.getHost()))
+ && (toUrl.getPort() == fromUrl.getPort())) {
// shared URL domain details, use URI to determine relative path
toPath = toUrl.getFile();
fromPath = fromUrl.getFile();
- }
- else
- {
+ } else {
// don't share basic URL information, no relative available
return to;
}
- }
- else if ( ( toUrl != null && fromUrl == null ) || ( toUrl == null && fromUrl != null ) )
- {
+ } else if ((toUrl != null && fromUrl == null) || (toUrl == null && fromUrl != null)) {
// one is a URL and the other isn't, no relative available.
return to;
@@ -263,81 +231,70 @@ public class DefaultSiteTool
// share the common protocol and domain info and we are left
// with their URI information
- String relativePath = getRelativeFilePath( fromPath, toPath );
+ String relativePath = getRelativeFilePath(fromPath, toPath);
- if ( relativePath == null )
- {
+ if (relativePath == null) {
relativePath = to;
}
- if ( LOGGER.isDebugEnabled() && !relativePath.toString().equals( to ) )
- {
- LOGGER.debug( "Mapped url: " + to + " to relative path: " + relativePath );
+ if (LOGGER.isDebugEnabled() && !relativePath.toString().equals(to)) {
+ LOGGER.debug("Mapped url: " + to + " to relative path: " + relativePath);
}
return relativePath;
}
- private static String getRelativeFilePath( final String oldPath, final String newPath )
- {
+ private static String getRelativeFilePath(final String oldPath, final String newPath) {
// normalize the path delimiters
- String fromPath = new File( oldPath ).getPath();
- String toPath = new File( newPath ).getPath();
+ String fromPath = new File(oldPath).getPath();
+ String toPath = new File(newPath).getPath();
// strip any leading slashes if its a windows path
- if ( toPath.matches( "^\\[a-zA-Z]:" ) )
- {
- toPath = toPath.substring( 1 );
+ if (toPath.matches("^\\[a-zA-Z]:")) {
+ toPath = toPath.substring(1);
}
- if ( fromPath.matches( "^\\[a-zA-Z]:" ) )
- {
- fromPath = fromPath.substring( 1 );
+ if (fromPath.matches("^\\[a-zA-Z]:")) {
+ fromPath = fromPath.substring(1);
}
// lowercase windows drive letters.
- if ( fromPath.startsWith( ":", 1 ) )
- {
- fromPath = Character.toLowerCase( fromPath.charAt( 0 ) ) + fromPath.substring( 1 );
+ if (fromPath.startsWith(":", 1)) {
+ fromPath = Character.toLowerCase(fromPath.charAt(0)) + fromPath.substring(1);
}
- if ( toPath.startsWith( ":", 1 ) )
- {
- toPath = Character.toLowerCase( toPath.charAt( 0 ) ) + toPath.substring( 1 );
+ if (toPath.startsWith(":", 1)) {
+ toPath = Character.toLowerCase(toPath.charAt(0)) + toPath.substring(1);
}
// check for the presence of windows drives. No relative way of
// traversing from one to the other.
- if ( ( toPath.startsWith( ":", 1 ) && fromPath.startsWith( ":", 1 ) )
- && ( !toPath.substring( 0, 1 ).equals( fromPath.substring( 0, 1 ) ) ) )
- {
+ if ((toPath.startsWith(":", 1) && fromPath.startsWith(":", 1))
+ && (!toPath.substring(0, 1).equals(fromPath.substring(0, 1)))) {
// they both have drive path element but they don't match, no
// relative path
return null;
}
- if ( ( toPath.startsWith( ":", 1 ) && !fromPath.startsWith( ":", 1 ) )
- || ( !toPath.startsWith( ":", 1 ) && fromPath.startsWith( ":", 1 ) ) )
- {
+ if ((toPath.startsWith(":", 1) && !fromPath.startsWith(":", 1))
+ || (!toPath.startsWith(":", 1) && fromPath.startsWith(":", 1))) {
// one has a drive path element and the other doesn't, no relative
// path.
return null;
-
}
- final String relativePath = buildRelativePath( toPath, fromPath, File.separatorChar );
+ final String relativePath = buildRelativePath(toPath, fromPath, File.separatorChar);
return relativePath.toString();
}
/** {@inheritDoc} */
- public File getSiteDescriptor( File siteDirectory, Locale locale )
- {
- Objects.requireNonNull( siteDirectory, "siteDirectory cannot be null" );
- Objects.requireNonNull( locale, "locale cannot be null" );
+ public File getSiteDescriptor(File siteDirectory, Locale locale) {
+ Objects.requireNonNull(siteDirectory, "siteDirectory cannot be null");
+ Objects.requireNonNull(locale, "locale cannot be null");
String variant = locale.getVariant();
String country = locale.getCountry();
@@ -345,24 +302,20 @@ public class DefaultSiteTool
File siteDescriptor = null;
- if ( !variant.isEmpty() )
- {
- siteDescriptor = new File( siteDirectory, "site_" + language + "_" + country + "_" + variant + ".xml" );
+ if (!variant.isEmpty()) {
+ siteDescriptor = new File(siteDirectory, "site_" + language + "_" + country + "_" + variant + ".xml");
}
- if ( ( siteDescriptor == null || !siteDescriptor.isFile() ) && !country.isEmpty() )
- {
- siteDescriptor = new File( siteDirectory, "site_" + language + "_" + country + ".xml" );
+ if ((siteDescriptor == null || !siteDescriptor.isFile()) && !country.isEmpty()) {
+ siteDescriptor = new File(siteDirectory, "site_" + language + "_" + country + ".xml");
}
- if ( ( siteDescriptor == null || !siteDescriptor.isFile() ) && !language.isEmpty() )
- {
- siteDescriptor = new File( siteDirectory, "site_" + language + ".xml" );
+ if ((siteDescriptor == null || !siteDescriptor.isFile()) && !language.isEmpty()) {
+ siteDescriptor = new File(siteDirectory, "site_" + language + ".xml");
}
- if ( siteDescriptor == null || !siteDescriptor.isFile() )
- {
- siteDescriptor = new File( siteDirectory, "site.xml" );
+ if (siteDescriptor == null || !siteDescriptor.isFile()) {
+ siteDescriptor = new File(siteDirectory, "site.xml");
}
return siteDescriptor;
@@ -380,144 +333,123 @@ public class DefaultSiteTool
* found in repositories.
* @throws SiteToolException if any
*/
- File getSiteDescriptorFromRepository( MavenProject project, ArtifactRepository localRepository,
- List<ArtifactRepository> repositories, Locale locale )
- throws SiteToolException
- {
- Objects.requireNonNull( project, "project cannot be null" );
- Objects.requireNonNull( localRepository, "localRepository cannot be null" );
- Objects.requireNonNull( repositories, "repositories cannot be null" );
- Objects.requireNonNull( locale, "locale cannot be null" );
-
- try
- {
- return resolveSiteDescriptor( project, localRepository, repositories, locale );
- }
- catch ( ArtifactNotFoundException e )
- {
- LOGGER.debug( "Unable to locate site descriptor", e );
+ File getSiteDescriptorFromRepository(
+ MavenProject project,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> repositories,
+ Locale locale)
+ throws SiteToolException {
+ Objects.requireNonNull(project, "project cannot be null");
+ Objects.requireNonNull(localRepository, "localRepository cannot be null");
+ Objects.requireNonNull(repositories, "repositories cannot be null");
+ Objects.requireNonNull(locale, "locale cannot be null");
+
+ try {
+ return resolveSiteDescriptor(project, localRepository, repositories, locale);
+ } catch (ArtifactNotFoundException e) {
+ LOGGER.debug("Unable to locate site descriptor", e);
return null;
- }
- catch ( ArtifactResolutionException e )
- {
- throw new SiteToolException( "Unable to locate site descriptor", e );
- }
- catch ( IOException e )
- {
- throw new SiteToolException( "Unable to locate site descriptor", e );
+ } catch (ArtifactResolutionException e) {
+ throw new SiteToolException("Unable to locate site descriptor", e);
+ } catch (IOException e) {
+ throw new SiteToolException("Unable to locate site descriptor", e);
}
}
/** {@inheritDoc} */
- public DecorationModel getDecorationModel( File siteDirectory, Locale locale, MavenProject project,
- List<MavenProject> reactorProjects, ArtifactRepository localRepository,
- List<ArtifactRepository> repositories )
- throws SiteToolException
- {
- Objects.requireNonNull( locale, "locale cannot be null" );
- Objects.requireNonNull( project, "project cannot be null" );
- Objects.requireNonNull( reactorProjects, "reactorProjects cannot be null" );
- Objects.requireNonNull( localRepository, "localRepository cannot be null" );
- Objects.requireNonNull( repositories, "repositories cannot be null" );
-
- LOGGER.debug( "Computing decoration model of '" + project.getId() + "' for "
- + ( locale.equals( SiteTool.DEFAULT_LOCALE ) ? "default locale" : "locale '" + locale + "'" ) );
+ public DecorationModel getDecorationModel(
+ File siteDirectory,
+ Locale locale,
+ MavenProject project,
+ List<MavenProject> reactorProjects,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> repositories)
+ throws SiteToolException {
+ Objects.requireNonNull(locale, "locale cannot be null");
+ Objects.requireNonNull(project, "project cannot be null");
+ Objects.requireNonNull(reactorProjects, "reactorProjects cannot be null");
+ Objects.requireNonNull(localRepository, "localRepository cannot be null");
+ Objects.requireNonNull(repositories, "repositories cannot be null");
+
+ LOGGER.debug("Computing decoration model of '" + project.getId() + "' for "
+ + (locale.equals(SiteTool.DEFAULT_LOCALE) ? "default locale" : "locale '" + locale + "'"));
Map.Entry<DecorationModel, MavenProject> result =
- getDecorationModel( 0, siteDirectory, locale, project, reactorProjects, localRepository, repositories );
+ getDecorationModel(0, siteDirectory, locale, project, reactorProjects, localRepository, repositories);
DecorationModel decorationModel = result.getKey();
MavenProject parentProject = result.getValue();
- if ( decorationModel == null )
- {
- LOGGER.debug( "Using default site descriptor" );
+ if (decorationModel == null) {
+ LOGGER.debug("Using default site descriptor");
decorationModel = getDefaultDecorationModel();
}
// DecorationModel back to String to interpolate, then go back to DecorationModel
- String siteDescriptorContent = decorationModelToString( decorationModel );
+ String siteDescriptorContent = decorationModelToString(decorationModel);
// "classical" late interpolation, after full inheritance
- siteDescriptorContent = getInterpolatedSiteDescriptorContent( project, siteDescriptorContent, false );
+ siteDescriptorContent = getInterpolatedSiteDescriptorContent(project, siteDescriptorContent, false);
- decorationModel = readDecorationModel( siteDescriptorContent );
+ decorationModel = readDecorationModel(siteDescriptorContent);
- if ( parentProject != null )
- {
- populateParentMenu( decorationModel, locale, project, parentProject, true );
+ if (parentProject != null) {
+ populateParentMenu(decorationModel, locale, project, parentProject, true);
}
- try
- {
- populateModulesMenu( decorationModel, locale, project, reactorProjects, localRepository, true );
- }
- catch ( IOException e )
- {
- throw new SiteToolException( "Error while populating modules menu", e );
+ try {
+ populateModulesMenu(decorationModel, locale, project, reactorProjects, localRepository, true);
+ } catch (IOException e) {
+ throw new SiteToolException("Error while populating modules menu", e);
}
return decorationModel;
}
/** {@inheritDoc} */
- public String getInterpolatedSiteDescriptorContent( Map<String, String> props, MavenProject aProject,
- String siteDescriptorContent )
- throws SiteToolException
- {
- Objects.requireNonNull( props, "props cannot be null" );
+ public String getInterpolatedSiteDescriptorContent(
+ Map<String, String> props, MavenProject aProject, String siteDescriptorContent) throws SiteToolException {
+ Objects.requireNonNull(props, "props cannot be null");
// "classical" late interpolation
- return getInterpolatedSiteDescriptorContent( aProject, siteDescriptorContent, false );
+ return getInterpolatedSiteDescriptorContent(aProject, siteDescriptorContent, false);
}
- private String getInterpolatedSiteDescriptorContent( MavenProject aProject,
- String siteDescriptorContent, boolean isEarly )
- throws SiteToolException
- {
- Objects.requireNonNull( aProject, "aProject cannot be null" );
- Objects.requireNonNull( siteDescriptorContent, "siteDescriptorContent cannot be null" );
+ private String getInterpolatedSiteDescriptorContent(
+ MavenProject aProject, String siteDescriptorContent, boolean isEarly) throws SiteToolException {
+ Objects.requireNonNull(aProject, "aProject cannot be null");
+ Objects.requireNonNull(siteDescriptorContent, "siteDescriptorContent cannot be null");
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
- if ( isEarly )
- {
- interpolator.addValueSource( new PrefixedObjectValueSource( "this.", aProject ) );
- interpolator.addValueSource( new PrefixedPropertiesValueSource( "this.", aProject.getProperties() ) );
- }
- else
- {
- interpolator.addValueSource( new PrefixedObjectValueSource( "project.", aProject ) );
- interpolator.addValueSource( new MapBasedValueSource( aProject.getProperties() ) );
+ if (isEarly) {
+ interpolator.addValueSource(new PrefixedObjectValueSource("this.", aProject));
+ interpolator.addValueSource(new PrefixedPropertiesValueSource("this.", aProject.getProperties()));
+ } else {
+ interpolator.addValueSource(new PrefixedObjectValueSource("project.", aProject));
+ interpolator.addValueSource(new MapBasedValueSource(aProject.getProperties()));
- try
- {
- interpolator.addValueSource( new EnvarBasedValueSource() );
- }
- catch ( IOException e )
- {
+ try {
+ interpolator.addValueSource(new EnvarBasedValueSource());
+ } catch (IOException e) {
// Prefer logging?
- throw new SiteToolException( "Cannot interpolate environment properties", e );
+ throw new SiteToolException("Cannot interpolate environment properties", e);
}
}
- try
- {
+ try {
// FIXME: this does not escape xml entities, see MSITE-226, PLXCOMP-118
- return interpolator.interpolate( siteDescriptorContent );
- }
- catch ( InterpolationException e )
- {
- throw new SiteToolException( "Cannot interpolate site descriptor", e );
+ return interpolator.interpolate(siteDescriptorContent);
+ } catch (InterpolationException e) {
+ throw new SiteToolException("Cannot interpolate site descriptor", e);
}
}
/** {@inheritDoc} */
- public MavenProject getParentProject( MavenProject aProject, List<MavenProject> reactorProjects,
- ArtifactRepository localRepository )
- {
- Objects.requireNonNull( aProject, "aProject cannot be null" );
- Objects.requireNonNull( reactorProjects, "reactorProjects cannot be null" );
- Objects.requireNonNull( localRepository, "localRepository cannot be null" );
+ public MavenProject getParentProject(
+ MavenProject aProject, List<MavenProject> reactorProjects, ArtifactRepository localRepository) {
+ Objects.requireNonNull(aProject, "aProject cannot be null");
+ Objects.requireNonNull(reactorProjects, "reactorProjects cannot be null");
+ Objects.requireNonNull(localRepository, "localRepository cannot be null");
return aProject.getParent();
}
@@ -532,71 +464,61 @@ public class DefaultSiteTool
* @param parentProject a Maven parent project, not null.
* @param keepInheritedRefs used for inherited references.
*/
- private void populateParentMenu( DecorationModel decorationModel, Locale locale, MavenProject project,
- MavenProject parentProject, boolean keepInheritedRefs )
- {
- Objects.requireNonNull( decorationModel, "decorationModel cannot be null" );
- Objects.requireNonNull( locale, "locale cannot be null" );
- Objects.requireNonNull( project, "project cannot be null" );
- Objects.requireNonNull( parentProject, "parentProject cannot be null" );
-
- Menu menu = decorationModel.getMenuRef( "parent" );
-
- if ( menu == null )
- {
+ private void populateParentMenu(
+ DecorationModel decorationModel,
+ Locale locale,
+ MavenProject project,
+ MavenProject parentProject,
+ boolean keepInheritedRefs) {
+ Objects.requireNonNull(decorationModel, "decorationModel cannot be null");
+ Objects.requireNonNull(locale, "locale cannot be null");
+ Objects.requireNonNull(project, "project cannot be null");
+ Objects.requireNonNull(parentProject, "parentProject cannot be null");
+
+ Menu menu = decorationModel.getMenuRef("parent");
+
+ if (menu == null) {
return;
}
- if ( keepInheritedRefs && menu.isInheritAsRef() )
- {
+ if (keepInheritedRefs && menu.isInheritAsRef()) {
return;
}
- String parentUrl = getDistMgmntSiteUrl( parentProject );
+ String parentUrl = getDistMgmntSiteUrl(parentProject);
- if ( parentUrl != null )
- {
- if ( parentUrl.endsWith( "/" ) )
- {
+ if (parentUrl != null) {
+ if (parentUrl.endsWith("/")) {
parentUrl += "index.html";
- }
- else
- {
+ } else {
parentUrl += "/index.html";
}
- parentUrl = getRelativePath( parentUrl, getDistMgmntSiteUrl( project ) );
- }
- else
- {
+ parentUrl = getRelativePath(parentUrl, getDistMgmntSiteUrl(project));
+ } else {
// parent has no url, assume relative path is given by site structure
File parentBasedir = parentProject.getBasedir();
// First make sure that the parent is available on the file system
- if ( parentBasedir != null )
- {
+ if (parentBasedir != null) {
// Try to find the relative path to the parent via the file system
String parentPath = parentBasedir.getAbsolutePath();
String projectPath = project.getBasedir().getAbsolutePath();
- parentUrl = getRelativePath( parentPath, projectPath ) + "/index.html";
+ parentUrl = getRelativePath(parentPath, projectPath) + "/index.html";
}
}
// Only add the parent menu if we were able to find a URL for it
- if ( parentUrl == null )
- {
- LOGGER.warn( "Unable to find a URL to the parent project. The parent menu will NOT be added." );
- }
- else
- {
- if ( menu.getName() == null )
- {
- menu.setName( i18n.getString( "site-tool", locale, "decorationModel.menu.parentproject" ) );
+ if (parentUrl == null) {
+ LOGGER.warn("Unable to find a URL to the parent project. The parent menu will NOT be added.");
+ } else {
+ if (menu.getName() == null) {
+ menu.setName(i18n.getString("site-tool", locale, "decorationModel.menu.parentproject"));
}
MenuItem item = new MenuItem();
- item.setName( parentProject.getName() );
- item.setHref( parentUrl );
- menu.addItem( item );
+ item.setName(parentProject.getName());
+ item.setHref(parentUrl);
+ menu.addItem(item);
}
}
@@ -613,106 +535,89 @@ public class DefaultSiteTool
* @throws SiteToolException if any
* @throws IOException
*/
- private void populateModulesMenu( DecorationModel decorationModel, Locale locale, MavenProject project,
- List<MavenProject> reactorProjects, ArtifactRepository localRepository,
- boolean keepInheritedRefs )
- throws SiteToolException, IOException
- {
- Objects.requireNonNull( decorationModel, "decorationModel cannot be null" );
- Objects.requireNonNull( locale, "locale cannot be null" );
- Objects.requireNonNull( project, "project cannot be null" );
- Objects.requireNonNull( reactorProjects, "reactorProjects cannot be null" );
- Objects.requireNonNull( localRepository, "localRepository cannot be null" );
-
- Menu menu = decorationModel.getMenuRef( "modules" );
-
- if ( menu == null )
- {
+ private void populateModulesMenu(
+ DecorationModel decorationModel,
+ Locale locale,
+ MavenProject project,
+ List<MavenProject> reactorProjects,
+ ArtifactRepository localRepository,
+ boolean keepInheritedRefs)
+ throws SiteToolException, IOException {
+ Objects.requireNonNull(decorationModel, "decorationModel cannot be null");
+ Objects.requireNonNull(locale, "locale cannot be null");
+ Objects.requireNonNull(project, "project cannot be null");
+ Objects.requireNonNull(reactorProjects, "reactorProjects cannot be null");
+ Objects.requireNonNull(localRepository, "localRepository cannot be null");
+
+ Menu menu = decorationModel.getMenuRef("modules");
+
+ if (menu == null) {
return;
}
- if ( keepInheritedRefs && menu.isInheritAsRef() )
- {
+ if (keepInheritedRefs && menu.isInheritAsRef()) {
return;
}
// we require child modules and reactors to process module menu
- if ( project.getModules().size() > 0 )
- {
- if ( menu.getName() == null )
- {
- menu.setName( i18n.getString( "site-tool", locale, "decorationModel.menu.projectmodules" ) );
+ if (project.getModules().size() > 0) {
+ if (menu.getName() == null) {
+ menu.setName(i18n.getString("site-tool", locale, "decorationModel.menu.projectmodules"));
}
- for ( String module : (List<String>) project.getModules() )
- {
- MavenProject moduleProject = getModuleFromReactor( project, reactorProjects, module );
+ for (String module : (List<String>) project.getModules()) {
+ MavenProject moduleProject = getModuleFromReactor(project, reactorProjects, module);
- if ( moduleProject == null )
- {
- LOGGER.warn( "Module " + module
- + " not found in reactor: loading locally" );
+ if (moduleProject == null) {
+ LOGGER.warn("Module " + module + " not found in reactor: loading locally");
- File f = new File( project.getBasedir(), module + "/pom.xml" );
- if ( f.exists() )
- {
- try
- {
+ File f = new File(project.getBasedir(), module + "/pom.xml");
+ if (f.exists()) {
+ try {
ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
- request.setLocalRepository( localRepository );
+ request.setLocalRepository(localRepository);
- ProjectBuildingResult result = projectBuilder.build( f, request );
+ ProjectBuildingResult result = projectBuilder.build(f, request);
moduleProject = result.getProject();
+ } catch (ProjectBuildingException e) {
+ throw new SiteToolException("Unable to read local module POM", e);
}
- catch ( ProjectBuildingException e )
- {
- throw new SiteToolException( "Unable to read local module POM", e );
- }
- }
- else
- {
- LOGGER.warn( "No filesystem module POM available" );
+ } else {
+ LOGGER.warn("No filesystem module POM available");
moduleProject = new MavenProject();
- moduleProject.setName( module );
- moduleProject.setDistributionManagement( new DistributionManagement() );
- moduleProject.getDistributionManagement().setSite( new Site() );
- moduleProject.getDistributionManagement().getSite().setUrl( module );
+ moduleProject.setName(module);
+ moduleProject.setDistributionManagement(new DistributionManagement());
+ moduleProject.getDistributionManagement().setSite(new Site());
+ moduleProject.getDistributionManagement().getSite().setUrl(module);
}
}
final String pluginId = "org.apache.maven.plugins:maven-site-plugin";
- String skipFlag = getPluginParameter( moduleProject, pluginId, "skip" );
- if ( skipFlag == null )
- {
- skipFlag = moduleProject.getProperties().getProperty( "maven.site.skip" );
+ String skipFlag = getPluginParameter(moduleProject, pluginId, "skip");
+ if (skipFlag == null) {
+ skipFlag = moduleProject.getProperties().getProperty("maven.site.skip");
}
- String siteUrl = "true".equalsIgnoreCase( skipFlag ) ? null : getDistMgmntSiteUrl( moduleProject );
+ String siteUrl = "true".equalsIgnoreCase(skipFlag) ? null : getDistMgmntSiteUrl(moduleProject);
String itemName =
- ( moduleProject.getName() == null ) ? moduleProject.getArtifactId() : moduleProject.getName();
- String defaultSiteUrl = "true".equalsIgnoreCase( skipFlag ) ? null : moduleProject.getArtifactId();
+ (moduleProject.getName() == null) ? moduleProject.getArtifactId() : moduleProject.getName();
+ String defaultSiteUrl = "true".equalsIgnoreCase(skipFlag) ? null : moduleProject.getArtifactId();
- appendMenuItem( project, menu, itemName, siteUrl, defaultSiteUrl );
+ appendMenuItem(project, menu, itemName, siteUrl, defaultSiteUrl);
}
- }
- else if ( decorationModel.getMenuRef( "modules" ).getInherit() == null )
- {
+ } else if (decorationModel.getMenuRef("modules").getInherit() == null) {
// only remove if project has no modules AND menu is not inherited, see MSHARED-174
- decorationModel.removeMenuRef( "modules" );
+ decorationModel.removeMenuRef("modules");
}
}
- private static MavenProject getModuleFromReactor( MavenProject project, List<MavenProject> reactorProjects,
- String module )
- throws IOException
- {
- File moduleBasedir = new File( project.getBasedir(), module ).getCanonicalFile();
+ private static MavenProject getModuleFromReactor(
+ MavenProject project, List<MavenProject> reactorProjects, String module) throws IOException {
+ File moduleBasedir = new File(project.getBasedir(), module).getCanonicalFile();
- for ( MavenProject reactorProject : reactorProjects )
- {
- if ( moduleBasedir.equals( reactorProject.getBasedir() ) )
- {
+ for (MavenProject reactorProject : reactorProjects) {
+ if (moduleBasedir.equals(reactorProject.getBasedir())) {
return reactorProject;
}
}
@@ -722,109 +627,96 @@ public class DefaultSiteTool
}
/** {@inheritDoc} */
- public void populateReportsMenu( DecorationModel decorationModel, Locale locale,
- Map<String, List<MavenReport>> categories )
- {
- Objects.requireNonNull( decorationModel, "decorationModel cannot be null" );
- Objects.requireNonNull( locale, "locale cannot be null" );
- Objects.requireNonNull( categories, "categories cannot be null" );
+ public void populateReportsMenu(
+ DecorationModel decorationModel, Locale locale, Map<String, List<MavenReport>> categories) {
+ Objects.requireNonNull(decorationModel, "decorationModel cannot be null");
+ Objects.requireNonNull(locale, "locale cannot be null");
+ Objects.requireNonNull(categories, "categories cannot be null");
- Menu menu = decorationModel.getMenuRef( "reports" );
+ Menu menu = decorationModel.getMenuRef("reports");
- if ( menu == null )
- {
+ if (menu == null) {
return;
}
- if ( menu.getName() == null )
- {
- menu.setName( i18n.getString( "site-tool", locale, "decorationModel.menu.projectdocumentation" ) );
+ if (menu.getName() == null) {
+ menu.setName(i18n.getString("site-tool", locale, "decorationModel.menu.projectdocumentation"));
}
boolean found = false;
- if ( menu.getItems().isEmpty() )
- {
- List<MavenReport> categoryReports = categories.get( MavenReport.CATEGORY_PROJECT_INFORMATION );
- if ( !isEmptyList( categoryReports ) )
- {
+ if (menu.getItems().isEmpty()) {
+ List<MavenReport> categoryReports = categories.get(MavenReport.CATEGORY_PROJECT_INFORMATION);
+ if (!isEmptyList(categoryReports)) {
MenuItem item = createCategoryMenu(
- i18n.getString( "site-tool", locale,
- "decorationModel.menu.projectinformation" ),
- "/project-info.html", categoryReports, locale );
- menu.getItems().add( item );
+ i18n.getString("site-tool", locale, "decorationModel.menu.projectinformation"),
+ "/project-info.html",
+ categoryReports,
+ locale);
+ menu.getItems().add(item);
found = true;
}
- categoryReports = categories.get( MavenReport.CATEGORY_PROJECT_REPORTS );
- if ( !isEmptyList( categoryReports ) )
- {
- MenuItem item =
- createCategoryMenu( i18n.getString( "site-tool", locale, "decorationModel.menu.projectreports" ),
- "/project-reports.html", categoryReports, locale );
- menu.getItems().add( item );
+ categoryReports = categories.get(MavenReport.CATEGORY_PROJECT_REPORTS);
+ if (!isEmptyList(categoryReports)) {
+ MenuItem item = createCategoryMenu(
+ i18n.getString("site-tool", locale, "decorationModel.menu.projectreports"),
+ "/project-reports.html",
+ categoryReports,
+ locale);
+ menu.getItems().add(item);
found = true;
}
}
- if ( !found )
- {
- decorationModel.removeMenuRef( "reports" );
+ if (!found) {
+ decorationModel.removeMenuRef("reports");
}
}
/** {@inheritDoc} */
- public List<Locale> getSiteLocales( String locales )
- {
- if ( locales == null )
- {
- return Collections.singletonList( DEFAULT_LOCALE );
+ public List<Locale> getSiteLocales(String locales) {
+ if (locales == null) {
+ return Collections.singletonList(DEFAULT_LOCALE);
}
- String[] localesArray = StringUtils.split( locales, "," );
- List<Locale> localesList = new ArrayList<Locale>( localesArray.length );
- List<Locale> availableLocales = Arrays.asList( Locale.getAvailableLocales() );
+ String[] localesArray = StringUtils.split(locales, ",");
+ List<Locale> localesList = new ArrayList<Locale>(localesArray.length);
+ List<Locale> availableLocales = Arrays.asList(Locale.getAvailableLocales());
- for ( String localeString : localesArray )
- {
- Locale locale = codeToLocale( localeString );
+ for (String localeString : localesArray) {
+ Locale locale = codeToLocale(localeString);
- if ( locale == null )
- {
+ if (locale == null) {
continue;
}
- if ( !availableLocales.contains( locale ) )
- {
- if ( LOGGER.isWarnEnabled() )
- {
- LOGGER.warn( "The locale defined by '" + locale
- + "' is not available in this Java Virtual Machine ("
- + System.getProperty( "java.version" )
- + " from " + System.getProperty( "java.vendor" ) + ") - IGNORING" );
+ if (!availableLocales.contains(locale)) {
+ if (LOGGER.isWarnEnabled()) {
+ LOGGER.warn("The locale defined by '" + locale
+ + "' is not available in this Java Virtual Machine ("
+ + System.getProperty("java.version")
+ + " from " + System.getProperty("java.vendor") + ") - IGNORING");
}
continue;
}
- Locale bundleLocale = i18n.getBundle( "site-tool", locale ).getLocale();
- if ( !( bundleLocale.equals( locale ) || bundleLocale.getLanguage().equals( locale.getLanguage() ) ) )
- {
- if ( LOGGER.isWarnEnabled() )
- {
- LOGGER.warn( "The locale '" + locale + "' (" + locale.getDisplayName( Locale.ENGLISH )
- + ") is not currently supported by Maven Site - IGNORING."
- + System.lineSeparator() + "Contributions are welcome and greatly appreciated!"
- + System.lineSeparator() + "If you want to contribute a new translation, please visit "
- + "https://maven.apache.org/plugins/localization.html for detailed instructions." );
+ Locale bundleLocale = i18n.getBundle("site-tool", locale).getLocale();
+ if (!(bundleLocale.equals(locale) || bundleLocale.getLanguage().equals(locale.getLanguage()))) {
+ if (LOGGER.isWarnEnabled()) {
+ LOGGER.warn("The locale '" + locale + "' (" + locale.getDisplayName(Locale.ENGLISH)
+ + ") is not currently supported by Maven Site - IGNORING."
+ + System.lineSeparator() + "Contributions are welcome and greatly appreciated!"
+ + System.lineSeparator() + "If you want to contribute a new translation, please visit "
+ + "https://maven.apache.org/plugins/localization.html for detailed instructions.");
}
continue;
}
- localesList.add( locale );
+ localesList.add(locale);
}
- if ( localesList.isEmpty() )
- {
- localesList = Collections.singletonList( DEFAULT_LOCALE );
+ if (localesList.isEmpty()) {
+ localesList = Collections.singletonList(DEFAULT_LOCALE);
}
return localesList;
@@ -842,20 +734,16 @@ public class DefaultSiteTool
* @see Locale#getDefault()
* @see SiteTool#DEFAULT_LOCALE
*/
- private Locale codeToLocale( String localeCode )
- {
- if ( localeCode == null )
- {
+ private Locale codeToLocale(String localeCode) {
+ if (localeCode == null) {
return null;
}
- if ( "system".equalsIgnoreCase( localeCode ) )
- {
+ if ("system".equalsIgnoreCase(localeCode)) {
return Locale.getDefault();
}
- if ( "default".equalsIgnoreCase( localeCode ) )
- {
+ if ("default".equalsIgnoreCase(localeCode)) {
return SiteTool.DEFAULT_LOCALE;
}
@@ -863,31 +751,26 @@ public class DefaultSiteTool
String country = "";
String variant = "";
- StringTokenizer tokenizer = new StringTokenizer( localeCode, "_" );
+ StringTokenizer tokenizer = new StringTokenizer(localeCode, "_");
final int maxTokens = 3;
- if ( tokenizer.countTokens() > maxTokens )
- {
- if ( LOGGER.isWarnEnabled() )
- {
- LOGGER.warn( "Invalid java.util.Locale format for '" + localeCode + "' entry - IGNORING" );
+ if (tokenizer.countTokens() > maxTokens) {
+ if (LOGGER.isWarnEnabled()) {
+ LOGGER.warn("Invalid java.util.Locale format for '" + localeCode + "' entry - IGNORING");
}
return null;
}
- if ( tokenizer.hasMoreTokens() )
- {
+ if (tokenizer.hasMoreTokens()) {
language = tokenizer.nextToken();
- if ( tokenizer.hasMoreTokens() )
- {
+ if (tokenizer.hasMoreTokens()) {
country = tokenizer.nextToken();
- if ( tokenizer.hasMoreTokens() )
- {
+ if (tokenizer.hasMoreTokens()) {
variant = tokenizer.nextToken();
}
}
}
- return new Locale( language, country, variant );
+ return new Locale(language, country, variant);
}
// ----------------------------------------------------------------------
@@ -899,14 +782,12 @@ public class DefaultSiteTool
* @return the path normalized, i.e. by eliminating "/../" and "/./" in the path.
* @see FilenameUtils#normalize(String)
*/
- protected static String getNormalizedPath( String path )
- {
- String normalized = FilenameUtils.normalize( path );
- if ( normalized == null )
- {
+ protected static String getNormalizedPath(String path) {
+ String normalized = FilenameUtils.normalize(path);
+ if (normalized == null) {
normalized = path;
}
- return ( normalized == null ) ? null : normalized.replace( '\\', '/' );
+ return (normalized == null) ? null : normalized.replace('\\', '/');
}
// ----------------------------------------------------------------------
@@ -923,10 +804,12 @@ public class DefaultSiteTool
* @throws ArtifactResolutionException if any
* @throws ArtifactNotFoundException if any
*/
- private File resolveSiteDescriptor( MavenProject project, ArtifactRepository localRepository,
- List<ArtifactRepository> repositories, Locale locale )
- throws IOException, ArtifactResolutionException, ArtifactNotFoundException
- {
+ private File resolveSiteDescriptor(
+ MavenProject project,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> repositories,
+ Locale locale)
+ throws IOException, ArtifactResolutionException, ArtifactNotFoundException {
String variant = locale.getVariant();
String country = locale.getCountry();
String language = locale.getLanguage();
@@ -935,138 +818,104 @@ public class DefaultSiteTool
File siteDescriptor = null;
boolean found = false;
- if ( !variant.isEmpty() )
- {
+ if (!variant.isEmpty()) {
String localeStr = language + "_" + country + "_" + variant;
// TODO: this is a bit crude - proper type, or proper handling as metadata rather than an artifact in 2.1?
- artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
- project.getArtifactId(),
- project.getVersion(), "xml",
- "site_" + localeStr );
+ artifact = artifactFactory.createArtifactWithClassifier(
+ project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site_" + localeStr);
- try
- {
- artifactResolver.resolve( artifact, repositories, localRepository );
+ try {
+ artifactResolver.resolve(artifact, repositories, localRepository);
siteDescriptor = artifact.getFile();
// we use zero length files to avoid re-resolution (see below)
- if ( siteDescriptor.length() > 0 )
- {
+ if (siteDescriptor.length() > 0) {
found = true;
+ } else {
+ LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr
+ + "', trying without variant...");
}
- else
- {
- LOGGER.debug( "No site descriptor found for '" + project.getId() + "' for locale '"
- + localeStr + "', trying without variant..." );
- }
- }
- catch ( ArtifactNotFoundException e )
- {
- LOGGER.debug( "Unable to locate site descriptor for locale '" + localeStr + "'", e );
+ } catch (ArtifactNotFoundException e) {
+ LOGGER.debug("Unable to locate site descriptor for locale '" + localeStr + "'", e);
// we can afford to write an empty descriptor here as we don't expect it to turn up later in the
// remote repository, because the parent was already released (and snapshots are updated
// automatically if changed)
- siteDescriptor = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
+ siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
siteDescriptor.getParentFile().mkdirs();
siteDescriptor.createNewFile();
}
}
- if ( !found && !country.isEmpty() )
- {
+ if (!found && !country.isEmpty()) {
String localeStr = language + "_" + country;
// TODO: this is a bit crude - proper type, or proper handling as metadata rather than an artifact in 2.1?
- artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
- project.getArtifactId(),
- project.getVersion(), "xml",
- "site_" + localeStr );
+ artifact = artifactFactory.createArtifactWithClassifier(
+ project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site_" + localeStr);
- try
- {
- artifactResolver.resolve( artifact, repositories, localRepository );
+ try {
+ artifactResolver.resolve(artifact, repositories, localRepository);
siteDescriptor = artifact.getFile();
// we use zero length files to avoid re-resolution (see below)
- if ( siteDescriptor.length() > 0 )
- {
+ if (siteDescriptor.length() > 0) {
found = true;
+ } else {
+ LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr
+ + "', trying without country...");
}
- else
- {
- LOGGER.debug( "No site descriptor found for '" + project.getId() + "' for locale '"
- + localeStr + "', trying without country..." );
- }
- }
- catch ( ArtifactNotFoundException e )
- {
- LOGGER.debug( "Unable to locate site descriptor for locale '" + localeStr + "'", e );
+ } catch (ArtifactNotFoundException e) {
+ LOGGER.debug("Unable to locate site descriptor for locale '" + localeStr + "'", e);
// we can afford to write an empty descriptor here as we don't expect it to turn up later in the
// remote repository, because the parent was already released (and snapshots are updated
// automatically if changed)
- siteDescriptor = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
+ siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
siteDescriptor.getParentFile().mkdirs();
siteDescriptor.createNewFile();
}
}
-
- if ( !found && !language.isEmpty() )
- {
+ if (!found && !language.isEmpty()) {
String localeStr = language;
// TODO: this is a bit crude - proper type, or proper handling as metadata rather than an artifact in 2.1?
- artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
- project.getArtifactId(),
- project.getVersion(), "xml",
- "site_" + localeStr );
+ artifact = artifactFactory.createArtifactWithClassifier(
+ project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site_" + localeStr);
- try
- {
- artifactResolver.resolve( artifact, repositories, localRepository );
+ try {
+ artifactResolver.resolve(artifact, repositories, localRepository);
siteDescriptor = artifact.getFile();
// we use zero length files to avoid re-resolution (see below)
- if ( siteDescriptor.length() > 0 )
- {
+ if (siteDescriptor.length() > 0) {
found = true;
+ } else {
+ LOGGER.debug("No site descriptor found for '" + project.getId() + "' for locale '" + localeStr
+ + "', trying default locale...");
}
- else
- {
- LOGGER.debug( "No site descriptor found for '" + project.getId() + "' for locale '"
- + localeStr + "', trying default locale..." );
- }
- }
- catch ( ArtifactNotFoundException e )
- {
- LOGGER.debug( "Unable to locate site descriptor for locale '" + localeStr + "'", e );
+ } catch (ArtifactNotFoundException e) {
+ LOGGER.debug("Unable to locate site descriptor for locale '" + localeStr + "'", e);
// we can afford to write an empty descriptor here as we don't expect it to turn up later in the
// remote repository, because the parent was already released (and snapshots are updated
// automatically if changed)
- siteDescriptor = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
+ siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
siteDescriptor.getParentFile().mkdirs();
siteDescriptor.createNewFile();
}
}
- if ( !found )
- {
- artifact = artifactFactory.createArtifactWithClassifier( project.getGroupId(),
- project.getArtifactId(),
- project.getVersion(), "xml",
- "site" );
- try
- {
- artifactResolver.resolve( artifact, repositories, localRepository );
- }
- catch ( ArtifactNotFoundException e )
- {
+ if (!found) {
+ artifact = artifactFactory.createArtifactWithClassifier(
+ project.getGroupId(), project.getArtifactId(), project.getVersion(), "xml", "site");
+ try {
+ artifactResolver.resolve(artifact, repositories, localRepository);
+ } catch (ArtifactNotFoundException e) {
// see above regarding this zero length file
- siteDescriptor = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
+ siteDescriptor = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
siteDescriptor.getParentFile().mkdirs();
siteDescriptor.createNewFile();
@@ -1076,9 +925,8 @@ public class DefaultSiteTool
siteDescriptor = artifact.getFile();
// we use zero length files to avoid re-resolution (see below)
- if ( siteDescriptor.length() == 0 )
- {
- LOGGER.debug( "No site descriptor found for '" + project.getId() + "' with default locale." );
+ if (siteDescriptor.length() == 0) {
+ LOGGER.debug("No site descriptor found for '" + project.getId() + "' with default locale.");
siteDescriptor = null;
}
}
@@ -1097,123 +945,116 @@ public class DefaultSiteTool
* @return the decoration model depending the locale and the parent project
* @throws SiteToolException if any
*/
- private Map.Entry<DecorationModel, MavenProject> getDecorationModel( int depth, File siteDirectory, Locale locale,
- MavenProject project,
- List<MavenProject> reactorProjects,
- ArtifactRepository localRepository,
- List<ArtifactRepository> repositories )
- throws SiteToolException
- {
+ private Map.Entry<DecorationModel, MavenProject> getDecorationModel(
+ int depth,
+ File siteDirectory,
+ Locale locale,
+ MavenProject project,
+ List<MavenProject> reactorProjects,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> repositories)
+ throws SiteToolException {
// 1. get site descriptor File
File siteDescriptor;
- if ( project.getBasedir() == null )
- {
+ if (project.getBasedir() == null) {
// POM is in the repository: look into the repository for site descriptor
- try
- {
- siteDescriptor = getSiteDescriptorFromRepository( project, localRepository, repositories, locale );
- }
- catch ( SiteToolException e )
- {
- throw new SiteToolException( "The site descriptor cannot be resolved from the repository", e );
+ try {
+ siteDescriptor = getSiteDescriptorFromRepository(project, localRepository, repositories, locale);
+ } catch (SiteToolException e) {
+ throw new SiteToolException("The site descriptor cannot be resolved from the repository", e);
}
- }
- else
- {
+ } else {
// POM is in build directory: look for site descriptor as local file
- siteDescriptor = getSiteDescriptor( siteDirectory, locale );
+ siteDescriptor = getSiteDescriptor(siteDirectory, locale);
}
// 2. read DecorationModel from site descriptor File and do early interpolation (${this.*})
DecorationModel decorationModel = null;
Reader siteDescriptorReader = null;
- try
- {
- if ( siteDescriptor != null && siteDescriptor.exists() )
- {
- LOGGER.debug( "Reading" + ( depth == 0 ? "" : ( " parent level " + depth ) )
- + " site descriptor from " + siteDescriptor );
+ try {
+ if (siteDescriptor != null && siteDescriptor.exists()) {
+ LOGGER.debug("Reading" + (depth == 0 ? "" : (" parent level " + depth)) + " site descriptor from "
+ + siteDescriptor);
- siteDescriptorReader = ReaderFactory.newXmlReader( siteDescriptor );
+ siteDescriptorReader = ReaderFactory.newXmlReader(siteDescriptor);
- String siteDescriptorContent = IOUtil.toString( siteDescriptorReader );
+ String siteDescriptorContent = IOUtil.toString(siteDescriptorReader);
// interpolate ${this.*} = early interpolation
- siteDescriptorContent = getInterpolatedSiteDescriptorContent( project, siteDescriptorContent, true );
+ siteDescriptorContent = getInterpolatedSiteDescriptorContent(project, siteDescriptorContent, true);
- decorationModel = readDecorationModel( siteDescriptorContent );
- decorationModel.setLastModified( siteDescriptor.lastModified() );
+ decorationModel = readDecorationModel(siteDescriptorContent);
+ decorationModel.setLastModified(siteDescriptor.lastModified());
+ } else {
+ LOGGER.debug("No" + (depth == 0 ? "" : (" parent level " + depth)) + " site descriptor.");
}
- else
- {
- LOGGER.debug( "No" + ( depth == 0 ? "" : ( " parent level " + depth ) ) + " site descriptor." );
- }
- }
- catch ( IOException e )
- {
- throw new SiteToolException( "The site descriptor for '" + project.getId() + "' cannot be read from "
- + siteDescriptor, e );
- }
- finally
- {
- IOUtil.close( siteDescriptorReader );
+ } catch (IOException e) {
+ throw new SiteToolException(
+ "The site descriptor for '" + project.getId() + "' cannot be read from " + siteDescriptor, e);
+ } finally {
+ IOUtil.close(siteDescriptorReader);
}
// 3. look for parent project
MavenProject parentProject = project.getParent();
// 4. merge with parent project DecorationModel
- if ( parentProject != null && ( decorationModel == null || decorationModel.isMergeParent() ) )
- {
+ if (parentProject != null && (decorationModel == null || decorationModel.isMergeParent())) {
depth++;
- LOGGER.debug( "Looking for site descriptor of level " + depth + " parent project: "
- + parentProject.getId() );
+ LOGGER.debug("Looking for site descriptor of level " + depth + " parent project: " + parentProject.getId());
File parentSiteDirectory = null;
- if ( parentProject.getBasedir() != null )
- {
+ if (parentProject.getBasedir() != null) {
// extrapolate parent project site directory
- String siteRelativePath = getRelativeFilePath( project.getBasedir().getAbsolutePath(),
- siteDescriptor.getParentFile().getAbsolutePath() );
+ String siteRelativePath = getRelativeFilePath(
+ project.getBasedir().getAbsolutePath(),
+ siteDescriptor.getParentFile().getAbsolutePath());
- parentSiteDirectory = new File( parentProject.getBasedir(), siteRelativePath );
+ parentSiteDirectory = new File(parentProject.getBasedir(), siteRelativePath);
// notice: using same siteRelativePath for parent as current project; may be wrong if site plugin
// has different configuration. But this is a rare case (this only has impact if parent is from reactor)
}
- DecorationModel parentDecorationModel =
- getDecorationModel( depth, parentSiteDirectory, locale, parentProject, reactorProjects, localRepository,
- repositories ).getKey();
+ DecorationModel parentDecorationModel = getDecorationModel(
+ depth,
+ parentSiteDirectory,
+ locale,
+ parentProject,
+ reactorProjects,
+ localRepository,
+ repositories)
+ .getKey();
// MSHARED-116 requires an empty decoration model (instead of a null one)
// MSHARED-145 requires us to do this only if there is a parent to merge it with
- if ( decorationModel == null && parentDecorationModel != null )
- {
+ if (decorationModel == null && parentDecorationModel != null) {
// we have no site descriptor: merge the parent into an empty one because the default one
// (default-site.xml) will break menu and breadcrumb composition.
decorationModel = new DecorationModel();
}
String name = project.getName();
- if ( decorationModel != null && StringUtils.isNotEmpty( decorationModel.getName() ) )
- {
+ if (decorationModel != null && StringUtils.isNotEmpty(decorationModel.getName())) {
name = decorationModel.getName();
}
// Merge the parent and child DecorationModels
- String projectDistMgmnt = getDistMgmntSiteUrl( project );
- String parentDistMgmnt = getDistMgmntSiteUrl( parentProject );
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.debug( "Site decoration model inheritance: assembling child with level " + depth
- + " parent: distributionManagement.site.url child = " + projectDistMgmnt + " and parent = "
- + parentDistMgmnt );
+ String projectDistMgmnt = getDistMgmntSiteUrl(project);
+ String parentDistMgmnt = getDistMgmntSiteUrl(parentProject);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Site decoration model inheritance: assembling child with level " + depth
+ + " parent: distributionManagement.site.url child = " + projectDistMgmnt + " and parent = "
+ + parentDistMgmnt);
}
- assembler.assembleModelInheritance( name, decorationModel, parentDecorationModel, projectDistMgmnt,
- parentDistMgmnt == null ? projectDistMgmnt : parentDistMgmnt );
+ assembler.assembleModelInheritance(
+ name,
+ decorationModel,
+ parentDecorationModel,
+ projectDistMgmnt,
+ parentDistMgmnt == null ? projectDistMgmnt : parentDistMgmnt);
}
- return new AbstractMap.SimpleEntry<DecorationModel, MavenProject>( decorationModel, parentProject );
+ return new AbstractMap.SimpleEntry<DecorationModel, MavenProject>(decorationModel, parentProject);
}
/**
@@ -1221,88 +1062,60 @@ public class DefaultSiteTool
* @return the decoration model object
* @throws SiteToolException if any
*/
- private DecorationModel readDecorationModel( String siteDescriptorContent )
- throws SiteToolException
- {
- try
- {
- return new DecorationXpp3Reader().read( new StringReader( siteDescriptorContent ) );
- }
- catch ( XmlPullParserException e )
- {
- throw new SiteToolException( "Error parsing site descriptor", e );
- }
- catch ( IOException e )
- {
- throw new SiteToolException( "Error reading site descriptor", e );
+ private DecorationModel readDecorationModel(String siteDescriptorContent) throws SiteToolException {
+ try {
+ return new DecorationXpp3Reader().read(new StringReader(siteDescriptorContent));
+ } catch (XmlPullParserException e) {
+ throw new SiteToolException("Error parsing site descriptor", e);
+ } catch (IOException e) {
+ throw new SiteToolException("Error reading site descriptor", e);
}
}
- private DecorationModel getDefaultDecorationModel()
- throws SiteToolException
- {
+ private DecorationModel getDefaultDecorationModel() throws SiteToolException {
String siteDescriptorContent;
Reader reader = null;
- try
- {
- reader = ReaderFactory.newXmlReader( getClass().getResourceAsStream( "/default-site.xml" ) );
- siteDescriptorContent = IOUtil.toString( reader );
- }
- catch ( IOException e )
- {
- throw new SiteToolException( "Error reading default site descriptor", e );
- }
- finally
- {
- IOUtil.close( reader );
+ try {
+ reader = ReaderFactory.newXmlReader(getClass().getResourceAsStream("/default-site.xml"));
+ siteDescriptorContent = IOUtil.toString(reader);
+ } catch (IOException e) {
+ throw new SiteToolException("Error reading default site descriptor", e);
+ } finally {
+ IOUtil.close(reader);
}
- return readDecorationModel( siteDescriptorContent );
+ return readDecorationModel(siteDescriptorContent);
}
- private String decorationModelToString( DecorationModel decoration )
- throws SiteToolException
- {
+ private String decorationModelToString(DecorationModel decoration) throws SiteToolException {
StringWriter writer = new StringWriter();
- try
- {
- new DecorationXpp3Writer().write( writer, decoration );
+ try {
+ new DecorationXpp3Writer().write(writer, decoration);
return writer.toString();
- }
- catch ( IOException e )
- {
- throw new SiteToolException( "Error reading site descriptor", e );
- }
- finally
- {
- IOUtil.close( writer );
+ } catch (IOException e) {
+ throw new SiteToolException("Error reading site descriptor", e);
+ } finally {
+ IOUtil.close(writer);
}
}
- private static String buildRelativePath( final String toPath, final String fromPath, final char separatorChar )
- {
+ private static String buildRelativePath(final String toPath, final String fromPath, final char separatorChar) {
// use tokenizer to traverse paths and for lazy checking
- StringTokenizer toTokeniser = new StringTokenizer( toPath, String.valueOf( separatorChar ) );
- StringTokenizer fromTokeniser = new StringTokenizer( fromPath, String.valueOf( separatorChar ) );
+ StringTokenizer toTokeniser = new StringTokenizer(toPath, String.valueOf(separatorChar));
+ StringTokenizer fromTokeniser = new StringTokenizer(fromPath, String.valueOf(separatorChar));
int count = 0;
// walk along the to path looking for divergence from the from path
- while ( toTokeniser.hasMoreTokens() && fromTokeniser.hasMoreTokens() )
- {
- if ( separatorChar == '\\' )
- {
- if ( !fromTokeniser.nextToken().equalsIgnoreCase( toTokeniser.nextToken() ) )
- {
+ while (toTokeniser.hasMoreTokens() && fromTokeniser.hasMoreTokens()) {
+ if (separatorChar == '\\') {
+ if (!fromTokeniser.nextToken().equalsIgnoreCase(toTokeniser.nextToken())) {
break;
}
- }
- else
- {
- if ( !fromTokeniser.nextToken().equals( toTokeniser.nextToken() ) )
- {
+ } else {
+ if (!fromTokeniser.nextToken().equals(toTokeniser.nextToken())) {
break;
}
}
@@ -1313,11 +1126,10 @@ public class DefaultSiteTool
// reinitialize the tokenizers to count positions to retrieve the
// gobbled token
- toTokeniser = new StringTokenizer( toPath, String.valueOf( separatorChar ) );
- fromTokeniser = new StringTokenizer( fromPath, String.valueOf( separatorChar ) );
+ toTokeniser = new StringTokenizer(toPath, String.valueOf(separatorChar));
+ fromTokeniser = new StringTokenizer(fromPath, String.valueOf(separatorChar));
- while ( count-- > 0 )
- {
+ while (count-- > 0) {
fromTokeniser.nextToken();
toTokeniser.nextToken();
}
@@ -1325,31 +1137,26 @@ public class DefaultSiteTool
StringBuilder relativePath = new StringBuilder();
// add back refs for the rest of from location.
- while ( fromTokeniser.hasMoreTokens() )
- {
+ while (fromTokeniser.hasMoreTokens()) {
fromTokeniser.nextToken();
- relativePath.append( ".." );
+ relativePath.append("..");
- if ( fromTokeniser.hasMoreTokens() )
- {
- relativePath.append( separatorChar );
+ if (fromTokeniser.hasMoreTokens()) {
+ relativePath.append(separatorChar);
}
}
- if ( relativePath.length() != 0 && toTokeniser.hasMoreTokens() )
- {
- relativePath.append( separatorChar );
+ if (relativePath.length() != 0 && toTokeniser.hasMoreTokens()) {
+ relativePath.append(separatorChar);
}
// add fwd fills for whatever's left of to.
- while ( toTokeniser.hasMoreTokens() )
- {
- relativePath.append( toTokeniser.nextToken() );
+ while (toTokeniser.hasMoreTokens()) {
+ relativePath.append(toTokeniser.nextToken());
- if ( toTokeniser.hasMoreTokens() )
- {
- relativePath.append( separatorChar );
+ if (toTokeniser.hasMoreTokens()) {
+ relativePath.append(separatorChar);
}
}
return relativePath.toString();
@@ -1362,36 +1169,29 @@ public class DefaultSiteTool
* @param href could be null
* @param defaultHref could be null
*/
- private void appendMenuItem( MavenProject project, Menu menu, String name, String href, String defaultHref )
- {
+ private void appendMenuItem(MavenProject project, Menu menu, String name, String href, String defaultHref) {
String selectedHref = href;
- if ( selectedHref == null )
- {
+ if (selectedHref == null) {
selectedHref = defaultHref;
}
MenuItem item = new MenuItem();
- item.setName( name );
-
- if ( selectedHref != null )
- {
- String baseUrl = getDistMgmntSiteUrl( project );
- if ( baseUrl != null )
- {
- selectedHref = getRelativePath( selectedHref, baseUrl );
- }
+ item.setName(name);
- if ( selectedHref.endsWith( "/" ) )
- {
- item.setHref( selectedHref + "index.html" );
+ if (selectedHref != null) {
+ String baseUrl = getDistMgmntSiteUrl(project);
+ if (baseUrl != null) {
+ selectedHref = getRelativePath(selectedHref, baseUrl);
}
- else
- {
- item.setHref( selectedHref + "/index.html" );
+
+ if (selectedHref.endsWith("/")) {
+ item.setHref(selectedHref + "index.html");
+ } else {
+ item.setHref(selectedHref + "/index.html");
}
}
- menu.addItem( item );
+ menu.addItem(item);
}
/**
@@ -1401,22 +1201,20 @@ public class DefaultSiteTool
* @param locale not null
* @return the menu item object
*/
- private MenuItem createCategoryMenu( String name, String href, List<MavenReport> categoryReports, Locale locale )
- {
+ private MenuItem createCategoryMenu(String name, String href, List<MavenReport> categoryReports, Locale locale) {
MenuItem item = new MenuItem();
- item.setName( name );
- item.setCollapse( true );
- item.setHref( href );
+ item.setName(name);
+ item.setCollapse(true);
+ item.setHref(href);
// MSHARED-172, allow reports to define their order in some other way?
- //Collections.sort( categoryReports, new ReportComparator( locale ) );
+ // Collections.sort( categoryReports, new ReportComparator( locale ) );
- for ( MavenReport report : categoryReports )
- {
+ for (MavenReport report : categoryReports) {
MenuItem subitem = new MenuItem();
- subitem.setName( report.getName( locale ) );
- subitem.setHref( report.getOutputName() + ".html" );
- item.getItems().add( subitem );
+ subitem.setName(report.getName(locale));
+ subitem.setHref(report.getOutputName() + ".html");
+ item.getItems().add(subitem);
}
return item;
@@ -1432,8 +1230,7 @@ public class DefaultSiteTool
* @param list could be null
* @return true if the list is <code>null</code> or empty
*/
- private static boolean isEmptyList( List<?> list )
- {
+ private static boolean isEmptyList(List<?> list) {
return list == null || list.isEmpty();
}
@@ -1443,17 +1240,16 @@ public class DefaultSiteTool
* @param project not null
* @return could be null
*/
- private static String getDistMgmntSiteUrl( MavenProject project )
- {
- return getDistMgmntSiteUrl( project.getDistributionManagement() );
+ private static String getDistMgmntSiteUrl(MavenProject project) {
+ return getDistMgmntSiteUrl(project.getDistributionManagement());
}
- private static String getDistMgmntSiteUrl( DistributionManagement distMgmnt )
- {
- if ( distMgmnt != null && distMgmnt.getSite() != null && distMgmnt.getSite().getUrl() != null )
- {
+ private static String getDistMgmntSiteUrl(DistributionManagement distMgmnt) {
+ if (distMgmnt != null
+ && distMgmnt.getSite() != null
+ && distMgmnt.getSite().getUrl() != null) {
// TODO This needs to go, it is just logically wrong
- return urlEncode( distMgmnt.getSite().getUrl() );
+ return urlEncode(distMgmnt.getSite().getUrl());
}
return null;
@@ -1464,19 +1260,17 @@ public class DefaultSiteTool
* @param pluginId The id of the plugin
* @return The information about the plugin.
*/
- private static Plugin getPlugin( MavenProject project, String pluginId )
- {
- if ( ( project.getBuild() == null ) || ( project.getBuild().getPluginsAsMap() == null ) )
- {
+ private static Plugin getPlugin(MavenProject project, String pluginId) {
+ if ((project.getBuild() == null) || (project.getBuild().getPluginsAsMap() == null)) {
return null;
}
- Plugin plugin = project.getBuild().getPluginsAsMap().get( pluginId );
+ Plugin plugin = project.getBuild().getPluginsAsMap().get(pluginId);
- if ( ( plugin == null ) && ( project.getBuild().getPluginManagement() != null )
- && ( project.getBuild().getPluginManagement().getPluginsAsMap() != null ) )
- {
- plugin = project.getBuild().getPluginManagement().getPluginsAsMap().get( pluginId );
+ if ((plugin == null)
+ && (project.getBuild().getPluginManagement() != null)
+ && (project.getBuild().getPluginManagement().getPluginsAsMap() != null)) {
+ plugin = project.getBuild().getPluginManagement().getPluginsAsMap().get(pluginId);
}
return plugin;
@@ -1488,35 +1282,28 @@ public class DefaultSiteTool
* @param param The child which should be checked.
* @return The value of the dom tree.
*/
- private static String getPluginParameter( MavenProject project, String pluginId, String param )
- {
- Plugin plugin = getPlugin( project, pluginId );
- if ( plugin != null )
- {
+ private static String getPluginParameter(MavenProject project, String pluginId, String param) {
+ Plugin plugin = getPlugin(project, pluginId);
+ if (plugin != null) {
Xpp3Dom xpp3Dom = (Xpp3Dom) plugin.getConfiguration();
- if ( xpp3Dom != null && xpp3Dom.getChild( param ) != null
- && StringUtils.isNotEmpty( xpp3Dom.getChild( param ).getValue() ) )
- {
- return xpp3Dom.getChild( param ).getValue();
+ if (xpp3Dom != null
+ && xpp3Dom.getChild(param) != null
+ && StringUtils.isNotEmpty(xpp3Dom.getChild(param).getValue())) {
+ return xpp3Dom.getChild(param).getValue();
}
}
return null;
}
- private static String urlEncode( final String url )
- {
- if ( url == null )
- {
+ private static String urlEncode(final String url) {
+ if (url == null) {
return null;
}
- try
- {
- return new File( url ).toURI().toURL().toExternalForm();
- }
- catch ( MalformedURLException ex )
- {
+ try {
+ return new File(url).toURI().toURL().toExternalForm();
+ } catch (MalformedURLException ex) {
return url; // this will then throw somewhere else
}
}
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/ReportComparator.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/ReportComparator.java
index f645f58..4aac8a9 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/ReportComparator.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/ReportComparator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.tools;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.tools;
import java.text.Collator;
import java.util.Comparator;
@@ -33,9 +32,7 @@ import org.apache.maven.reporting.MavenReport;
* TODO move to reporting API?
* TODO allow reports to define their order in some other way?
*/
-public class ReportComparator
- implements Comparator<MavenReport>
-{
+public class ReportComparator implements Comparator<MavenReport> {
/** the local */
private final Locale locale;
@@ -44,15 +41,13 @@ public class ReportComparator
*
* @param locale not null
*/
- public ReportComparator( Locale locale )
- {
- this.locale = Objects.requireNonNull( locale, "locale cannot be null" );
+ public ReportComparator(Locale locale) {
+ this.locale = Objects.requireNonNull(locale, "locale cannot be null");
}
/** {@inheritDoc} */
- public int compare( MavenReport r1, MavenReport r2 )
- {
- Collator collator = Collator.getInstance( locale );
- return collator.compare( r1.getName( locale ), r2.getName( locale ) );
+ public int compare(MavenReport r1, MavenReport r2) {
+ Collator collator = Collator.getInstance(locale);
+ return collator.compare(r1.getName(locale), r2.getName(locale));
}
}
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
index 2d4d814..c31d30e 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.tools;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.tools;
import java.io.File;
import java.util.List;
@@ -36,8 +35,7 @@ import org.apache.maven.reporting.MavenReport;
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-public interface SiteTool
-{
+public interface SiteTool {
/**
* The locale by default for a Maven Site.
*
@@ -55,10 +53,11 @@ public interface SiteTool
* local repository
* @throws SiteToolException if any
*/
- Artifact getSkinArtifactFromRepository( ArtifactRepository localRepository,
- List<ArtifactRepository> remoteArtifactRepositories,
- DecorationModel decoration )
- throws SiteToolException;
+ Artifact getSkinArtifactFromRepository(
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteArtifactRepositories,
+ DecorationModel decoration)
+ throws SiteToolException;
/**
* Get a site descriptor from the project's site directory.
@@ -70,8 +69,9 @@ public interface SiteTool
* to <code>site.xml</code> as last resort for {@link Locale#ROOT}, if provided
* locale defines a variant and/or a country and/or a language.
* @return the most specific site descriptor file for the given locale
- */ // used by maven-pdf-plugin (should not?)
- File getSiteDescriptor( File siteDirectory, Locale locale );
+ */
+ // used by maven-pdf-plugin (should not?)
+ File getSiteDescriptor(File siteDirectory, Locale locale);
/**
* Interpolating several expressions in the site descriptor content. Actually, the expressions can be in
@@ -102,10 +102,10 @@ public interface SiteTool
* @param siteDescriptorContent the site descriptor file, not null.
* @return the interpolated site descriptor content.
* @throws SiteToolException if errors happened during the interpolation.
- */ // used by maven-pdf-plugin (should not?)
- String getInterpolatedSiteDescriptorContent( Map<String, String> props, MavenProject aProject,
- String siteDescriptorContent )
- throws SiteToolException;
+ */
+ // used by maven-pdf-plugin (should not?)
+ String getInterpolatedSiteDescriptorContent(
+ Map<String, String> props, MavenProject aProject, String siteDescriptorContent) throws SiteToolException;
/**
* Get a decoration model for a project.
@@ -122,10 +122,14 @@ public interface SiteTool
* @throws SiteToolException if any
* @since 1.7, was previously with other parameter types and order
*/
- DecorationModel getDecorationModel( File siteDirectory, Locale locale, MavenProject project,
- List<MavenProject> reactorProjects, ArtifactRepository localRepository,
- List<ArtifactRepository> repositories )
- throws SiteToolException;
+ DecorationModel getDecorationModel(
+ File siteDirectory,
+ Locale locale,
+ MavenProject project,
+ List<MavenProject> reactorProjects,
+ ArtifactRepository localRepository,
+ List<ArtifactRepository> repositories)
+ throws SiteToolException;
/**
* Populate the pre-defined <code>reports</code> menu of the decoration model,
@@ -139,8 +143,8 @@ public interface SiteTool
* @see MavenReport#CATEGORY_PROJECT_INFORMATION
* @see MavenReport#CATEGORY_PROJECT_REPORTS
*/
- void populateReportsMenu( DecorationModel decorationModel, Locale locale,
- Map<String, List<MavenReport>> reportsPerCategory );
+ void populateReportsMenu(
+ DecorationModel decorationModel, Locale locale, Map<String, List<MavenReport>> reportsPerCategory);
/**
* Extracts from a comma-separated list the locales that are available in <code>site-tool</code>
@@ -150,7 +154,7 @@ public interface SiteTool
* @return a list of <code>Locale</code>s.
* @since 1.7, was previously getAvailableLocales(String)
*/
- List<Locale> getSiteLocales( String locales );
+ List<Locale> getSiteLocales(String locales);
/**
* Calculate the relative path between two URLs or between two files.
@@ -174,7 +178,7 @@ public interface SiteTool
* @param from the <code>from</code> url of file as string
* @return a relative path from <code>from</code> to <code>to</code>.
*/
- String getRelativePath( String to, String from );
+ String getRelativePath(String to, String from);
/**
* Returns the parent POM with interpolated URLs.
@@ -191,6 +195,6 @@ public interface SiteTool
* @return the parent project with interpolated URLs.
*/
@Deprecated
- MavenProject getParentProject( MavenProject aProject, List<MavenProject> reactorProjects,
- ArtifactRepository localRepository );
+ MavenProject getParentProject(
+ MavenProject aProject, List<MavenProject> reactorProjects, ArtifactRepository localRepository);
}
diff --git a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteToolException.java b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteToolException.java
index 1b2fd10..8cdb2ff 100644
--- a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteToolException.java
+++ b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteToolException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,15 +16,14 @@ package org.apache.maven.doxia.tools;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.tools;
/**
* An exception occurring during the execution of this tool.
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-public class SiteToolException
- extends Exception
-{
+public class SiteToolException extends Exception {
/** serialVersionUID */
static final long serialVersionUID = 2331441332996055959L;
@@ -37,9 +34,8 @@ public class SiteToolException
* @param message could be null
* @param cause could be null
*/
- public SiteToolException( String message, Exception cause )
- {
- super( message, cause );
+ public SiteToolException(String message, Exception cause) {
+ super(message, cause);
}
/**
@@ -49,9 +45,8 @@ public class SiteToolException
* @param message could be null
* @param cause could be null
*/
- public SiteToolException( String message, Throwable cause )
- {
- super( message, cause );
+ public SiteToolException(String message, Throwable cause) {
+ super(message, cause);
}
/**
@@ -59,8 +54,7 @@ public class SiteToolException
*
* @param message could be null
*/
- public SiteToolException( String message )
- {
- super( message );
+ public SiteToolException(String message) {
+ super(message);
}
}
diff --git a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/DefaultSiteToolTest.java b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/DefaultSiteToolTest.java
index e6a0dbb..ad5b8c1 100644
--- a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/DefaultSiteToolTest.java
+++ b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/DefaultSiteToolTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +16,7 @@ package org.apache.maven.doxia.tools;
* specific language governing permissions and limitations
* under the License.
*/
-
-
+package org.apache.maven.doxia.tools;
import java.io.File;
@@ -32,8 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-public class DefaultSiteToolTest
-{
+public class DefaultSiteToolTest {
private DefaultSiteTool tool = new DefaultSiteTool();
@@ -41,68 +37,63 @@ public class DefaultSiteToolTest
* test getNormalizedPath().
*/
@Test
- public void testGetNormalizedPath()
- {
- assertNull( DefaultSiteTool.getNormalizedPath( null ) );
- assertEquals( "", DefaultSiteTool.getNormalizedPath( "" ) );
- assertEquals( "", DefaultSiteTool.getNormalizedPath( "." ) );
- assertEquals( "", DefaultSiteTool.getNormalizedPath( "./" ) );
- assertEquals( "foo", DefaultSiteTool.getNormalizedPath( "foo" ) );
- assertEquals( "foo/bar", DefaultSiteTool.getNormalizedPath( "foo/bar" ) );
- assertEquals( "foo/bar", DefaultSiteTool.getNormalizedPath( "foo\\bar" ) );
- assertEquals( "foo/bar", DefaultSiteTool.getNormalizedPath( "foo/./bar" ) );
- assertEquals( "foo/bar", DefaultSiteTool.getNormalizedPath( "foo//bar" ) );
- assertEquals( "", DefaultSiteTool.getNormalizedPath( "foo/../" ) );
- assertEquals( "", DefaultSiteTool.getNormalizedPath( "foo/.." ) );
- assertEquals( "bar", DefaultSiteTool.getNormalizedPath( "foo/../bar" ) );
- assertEquals( "foo", DefaultSiteTool.getNormalizedPath( "./foo" ) );
- assertEquals( "../foo", DefaultSiteTool.getNormalizedPath( "../foo" ) );
- assertEquals( "../../foo", DefaultSiteTool.getNormalizedPath( "../../foo" ) );
- assertEquals( "index.html", DefaultSiteTool.getNormalizedPath( "./foo/../index.html" ) );
+ public void testGetNormalizedPath() {
+ assertNull(DefaultSiteTool.getNormalizedPath(null));
+ assertEquals("", DefaultSiteTool.getNormalizedPath(""));
+ assertEquals("", DefaultSiteTool.getNormalizedPath("."));
+ assertEquals("", DefaultSiteTool.getNormalizedPath("./"));
+ assertEquals("foo", DefaultSiteTool.getNormalizedPath("foo"));
+ assertEquals("foo/bar", DefaultSiteTool.getNormalizedPath("foo/bar"));
+ assertEquals("foo/bar", DefaultSiteTool.getNormalizedPath("foo\\bar"));
+ assertEquals("foo/bar", DefaultSiteTool.getNormalizedPath("foo/./bar"));
+ assertEquals("foo/bar", DefaultSiteTool.getNormalizedPath("foo//bar"));
+ assertEquals("", DefaultSiteTool.getNormalizedPath("foo/../"));
+ assertEquals("", DefaultSiteTool.getNormalizedPath("foo/.."));
+ assertEquals("bar", DefaultSiteTool.getNormalizedPath("foo/../bar"));
+ assertEquals("foo", DefaultSiteTool.getNormalizedPath("./foo"));
+ assertEquals("../foo", DefaultSiteTool.getNormalizedPath("../foo"));
+ assertEquals("../../foo", DefaultSiteTool.getNormalizedPath("../../foo"));
+ assertEquals("index.html", DefaultSiteTool.getNormalizedPath("./foo/../index.html"));
// note: space is preserved and double slash is removed!
- assertEquals( "file:/Documents and Settings/",
- DefaultSiteTool.getNormalizedPath( "file://Documents and Settings/" ) );
+ assertEquals(
+ "file:/Documents and Settings/", DefaultSiteTool.getNormalizedPath("file://Documents and Settings/"));
}
@SuppressWarnings("deprecation")
@Test
- public void testGetRelativePath()
- {
+ public void testGetRelativePath() {
assertEquals(
- ".." + File.separator + "bar.html",
- tool.getRelativePath("http://example.com/foo/bar.html", "http://example.com/foo/baz.html"));
+ ".." + File.separator + "bar.html",
+ tool.getRelativePath("http://example.com/foo/bar.html", "http://example.com/foo/baz.html"));
}
@SuppressWarnings("deprecation")
@Test
- public void testGetRelativePath_same()
- {
- assertTrue(
- tool.getRelativePath( "http://example.com/foo/bar.html", "http://example.com/foo/bar.html" ).isEmpty() );
+ public void testGetRelativePath_same() {
+ assertTrue(tool.getRelativePath("http://example.com/foo/bar.html", "http://example.com/foo/bar.html")
+ .isEmpty());
}
@SuppressWarnings("deprecation")
@Test
public void testGetRelativePath_differentSchemes() {
assertEquals(
- "scp://example.com/foo/bar.html",
- tool.getRelativePath( "scp://example.com/foo/bar.html", "http://example.com/foo/bar.html" ) );
- assertEquals(
- "file:///tmp/bloop",
- tool.getRelativePath( "file:///tmp/bloop", "scp://localhost:/tmp/blop" ) );
+ "scp://example.com/foo/bar.html",
+ tool.getRelativePath("scp://example.com/foo/bar.html", "http://example.com/foo/bar.html"));
+ assertEquals("file:///tmp/bloop", tool.getRelativePath("file:///tmp/bloop", "scp://localhost:/tmp/blop"));
}
@SuppressWarnings("deprecation")
@Test
public void testGetRelativePath_differentDomains() {
assertEquals(
- "https://example.org/bar.html",
- tool.getRelativePath( "https://example.org/bar.html", "https://example.com/bar.html" ) );
+ "https://example.org/bar.html",
+ tool.getRelativePath("https://example.org/bar.html", "https://example.com/bar.html"));
assertEquals(
- "dav:https://nexus2.mysite.net:123/nexus/content/sites/site/mysite-child/2.0.0/",
- tool.getRelativePath(
- "dav:https://nexus2.mysite.net:123/nexus/content/sites/site/mysite-child/2.0.0/",
- "dav:https://nexus1.mysite.net:123/nexus/content/sites/site/mysite-parent/1.0.0/" ));
+ "dav:https://nexus2.mysite.net:123/nexus/content/sites/site/mysite-child/2.0.0/",
+ tool.getRelativePath(
+ "dav:https://nexus2.mysite.net:123/nexus/content/sites/site/mysite-child/2.0.0/",
+ "dav:https://nexus1.mysite.net:123/nexus/content/sites/site/mysite-parent/1.0.0/"));
}
}
diff --git a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
index 05b6022..34ce2e4 100644
--- a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
+++ b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.tools;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.tools;
import javax.inject.Inject;
import javax.inject.Named;
@@ -42,7 +41,6 @@ import org.apache.maven.doxia.site.decoration.Skin;
import org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Writer;
import org.apache.maven.doxia.tools.stubs.SiteToolMavenProjectStub;
import org.apache.maven.project.MavenProject;
-
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.FileUtils;
@@ -61,10 +59,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-@SuppressWarnings( "javadoc" )
+@SuppressWarnings("javadoc")
@PlexusTest
-public class SiteToolTest
-{
+public class SiteToolTest {
@Inject
private PlexusContainer container;
@@ -72,7 +69,8 @@ public class SiteToolTest
@Inject
private ArtifactRepositoryFactory artifactRepositoryFactory;
- @Inject @Named( "default" )
+ @Inject
+ @Named("default")
private ArtifactRepositoryLayout defaultArtifactRepositoryLayout;
@Inject
@@ -83,17 +81,19 @@ public class SiteToolTest
*
* @throws Exception
*/
- protected ArtifactRepository getLocalRepo()
- throws Exception
- {
+ protected ArtifactRepository getLocalRepo() throws Exception {
String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS;
String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
- ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag,
- checksumPolicyFlag );
- ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy( true, updatePolicyFlag,
- checksumPolicyFlag );
- return artifactRepositoryFactory.createArtifactRepository( "local", getTestFile( "target/local-repo" ).toURI().toURL()
- .toString(), defaultArtifactRepositoryLayout, snapshotsPolicy, releasesPolicy );
+ ArtifactRepositoryPolicy snapshotsPolicy =
+ new ArtifactRepositoryPolicy(true, updatePolicyFlag, checksumPolicyFlag);
+ ArtifactRepositoryPolicy releasesPolicy =
+ new ArtifactRepositoryPolicy(true, updatePolicyFlag, checksumPolicyFlag);
+ return artifactRepositoryFactory.createArtifactRepository(
+ "local",
+ getTestFile("target/local-repo").toURI().toURL().toString(),
+ defaultArtifactRepositoryLayout,
+ snapshotsPolicy,
+ releasesPolicy);
}
/**
@@ -101,68 +101,71 @@ public class SiteToolTest
*
* @throws Exception
*/
- protected File getLocalRepoDir()
- throws Exception
- {
- return new File( getLocalRepo().getBasedir() );
+ protected File getLocalRepoDir() throws Exception {
+ return new File(getLocalRepo().getBasedir());
}
/**
* @throws Exception
*/
@Test
- public void testGetSkinArtifactFromRepository()
- throws Exception
- {
- assertNotNull( tool );
+ public void testGetSkinArtifactFromRepository() throws Exception {
+ assertNotNull(tool);
- SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "site-tool-test" );
+ SiteToolMavenProjectStub project = new SiteToolMavenProjectStub("site-tool-test");
DecorationModel decorationModel = new DecorationModel();
Skin skin = new Skin();
- skin.setGroupId( "org.apache.maven.skins" );
- skin.setArtifactId( "maven-stylus-skin" );
- decorationModel.setSkin( skin );
- assertNotNull( tool.getSkinArtifactFromRepository( getLocalRepo(), project.getRemoteArtifactRepositories(),
- decorationModel ) );
+ skin.setGroupId("org.apache.maven.skins");
+ skin.setArtifactId("maven-stylus-skin");
+ decorationModel.setSkin(skin);
+ assertNotNull(tool.getSkinArtifactFromRepository(
+ getLocalRepo(), project.getRemoteArtifactRepositories(), decorationModel));
}
- private void checkGetRelativePathDirectory( SiteTool tool, String relative, String to, String from )
- {
- assertEquals( relative, tool.getRelativePath( to, from ) );
- assertEquals( relative, tool.getRelativePath( to + '/', from ) );
- assertEquals( relative, tool.getRelativePath( to, from + '/' ) );
- assertEquals( relative, tool.getRelativePath( to + '/', from + '/' ) );
+ private void checkGetRelativePathDirectory(SiteTool tool, String relative, String to, String from) {
+ assertEquals(relative, tool.getRelativePath(to, from));
+ assertEquals(relative, tool.getRelativePath(to + '/', from));
+ assertEquals(relative, tool.getRelativePath(to, from + '/'));
+ assertEquals(relative, tool.getRelativePath(to + '/', from + '/'));
}
/**
* @throws Exception
*/
@Test
- @SuppressWarnings( { "deprecation" } )
- public void testGetRelativePath()
- throws Exception
- {
- assertNotNull( tool );
+ @SuppressWarnings({"deprecation"})
+ public void testGetRelativePath() throws Exception {
+ assertNotNull(tool);
- checkGetRelativePathDirectory( tool, "", "http://maven.apache.org", "http://maven.apache.org" );
+ checkGetRelativePathDirectory(tool, "", "http://maven.apache.org", "http://maven.apache.org");
- checkGetRelativePathDirectory( tool, ".." + File.separator + "..", "http://maven.apache.org",
- "http://maven.apache.org/plugins/maven-site-plugin" );
+ checkGetRelativePathDirectory(
+ tool,
+ ".." + File.separator + "..",
+ "http://maven.apache.org",
+ "http://maven.apache.org/plugins/maven-site-plugin");
- checkGetRelativePathDirectory( tool, "plugins" + File.separator + "maven-site-plugin",
- "http://maven.apache.org/plugins/maven-site-plugin", "http://maven.apache.org" );
+ checkGetRelativePathDirectory(
+ tool,
+ "plugins" + File.separator + "maven-site-plugin",
+ "http://maven.apache.org/plugins/maven-site-plugin",
+ "http://maven.apache.org");
- checkGetRelativePathDirectory( tool, "", "dav:https://maven.apache.org", "dav:https://maven.apache.org" );
+ checkGetRelativePathDirectory(tool, "", "dav:https://maven.apache.org", "dav:https://maven.apache.org");
- checkGetRelativePathDirectory( tool, "plugins" + File.separator + "maven-site-plugin",
- "dav:http://maven.apache.org/plugins/maven-site-plugin",
- "dav:http://maven.apache.org" );
+ checkGetRelativePathDirectory(
+ tool,
+ "plugins" + File.separator + "maven-site-plugin",
+ "dav:http://maven.apache.org/plugins/maven-site-plugin",
+ "dav:http://maven.apache.org");
- checkGetRelativePathDirectory( tool, "", "scm:svn:https://maven.apache.org", "scm:svn:https://maven.apache.org" );
+ checkGetRelativePathDirectory(tool, "", "scm:svn:https://maven.apache.org", "scm:svn:https://maven.apache.org");
- checkGetRelativePathDirectory( tool, "plugins" + File.separator + "maven-site-plugin",
- "scm:svn:https://maven.apache.org/plugins/maven-site-plugin",
- "scm:svn:https://maven.apache.org" );
+ checkGetRelativePathDirectory(
+ tool,
+ "plugins" + File.separator + "maven-site-plugin",
+ "scm:svn:https://maven.apache.org/plugins/maven-site-plugin",
+ "scm:svn:https://maven.apache.org");
String to = "http://maven.apache.org/downloads.html";
String from = "http://maven.apache.org/index.html";
@@ -170,282 +173,347 @@ public class SiteToolTest
// MSITE-600, MSHARED-203
to = "file:///tmp/bloop";
from = "scp://localhost:/tmp/blop";
- assertEquals( tool.getRelativePath( to, from ), to );
+ assertEquals(tool.getRelativePath(to, from), to);
// note: 'tmp' is the host here which is probably not the intention, but at least the result is correct
to = "file://tmp/bloop";
from = "scp://localhost:/tmp/blop";
- assertEquals( to, tool.getRelativePath( to, from ) );
+ assertEquals(to, tool.getRelativePath(to, from));
// Tests between files as described in MIDEA-102
to = "C:/dev/voca/gateway/parser/gateway-parser.iml";
from = "C:/dev/voca/gateway/";
- assertEquals( "parser" + File.separator + "gateway-parser.iml", tool.getRelativePath( to, from ),
- "Child file using Windows drive letter");
+ assertEquals(
+ "parser" + File.separator + "gateway-parser.iml",
+ tool.getRelativePath(to, from),
+ "Child file using Windows drive letter");
to = "C:/foo/child";
from = "C:/foo/master";
- assertEquals( ".." + File.separator + "child", tool.getRelativePath( to, from ),
- "Sibling directory using Windows drive letter" );
+ assertEquals(
+ ".." + File.separator + "child",
+ tool.getRelativePath(to, from),
+ "Sibling directory using Windows drive letter");
to = "/myproject/myproject-module1";
from = "/myproject/myproject";
- assertEquals( ".." + File.separator + "myproject-module1", tool.getRelativePath( to, from ),
- "Sibling directory with similar name" );
+ assertEquals(
+ ".." + File.separator + "myproject-module1",
+ tool.getRelativePath(to, from),
+ "Sibling directory with similar name");
// Normalized paths as described in MSITE-284
- assertEquals( ".." + File.separator + "project-module-1" + File.separator + "src" + File.separator + "site",
- tool.getRelativePath( "Z:\\dir\\project\\project-module-1\\src\\site",
- "Z:\\dir\\project\\project-module-1\\..\\project-parent" ) );
- assertEquals( ".." + File.separator + ".." + File.separator + ".." + File.separator + "project-parent",
- tool.getRelativePath( "Z:\\dir\\project\\project-module-1\\..\\project-parent",
- "Z:\\dir\\project\\project-module-1\\src\\site" ) );
-
- assertEquals( ".." + File.separator + "foo", tool.getRelativePath( "../../foo/foo", "../../foo/bar" ) );
+ assertEquals(
+ ".." + File.separator + "project-module-1" + File.separator + "src" + File.separator + "site",
+ tool.getRelativePath(
+ "Z:\\dir\\project\\project-module-1\\src\\site",
+ "Z:\\dir\\project\\project-module-1\\..\\project-parent"));
+ assertEquals(
+ ".." + File.separator + ".." + File.separator + ".." + File.separator + "project-parent",
+ tool.getRelativePath(
+ "Z:\\dir\\project\\project-module-1\\..\\project-parent",
+ "Z:\\dir\\project\\project-module-1\\src\\site"));
+
+ assertEquals(".." + File.separator + "foo", tool.getRelativePath("../../foo/foo", "../../foo/bar"));
}
/**
* @throws Exception
*/
@Test
- public void testGetSiteDescriptorFromBasedir()
- throws Exception
- {
- assertNotNull( tool );
-
- SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "site-tool-test" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), SiteTool.DEFAULT_LOCALE ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.ENGLISH ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
+ public void testGetSiteDescriptorFromBasedir() throws Exception {
+ assertNotNull(tool);
+
+ SiteToolMavenProjectStub project = new SiteToolMavenProjectStub("site-tool-test");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), SiteTool.DEFAULT_LOCALE)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.ENGLISH)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
String siteDir = "src/blabla";
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), siteDir ), SiteTool.DEFAULT_LOCALE ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "blabla" + File.separator + "site.xml" );
-
- project = new SiteToolMavenProjectStub( "site-tool-locales-test/full" );
- final Locale BAVARIAN = new Locale( "de", "DE", "BY" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), SiteTool.DEFAULT_LOCALE ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), BAVARIAN ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site_de_DE_BY.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.GERMANY ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.ENGLISH ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.GERMAN ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
-
- project = new SiteToolMavenProjectStub( "site-tool-locales-test/language_country" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), SiteTool.DEFAULT_LOCALE ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), BAVARIAN ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site_de_DE.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.GERMANY ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site_de_DE.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.ENGLISH ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.GERMAN ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
-
- project = new SiteToolMavenProjectStub( "site-tool-locales-test/language" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), SiteTool.DEFAULT_LOCALE ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), BAVARIAN ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site_de.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.GERMANY ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site_de.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.ENGLISH ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml" );
- assertEquals( tool.getSiteDescriptor( new File( project.getBasedir(), "src/site" ), Locale.GERMAN ).toString(),
- project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site_de.xml" );
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), siteDir), SiteTool.DEFAULT_LOCALE)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "blabla" + File.separator
+ + "site.xml");
+
+ project = new SiteToolMavenProjectStub("site-tool-locales-test/full");
+ final Locale BAVARIAN = new Locale("de", "DE", "BY");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), SiteTool.DEFAULT_LOCALE)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), BAVARIAN)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator
+ + "site_de_DE_BY.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.GERMANY)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.ENGLISH)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.GERMAN)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+
+ project = new SiteToolMavenProjectStub("site-tool-locales-test/language_country");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), SiteTool.DEFAULT_LOCALE)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), BAVARIAN)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator
+ + "site_de_DE.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.GERMANY)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator
+ + "site_de_DE.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.ENGLISH)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.GERMAN)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+
+ project = new SiteToolMavenProjectStub("site-tool-locales-test/language");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), SiteTool.DEFAULT_LOCALE)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), BAVARIAN)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator
+ + "site_de.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.GERMANY)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator
+ + "site_de.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.ENGLISH)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator + "site.xml");
+ assertEquals(
+ tool.getSiteDescriptor(new File(project.getBasedir(), "src/site"), Locale.GERMAN)
+ .toString(),
+ project.getBasedir() + File.separator + "src" + File.separator + "site" + File.separator
+ + "site_de.xml");
}
/**
* @throws Exception
*/
@Test
- public void testGetSiteDescriptorFromRepository()
- throws Exception
- {
- assertNotNull( tool );
-
- SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "site-tool-test" );
- project.setGroupId( "org.apache.maven" );
- project.setArtifactId( "maven-site" );
- project.setVersion( "1.0" );
- String result = getLocalRepoDir() + File.separator + "org" + File.separator + "apache" + File.separator
- + "maven" + File.separator + "maven-site" + File.separator + "1.0" + File.separator
- + "maven-site-1.0-site.xml";
+ public void testGetSiteDescriptorFromRepository() throws Exception {
+ assertNotNull(tool);
- assertEquals( tool.getSiteDescriptorFromRepository( project, getLocalRepo(),
- project.getRemoteArtifactRepositories(), SiteTool.DEFAULT_LOCALE )
- .toString(), result );
+ SiteToolMavenProjectStub project = new SiteToolMavenProjectStub("site-tool-test");
+ project.setGroupId("org.apache.maven");
+ project.setArtifactId("maven-site");
+ project.setVersion("1.0");
+ String result = getLocalRepoDir() + File.separator + "org" + File.separator + "apache" + File.separator
+ + "maven" + File.separator + "maven-site" + File.separator + "1.0" + File.separator
+ + "maven-site-1.0-site.xml";
+
+ assertEquals(
+ tool.getSiteDescriptorFromRepository(
+ project,
+ getLocalRepo(),
+ project.getRemoteArtifactRepositories(),
+ SiteTool.DEFAULT_LOCALE)
+ .toString(),
+ result);
}
/**
* @throws Exception
*/
@Test
- public void testGetDecorationModel()
- throws Exception
- {
- assertNotNull( tool );
+ public void testGetDecorationModel() throws Exception {
+ assertNotNull(tool);
- SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "site-tool-test" );
+ SiteToolMavenProjectStub project = new SiteToolMavenProjectStub("site-tool-test");
List<MavenProject> reactorProjects = new ArrayList<MavenProject>();
// model from current local build
- DecorationModel model =
- tool.getDecorationModel( new File( project.getBasedir(), "src/site" ), SiteTool.DEFAULT_LOCALE, project,
- reactorProjects, getLocalRepo(), project.getRemoteArtifactRepositories() );
- assertNotNull( model );
- assertNotNull( model.getBannerLeft() );
- assertEquals( "Maven Site", model.getBannerLeft().getName() );
- assertEquals( "http://maven.apache.org/images/apache-maven-project.png", model.getBannerLeft().getSrc() );
- assertEquals( "http://maven.apache.org/", model.getBannerLeft().getHref() );
- assertNotNull( model.getBannerRight() );
- assertNull( model.getBannerRight().getName() );
- assertEquals( "http://maven.apache.org/images/maven-small.gif", model.getBannerRight().getSrc() );
- assertNull( model.getBannerRight().getHref() );
+ DecorationModel model = tool.getDecorationModel(
+ new File(project.getBasedir(), "src/site"),
+ SiteTool.DEFAULT_LOCALE,
+ project,
+ reactorProjects,
+ getLocalRepo(),
+ project.getRemoteArtifactRepositories());
+ assertNotNull(model);
+ assertNotNull(model.getBannerLeft());
+ assertEquals("Maven Site", model.getBannerLeft().getName());
+ assertEquals(
+ "http://maven.apache.org/images/apache-maven-project.png",
+ model.getBannerLeft().getSrc());
+ assertEquals("http://maven.apache.org/", model.getBannerLeft().getHref());
+ assertNotNull(model.getBannerRight());
+ assertNull(model.getBannerRight().getName());
+ assertEquals(
+ "http://maven.apache.org/images/maven-small.gif",
+ model.getBannerRight().getSrc());
+ assertNull(model.getBannerRight().getHref());
// model from repo: https://repo1.maven.org/maven2/org/apache/maven/maven/3.8.6/maven-3.8.6-site.xml
- project.setBasedir( null );
- project.setGroupId( "org.apache.maven" );
- project.setArtifactId( "maven" );
- project.setVersion( "3.8.6" );
- DecorationModel modelFromRepo =
- tool.getDecorationModel( null, SiteTool.DEFAULT_LOCALE, project, reactorProjects, getLocalRepo(),
- project.getRemoteArtifactRepositories() );
- assertNotNull( modelFromRepo );
- assertNotNull( modelFromRepo.getBannerLeft() );
- assertEquals( "dummy", modelFromRepo.getBannerLeft().getName() );
- assertEquals( "https://maven.apache.org/images/apache-maven-project.png", modelFromRepo.getBannerLeft().getSrc() );
- assertEquals( "https://maven.apache.org/", modelFromRepo.getBannerLeft().getHref() );
- assertNull( modelFromRepo.getBannerRight() );
+ project.setBasedir(null);
+ project.setGroupId("org.apache.maven");
+ project.setArtifactId("maven");
+ project.setVersion("3.8.6");
+ DecorationModel modelFromRepo = tool.getDecorationModel(
+ null,
+ SiteTool.DEFAULT_LOCALE,
+ project,
+ reactorProjects,
+ getLocalRepo(),
+ project.getRemoteArtifactRepositories());
+ assertNotNull(modelFromRepo);
+ assertNotNull(modelFromRepo.getBannerLeft());
+ assertEquals("dummy", modelFromRepo.getBannerLeft().getName());
+ assertEquals(
+ "https://maven.apache.org/images/apache-maven-project.png",
+ modelFromRepo.getBannerLeft().getSrc());
+ assertEquals("https://maven.apache.org/", modelFromRepo.getBannerLeft().getHref());
+ assertNull(modelFromRepo.getBannerRight());
}
/**
* @throws Exception
*/
@Test
- public void testGetDefaultDecorationModel()
- throws Exception
- {
- assertNotNull( tool );
+ public void testGetDefaultDecorationModel() throws Exception {
+ assertNotNull(tool);
- SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "no-site-test" );
+ SiteToolMavenProjectStub project = new SiteToolMavenProjectStub("no-site-test");
String siteDirectory = "src/site";
List<MavenProject> reactorProjects = new ArrayList<MavenProject>();
- DecorationModel model =
- tool.getDecorationModel( new File( project.getBasedir(), siteDirectory ), SiteTool.DEFAULT_LOCALE, project,
- reactorProjects, getLocalRepo(), project.getRemoteArtifactRepositories() );
- assertNotNull( model );
+ DecorationModel model = tool.getDecorationModel(
+ new File(project.getBasedir(), siteDirectory),
+ SiteTool.DEFAULT_LOCALE,
+ project,
+ reactorProjects,
+ getLocalRepo(),
+ project.getRemoteArtifactRepositories());
+ assertNotNull(model);
}
@Test
- public void testGetAvailableLocales()
- throws Exception
- {
- assertEquals( Collections.singletonList( SiteTool.DEFAULT_LOCALE ), tool.getSiteLocales( "default" ) );
+ public void testGetAvailableLocales() throws Exception {
+ assertEquals(Collections.singletonList(SiteTool.DEFAULT_LOCALE), tool.getSiteLocales("default"));
- assertEquals( Arrays.asList( SiteTool.DEFAULT_LOCALE, Locale.FRENCH, Locale.ITALIAN ),
- tool.getSiteLocales( "default,fr,it" ) );
+ assertEquals(
+ Arrays.asList(SiteTool.DEFAULT_LOCALE, Locale.FRENCH, Locale.ITALIAN),
+ tool.getSiteLocales("default,fr,it"));
// by default, only DEFAULT_LOCALE
- assertEquals( Collections.singletonList( SiteTool.DEFAULT_LOCALE ), tool.getSiteLocales( "" ) );
+ assertEquals(Collections.singletonList(SiteTool.DEFAULT_LOCALE), tool.getSiteLocales(""));
}
@Test
- public void testGetInterpolatedSiteDescriptorContent()
- throws Exception
- {
- assertNotNull( tool );
-
- File pomXmlFile = getTestFile( "src/test/resources/unit/interpolated-site/pom.xml" );
- assertNotNull( pomXmlFile );
- assertTrue( pomXmlFile.exists() );
-
- File descriptorFile = getTestFile( "src/test/resources/unit/interpolated-site/src/site/site.xml" );
- assertNotNull( descriptorFile );
- assertTrue( descriptorFile.exists() );
-
- String siteDescriptorContent = FileUtils.fileRead( descriptorFile );
- assertNotNull( siteDescriptorContent );
- assertTrue( siteDescriptorContent.contains( "${project.name}" ) );
- assertFalse( siteDescriptorContent.contains( "Interpolatesite" ) );
-
- SiteToolMavenProjectStub project = new SiteToolMavenProjectStub( "interpolated-site" );
-
- siteDescriptorContent =
- tool.getInterpolatedSiteDescriptorContent( new HashMap<String, String>(), project,
- siteDescriptorContent );
- assertNotNull( siteDescriptorContent );
- assertFalse( siteDescriptorContent.contains( "${project.name}" ) );
- assertTrue( siteDescriptorContent.contains( "Interpolatesite" ) );
+ public void testGetInterpolatedSiteDescriptorContent() throws Exception {
+ assertNotNull(tool);
+
+ File pomXmlFile = getTestFile("src/test/resources/unit/interpolated-site/pom.xml");
+ assertNotNull(pomXmlFile);
+ assertTrue(pomXmlFile.exists());
+
+ File descriptorFile = getTestFile("src/test/resources/unit/interpolated-site/src/site/site.xml");
+ assertNotNull(descriptorFile);
+ assertTrue(descriptorFile.exists());
+
+ String siteDescriptorContent = FileUtils.fileRead(descriptorFile);
+ assertNotNull(siteDescriptorContent);
+ assertTrue(siteDescriptorContent.contains("${project.name}"));
+ assertFalse(siteDescriptorContent.contains("Interpolatesite"));
+
+ SiteToolMavenProjectStub project = new SiteToolMavenProjectStub("interpolated-site");
+
+ siteDescriptorContent = tool.getInterpolatedSiteDescriptorContent(
+ new HashMap<String, String>(), project, siteDescriptorContent);
+ assertNotNull(siteDescriptorContent);
+ assertFalse(siteDescriptorContent.contains("${project.name}"));
+ assertTrue(siteDescriptorContent.contains("Interpolatesite"));
}
// MSHARED-217 -> DOXIATOOLS-34 -> DOXIASITETOOLS-118
@Test
- public void testDecorationModelInheritanceAndInterpolation()
- throws Exception
- {
- assertNotNull( tool );
+ public void testDecorationModelInheritanceAndInterpolation() throws Exception {
+ assertNotNull(tool);
- SiteToolMavenProjectStub parentProject = new SiteToolMavenProjectStub( "interpolation-parent-test" );
- parentProject.setDistgributionManagementSiteUrl( "dav+https://davs.codehaus.org/site" );
+ SiteToolMavenProjectStub parentProject = new SiteToolMavenProjectStub("interpolation-parent-test");
+ parentProject.setDistgributionManagementSiteUrl("dav+https://davs.codehaus.org/site");
- SiteToolMavenProjectStub childProject = new SiteToolMavenProjectStub( "interpolation-child-test" );
- childProject.setParent( parentProject );
- childProject.setDistgributionManagementSiteUrl( "dav+https://davs.codehaus.org/site/child" );
+ SiteToolMavenProjectStub childProject = new SiteToolMavenProjectStub("interpolation-child-test");
+ childProject.setParent(parentProject);
+ childProject.setDistgributionManagementSiteUrl("dav+https://davs.codehaus.org/site/child");
- List<MavenProject> reactorProjects = Collections.<MavenProject>singletonList( parentProject );
+ List<MavenProject> reactorProjects = Collections.<MavenProject>singletonList(parentProject);
- DecorationModel model = tool.getDecorationModel( new File( childProject.getBasedir(), "src/site" ),
- SiteTool.DEFAULT_LOCALE, childProject, reactorProjects,
- getLocalRepo(), childProject.getRemoteArtifactRepositories() );
- assertNotNull( model );
+ DecorationModel model = tool.getDecorationModel(
+ new File(childProject.getBasedir(), "src/site"),
+ SiteTool.DEFAULT_LOCALE,
+ childProject,
+ reactorProjects,
+ getLocalRepo(),
+ childProject.getRemoteArtifactRepositories());
+ assertNotNull(model);
- writeModel( model, "unit/interpolation-child-test/effective-site.xml" );
+ writeModel(model, "unit/interpolation-child-test/effective-site.xml");
- assertEquals( "MSHARED-217 Child", model.getName() );
+ assertEquals("MSHARED-217 Child", model.getName());
// late (classical) interpolation
- assertEquals( "project.artifactId = mshared-217-child", model.getBannerLeft().getName() );
+ assertEquals(
+ "project.artifactId = mshared-217-child", model.getBannerLeft().getName());
// early interpolation: DOXIASITETOOLS-158
- assertEquals( "this.artifactId = mshared-217-parent", model.getBannerRight().getName() );
+ assertEquals(
+ "this.artifactId = mshared-217-parent", model.getBannerRight().getName());
// href rebase
- assertEquals( "../../index.html", model.getBody().getBreadcrumbs().iterator().next().getHref() );
+ assertEquals(
+ "../../index.html",
+ model.getBody().getBreadcrumbs().iterator().next().getHref());
Iterator<LinkItem> links = model.getBody().getLinks().iterator();
// late interpolation of pom content
- assertEquals( "project.name = MSHARED-217 Child", links.next().getName() );
- assertEquals( "name = name property", links.next().getName() );
+ assertEquals("project.name = MSHARED-217 Child", links.next().getName());
+ assertEquals("name = name property", links.next().getName());
// early interpolation: DOXIASITETOOLS-158
- assertEquals( "this.name = MSHARED-217 Parent", links.next().getName() );
+ assertEquals("this.name = MSHARED-217 Parent", links.next().getName());
// late interpolation of project properties
- assertEquals( "my_property = from child pom.xml", links.next().getName() );
+ assertEquals("my_property = from child pom.xml", links.next().getName());
// early interpolation of project properties: DOXIASITETOOLS-158
- assertEquals( "this.my_property = from parent pom.xml", links.next().getName() );
+ assertEquals("this.my_property = from parent pom.xml", links.next().getName());
// Env Var interpolation
String envPath = links.next().getName();
- assertTrue( envPath.startsWith( "env.PATH = " ) );
- assertFalse( envPath.contains( "${" ) );
- assertNotSame( "env.PATH = PATH property from pom", envPath );
+ assertTrue(envPath.startsWith("env.PATH = "));
+ assertFalse(envPath.contains("${"));
+ assertNotSame("env.PATH = PATH property from pom", envPath);
// property overrides env
- assertEquals( "PATH = PATH property from pom", links.next().getName() );
+ assertEquals("PATH = PATH property from pom", links.next().getName());
}
- private void writeModel( DecorationModel model, String to )
- throws Exception
- {
- Writer writer = WriterFactory.newXmlWriter( getTestFile( "target/test-classes/" + to ) );
- try
- {
- new DecorationXpp3Writer().write( writer, model );
- }
- finally
- {
- IOUtil.close( writer );
+ private void writeModel(DecorationModel model, String to) throws Exception {
+ Writer writer = WriterFactory.newXmlWriter(getTestFile("target/test-classes/" + to));
+ try {
+ new DecorationXpp3Writer().write(writer, model);
+ } finally {
+ IOUtil.close(writer);
}
}
}
diff --git a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/MavenProjectStub.java b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/MavenProjectStub.java
index 84f34d2..97697ac 100644
--- a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/MavenProjectStub.java
+++ b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/MavenProjectStub.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools.stubs;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.tools.stubs;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.tools.stubs;
import java.io.File;
import java.io.IOException;
@@ -70,9 +69,7 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
* @author jesse
* @version $Id$
*/
-public class MavenProjectStub
- extends MavenProject
-{
+public class MavenProjectStub extends MavenProject {
private String groupId;
private String artifactId;
@@ -166,44 +163,35 @@ public class MavenProjectStub
/**
* Default constructor
*/
- public MavenProjectStub()
- {
- this( new Model() );
+ public MavenProjectStub() {
+ this(new Model());
}
/**
* @param model the given model
*/
- public MavenProjectStub( Model model )
- {
- super( (Model) null );
+ public MavenProjectStub(Model model) {
+ super((Model) null);
this.model = model;
}
/**
* Loads the model for this stub from the specified POM. For convenience, any checked exception caused by I/O or
* parser errors will be wrapped into an unchecked exception.
- *
+ *
* @param pomFile The path to the POM file to load, must not be <code>null</code>. If this path is relative, it
* is resolved against the return value of {@link #getBasedir()}.
*/
- protected void readModel( File pomFile )
- {
- if ( !pomFile.isAbsolute() )
- {
- pomFile = new File( getBasedir(), pomFile.getPath() );
- }
- try
- {
- setModel( new MavenXpp3Reader().read( ReaderFactory.newXmlReader( pomFile ) ) );
+ protected void readModel(File pomFile) {
+ if (!pomFile.isAbsolute()) {
+ pomFile = new File(getBasedir(), pomFile.getPath());
}
- catch ( IOException e )
- {
- throw new RuntimeException( "Failed to read POM file: " + pomFile, e );
- }
- catch ( XmlPullParserException e )
- {
- throw new RuntimeException( "Failed to parse POM file: " + pomFile, e );
+ try {
+ setModel(new MavenXpp3Reader().read(ReaderFactory.newXmlReader(pomFile)));
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read POM file: " + pomFile, e);
+ } catch (XmlPullParserException e) {
+ throw new RuntimeException("Failed to parse POM file: " + pomFile, e);
}
}
@@ -212,9 +200,8 @@ public class MavenProjectStub
*
* @param project the given project
*/
- public MavenProjectStub( MavenProject project )
- {
- super( (Model) null );
+ public MavenProjectStub(MavenProject project) {
+ super((Model) null);
}
/**
@@ -222,39 +209,32 @@ public class MavenProjectStub
* @return an empty String
* @throws IOException if any
*/
- public String getModulePathAdjustment( MavenProject mavenProject )
- throws IOException
- {
+ public String getModulePathAdjustment(MavenProject mavenProject) throws IOException {
return "";
}
/** {@inheritDoc} */
- public Artifact getArtifact()
- {
+ public Artifact getArtifact() {
return artifact;
}
/** {@inheritDoc} */
- public void setArtifact( Artifact artifact )
- {
+ public void setArtifact(Artifact artifact) {
this.artifact = artifact;
}
/** {@inheritDoc} */
- public Model getModel()
- {
+ public Model getModel() {
return model;
}
/** {@inheritDoc} */
- public MavenProject getParent()
- {
+ public MavenProject getParent() {
return parent;
}
/** {@inheritDoc} */
- public void setParent( MavenProject mavenProject )
- {
+ public void setParent(MavenProject mavenProject) {
this.parent = mavenProject;
}
@@ -263,8 +243,7 @@ public class MavenProjectStub
*
* @see MavenProject#setRemoteArtifactRepositories(List)
*/
- public void setRemoteArtifactRepositories( List<ArtifactRepository> list )
- {
+ public void setRemoteArtifactRepositories(List<ArtifactRepository> list) {
// nop
}
@@ -273,16 +252,13 @@ public class MavenProjectStub
*
* @see MavenProject#getRemoteArtifactRepositories()
*/
- public List<ArtifactRepository> getRemoteArtifactRepositories()
- {
+ public List<ArtifactRepository> getRemoteArtifactRepositories() {
return Collections.<ArtifactRepository>emptyList();
}
/** {@inheritDoc} */
- public boolean hasParent()
- {
- if ( parent != null )
- {
+ public boolean hasParent() {
+ if (parent != null) {
return true;
}
@@ -290,21 +266,18 @@ public class MavenProjectStub
}
/** {@inheritDoc} */
- public File getFile()
- {
+ public File getFile() {
return file;
}
/** {@inheritDoc} */
- public void setFile( File file )
- {
+ public void setFile(File file) {
this.file = file;
}
/** {@inheritDoc} */
- public File getBasedir()
- {
- return new File( PlexusExtension.getBasedir() );
+ public File getBasedir() {
+ return new File(PlexusExtension.getBasedir());
}
/**
@@ -312,8 +285,7 @@ public class MavenProjectStub
*
* @see MavenProject#setDependencies(List)
*/
- public void setDependencies( List<Dependency> list )
- {
+ public void setDependencies(List<Dependency> list) {
// nop
}
@@ -322,8 +294,7 @@ public class MavenProjectStub
*
* @see MavenProject#getDependencies()
*/
- public List<Dependency> getDependencies()
- {
+ public List<Dependency> getDependencies() {
return Collections.<Dependency>emptyList();
}
@@ -332,329 +303,273 @@ public class MavenProjectStub
*
* @see MavenProject#getDependencyManagement()
*/
- public DependencyManagement getDependencyManagement()
- {
+ public DependencyManagement getDependencyManagement() {
return null;
}
/** {@inheritDoc} */
- public void addCompileSourceRoot( String string )
- {
- if ( compileSourceRoots == null )
- {
- compileSourceRoots = new ArrayList<String>( Collections.singletonList( string ) );
- }
- else
- {
- compileSourceRoots.add( string );
+ public void addCompileSourceRoot(String string) {
+ if (compileSourceRoots == null) {
+ compileSourceRoots = new ArrayList<String>(Collections.singletonList(string));
+ } else {
+ compileSourceRoots.add(string);
}
}
/** {@inheritDoc} */
- public void addScriptSourceRoot( String string )
- {
- if ( scriptSourceRoots == null )
- {
- scriptSourceRoots = new ArrayList<String>( Collections.singletonList( string ) );
- }
- else
- {
- scriptSourceRoots.add( string );
+ public void addScriptSourceRoot(String string) {
+ if (scriptSourceRoots == null) {
+ scriptSourceRoots = new ArrayList<String>(Collections.singletonList(string));
+ } else {
+ scriptSourceRoots.add(string);
}
}
/** {@inheritDoc} */
- public void addTestCompileSourceRoot( String string )
- {
- if ( testCompileSourceRoots == null )
- {
- testCompileSourceRoots = new ArrayList<String>( Collections.singletonList( string ) );
- }
- else
- {
- testCompileSourceRoots.add( string );
+ public void addTestCompileSourceRoot(String string) {
+ if (testCompileSourceRoots == null) {
+ testCompileSourceRoots = new ArrayList<String>(Collections.singletonList(string));
+ } else {
+ testCompileSourceRoots.add(string);
}
}
/** {@inheritDoc} */
- public List<String> getCompileSourceRoots()
- {
+ public List<String> getCompileSourceRoots() {
return compileSourceRoots;
}
/** {@inheritDoc} */
- public List<String> getScriptSourceRoots()
- {
+ public List<String> getScriptSourceRoots() {
return scriptSourceRoots;
}
/** {@inheritDoc} */
- public List<String> getTestCompileSourceRoots()
- {
+ public List<String> getTestCompileSourceRoots() {
return testCompileSourceRoots;
}
/** {@inheritDoc} */
- public List<String> getCompileClasspathElements()
- throws DependencyResolutionRequiredException
- {
+ public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException {
return compileSourceRoots;
}
/**
* @param compileArtifacts
*/
- public void setCompileArtifacts( List<Artifact> compileArtifacts )
- {
+ public void setCompileArtifacts(List<Artifact> compileArtifacts) {
this.compileArtifacts = compileArtifacts;
}
/** {@inheritDoc} */
- public List<Artifact> getCompileArtifacts()
- {
+ public List<Artifact> getCompileArtifacts() {
return compileArtifacts;
}
/** {@inheritDoc} */
- public List<Dependency> getCompileDependencies()
- {
+ public List<Dependency> getCompileDependencies() {
return compileDependencies;
}
/** {@inheritDoc} */
- public List<String> getTestClasspathElements()
- throws DependencyResolutionRequiredException
- {
+ public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException {
return testClasspathElements;
}
/** {@inheritDoc} */
- public List<Artifact> getTestArtifacts()
- {
+ public List<Artifact> getTestArtifacts() {
return testArtifacts;
}
/** {@inheritDoc} */
- public List<Dependency> getTestDependencies()
- {
+ public List<Dependency> getTestDependencies() {
return testDependencies;
}
/** {@inheritDoc} */
- public List<String> getRuntimeClasspathElements()
- throws DependencyResolutionRequiredException
- {
+ public List<String> getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
return runtimeClasspathElements;
}
/** {@inheritDoc} */
- public List<Artifact> getRuntimeArtifacts()
- {
+ public List<Artifact> getRuntimeArtifacts() {
return runtimeArtifacts;
}
/** {@inheritDoc} */
- public List<Dependency> getRuntimeDependencies()
- {
+ public List<Dependency> getRuntimeDependencies() {
return runtimeDependencies;
}
/** {@inheritDoc} */
- public List<String> getSystemClasspathElements()
- throws DependencyResolutionRequiredException
- {
+ public List<String> getSystemClasspathElements() throws DependencyResolutionRequiredException {
return systemClasspathElements;
}
/** {@inheritDoc} */
- public List<Artifact> getSystemArtifacts()
- {
+ public List<Artifact> getSystemArtifacts() {
return systemArtifacts;
}
/**
* @param runtimeClasspathElements
*/
- public void setRuntimeClasspathElements( List<String> runtimeClasspathElements )
- {
+ public void setRuntimeClasspathElements(List<String> runtimeClasspathElements) {
this.runtimeClasspathElements = runtimeClasspathElements;
}
/**
* @param attachedArtifacts
*/
- public void setAttachedArtifacts( List<Artifact> attachedArtifacts )
- {
+ public void setAttachedArtifacts(List<Artifact> attachedArtifacts) {
this.attachedArtifacts = attachedArtifacts;
}
/**
* @param compileSourceRoots
*/
- public void setCompileSourceRoots( List<String> compileSourceRoots )
- {
+ public void setCompileSourceRoots(List<String> compileSourceRoots) {
this.compileSourceRoots = compileSourceRoots;
}
/**
* @param testCompileSourceRoots
*/
- public void setTestCompileSourceRoots( List<String> testCompileSourceRoots )
- {
+ public void setTestCompileSourceRoots(List<String> testCompileSourceRoots) {
this.testCompileSourceRoots = testCompileSourceRoots;
}
/**
* @param scriptSourceRoots
*/
- public void setScriptSourceRoots( List<String> scriptSourceRoots )
- {
+ public void setScriptSourceRoots(List<String> scriptSourceRoots) {
this.scriptSourceRoots = scriptSourceRoots;
}
/**
* @param artifactMap
*/
- public void setArtifactMap( Map<String, Artifact> artifactMap )
- {
+ public void setArtifactMap(Map<String, Artifact> artifactMap) {
this.artifactMap = artifactMap;
}
/**
* @param pluginArtifactMap
*/
- public void setPluginArtifactMap( Map<String, Artifact> pluginArtifactMap )
- {
+ public void setPluginArtifactMap(Map<String, Artifact> pluginArtifactMap) {
this.pluginArtifactMap = pluginArtifactMap;
}
/**
* @param reportArtifactMap
*/
- public void setReportArtifactMap( Map<String, Artifact> reportArtifactMap )
- {
+ public void setReportArtifactMap(Map<String, Artifact> reportArtifactMap) {
this.reportArtifactMap = reportArtifactMap;
}
/**
* @param extensionArtifactMap
*/
- public void setExtensionArtifactMap( Map<String, Artifact> extensionArtifactMap )
- {
+ public void setExtensionArtifactMap(Map<String, Artifact> extensionArtifactMap) {
this.extensionArtifactMap = extensionArtifactMap;
}
/**
* @param projectReferences
*/
- public void setProjectReferences( Map<String, MavenProject> projectReferences )
- {
+ public void setProjectReferences(Map<String, MavenProject> projectReferences) {
this.projectReferences = projectReferences;
}
/**
* @param buildOverlay
*/
- public void setBuildOverlay( Build buildOverlay )
- {
+ public void setBuildOverlay(Build buildOverlay) {
this.buildOverlay = buildOverlay;
}
/**
* @param compileDependencies
*/
- public void setCompileDependencies( List<Dependency> compileDependencies )
- {
+ public void setCompileDependencies(List<Dependency> compileDependencies) {
this.compileDependencies = compileDependencies;
}
/**
* @param systemDependencies
*/
- public void setSystemDependencies( List<Dependency> systemDependencies )
- {
+ public void setSystemDependencies(List<Dependency> systemDependencies) {
this.systemDependencies = systemDependencies;
}
/**
* @param testClasspathElements
*/
- public void setTestClasspathElements( List<String> testClasspathElements )
- {
+ public void setTestClasspathElements(List<String> testClasspathElements) {
this.testClasspathElements = testClasspathElements;
}
/**
* @param testDependencies
*/
- public void setTestDependencies( List<Dependency> testDependencies )
- {
+ public void setTestDependencies(List<Dependency> testDependencies) {
this.testDependencies = testDependencies;
}
/**
* @param systemClasspathElements
*/
- public void setSystemClasspathElements( List<String> systemClasspathElements )
- {
+ public void setSystemClasspathElements(List<String> systemClasspathElements) {
this.systemClasspathElements = systemClasspathElements;
}
/**
* @param systemArtifacts
*/
- public void setSystemArtifacts( List<Artifact> systemArtifacts )
- {
+ public void setSystemArtifacts(List<Artifact> systemArtifacts) {
this.systemArtifacts = systemArtifacts;
}
/**
* @param testArtifacts
*/
- public void setTestArtifacts( List<Artifact> testArtifacts )
- {
+ public void setTestArtifacts(List<Artifact> testArtifacts) {
this.testArtifacts = testArtifacts;
}
/**
* @param runtimeArtifacts
*/
- public void setRuntimeArtifacts( List<Artifact> runtimeArtifacts )
- {
+ public void setRuntimeArtifacts(List<Artifact> runtimeArtifacts) {
this.runtimeArtifacts = runtimeArtifacts;
}
/**
* @param runtimeDependencies
*/
- public void setRuntimeDependencies( List<Dependency> runtimeDependencies )
- {
+ public void setRuntimeDependencies(List<Dependency> runtimeDependencies) {
this.runtimeDependencies = runtimeDependencies;
}
/**
* @param model
*/
- public void setModel( Model model )
- {
+ public void setModel(Model model) {
this.model = model;
}
/** {@inheritDoc} */
- public List<Dependency> getSystemDependencies()
- {
+ public List<Dependency> getSystemDependencies() {
return systemDependencies;
}
/** {@inheritDoc} */
- public void setModelVersion( String string )
- {
+ public void setModelVersion(String string) {
this.modelVersion = string;
}
/** {@inheritDoc} */
- public String getModelVersion()
- {
+ public String getModelVersion() {
return modelVersion;
}
@@ -663,92 +578,77 @@ public class MavenProjectStub
*
* @see MavenProject#getId()
*/
- public String getId()
- {
+ public String getId() {
return "";
}
/** {@inheritDoc} */
- public void setGroupId( String string )
- {
+ public void setGroupId(String string) {
this.groupId = string;
}
/** {@inheritDoc} */
- public String getGroupId()
- {
+ public String getGroupId() {
return groupId;
}
/** {@inheritDoc} */
- public void setArtifactId( String string )
- {
+ public void setArtifactId(String string) {
this.artifactId = string;
}
/** {@inheritDoc} */
- public String getArtifactId()
- {
+ public String getArtifactId() {
return artifactId;
}
/** {@inheritDoc} */
- public void setName( String string )
- {
+ public void setName(String string) {
this.name = string;
}
/** {@inheritDoc} */
- public String getName()
- {
+ public String getName() {
return name;
}
/** {@inheritDoc} */
- public void setVersion( String string )
- {
+ public void setVersion(String string) {
this.version = string;
}
/** {@inheritDoc} */
- public String getVersion()
- {
+ public String getVersion() {
return version;
}
/** {@inheritDoc} */
- public String getPackaging()
- {
+ public String getPackaging() {
return packaging;
}
/** {@inheritDoc} */
- public void setPackaging( String string )
- {
+ public void setPackaging(String string) {
this.packaging = string;
}
/** {@inheritDoc} */
- public void setInceptionYear( String string )
- {
+ public void setInceptionYear(String string) {
this.inceptionYear = string;
}
/** {@inheritDoc} */
- public String getInceptionYear()
- {
+ public String getInceptionYear() {
return inceptionYear;
}
/** {@inheritDoc} */
- public void setUrl( String string )
- {
+ public void setUrl(String string) {
this.url = string;
}
/** {@inheritDoc} */
- public String getUrl()
- {
+ public String getUrl() {
return url;
}
@@ -757,8 +657,7 @@ public class MavenProjectStub
*
* @see MavenProject#getPrerequisites()
*/
- public Prerequisites getPrerequisites()
- {
+ public Prerequisites getPrerequisites() {
return null;
}
@@ -767,8 +666,7 @@ public class MavenProjectStub
*
* @see MavenProject#setIssueManagement(IssueManagement)
*/
- public void setIssueManagement( IssueManagement issueManagement )
- {
+ public void setIssueManagement(IssueManagement issueManagement) {
// nop
}
@@ -777,8 +675,7 @@ public class MavenProjectStub
*
* @see MavenProject#getCiManagement()
*/
- public CiManagement getCiManagement()
- {
+ public CiManagement getCiManagement() {
return null;
}
@@ -787,8 +684,7 @@ public class MavenProjectStub
*
* @see MavenProject#setCiManagement(CiManagement)
*/
- public void setCiManagement( CiManagement ciManagement )
- {
+ public void setCiManagement(CiManagement ciManagement) {
// nop
}
@@ -797,8 +693,7 @@ public class MavenProjectStub
*
* @see MavenProject#getIssueManagement()
*/
- public IssueManagement getIssueManagement()
- {
+ public IssueManagement getIssueManagement() {
return null;
}
@@ -807,8 +702,7 @@ public class MavenProjectStub
*
* @see MavenProject#setDistributionManagement(DistributionManagement)
*/
- public void setDistributionManagement( DistributionManagement distributionManagement )
- {
+ public void setDistributionManagement(DistributionManagement distributionManagement) {
// nop
}
@@ -817,20 +711,17 @@ public class MavenProjectStub
*
* @see MavenProject#getDistributionManagement()
*/
- public DistributionManagement getDistributionManagement()
- {
+ public DistributionManagement getDistributionManagement() {
return null;
}
/** {@inheritDoc} */
- public void setDescription( String string )
- {
+ public void setDescription(String string) {
this.description = string;
}
/** {@inheritDoc} */
- public String getDescription()
- {
+ public String getDescription() {
return description;
}
@@ -839,8 +730,7 @@ public class MavenProjectStub
*
* @see MavenProject#setOrganization(Organization)
*/
- public void setOrganization( Organization organization )
- {
+ public void setOrganization(Organization organization) {
// nop
}
@@ -849,8 +739,7 @@ public class MavenProjectStub
*
* @see MavenProject#getOrganization()
*/
- public Organization getOrganization()
- {
+ public Organization getOrganization() {
return null;
}
@@ -859,8 +748,7 @@ public class MavenProjectStub
*
* @see MavenProject#setScm(Scm)
*/
- public void setScm( Scm scm )
- {
+ public void setScm(Scm scm) {
// nop
}
@@ -869,8 +757,7 @@ public class MavenProjectStub
*
* @see MavenProject#getScm()
*/
- public Scm getScm()
- {
+ public Scm getScm() {
return null;
}
@@ -879,8 +766,7 @@ public class MavenProjectStub
*
* @see MavenProject#setMailingLists(List)
*/
- public void setMailingLists( List<MailingList> list )
- {
+ public void setMailingLists(List<MailingList> list) {
// nop
}
@@ -889,8 +775,7 @@ public class MavenProjectStub
*
* @see MavenProject#getMailingLists()
*/
- public List<MailingList> getMailingLists()
- {
+ public List<MailingList> getMailingLists() {
return Collections.<MailingList>emptyList();
}
@@ -899,8 +784,7 @@ public class MavenProjectStub
*
* @see MavenProject#addMailingList(MailingList)
*/
- public void addMailingList( MailingList mailingList )
- {
+ public void addMailingList(MailingList mailingList) {
// nop
}
@@ -909,8 +793,7 @@ public class MavenProjectStub
*
* @see MavenProject#setDevelopers(List)
*/
- public void setDevelopers( List<Developer> list )
- {
+ public void setDevelopers(List<Developer> list) {
// nop
}
@@ -919,8 +802,7 @@ public class MavenProjectStub
*
* @see MavenProject#getDevelopers()
*/
- public List<Developer> getDevelopers()
- {
+ public List<Developer> getDevelopers() {
return Collections.<Developer>emptyList();
}
@@ -929,8 +811,7 @@ public class MavenProjectStub
*
* @see MavenProject#addDeveloper(Developer)
*/
- public void addDeveloper( Developer developer )
- {
+ public void addDeveloper(Developer developer) {
// nop
}
@@ -939,8 +820,7 @@ public class MavenProjectStub
*
* @see MavenProject#setContributors(List)
*/
- public void setContributors( List<Contributor> list )
- {
+ public void setContributors(List<Contributor> list) {
// nop
}
@@ -949,8 +829,7 @@ public class MavenProjectStub
*
* @see MavenProject#getContributors()
*/
- public List<Contributor> getContributors()
- {
+ public List<Contributor> getContributors() {
return Collections.<Contributor>emptyList();
}
@@ -959,20 +838,17 @@ public class MavenProjectStub
*
* @see MavenProject#addContributor(Contributor)
*/
- public void addContributor( Contributor contributor )
- {
+ public void addContributor(Contributor contributor) {
// nop
}
/** {@inheritDoc} */
- public void setBuild( Build build )
- {
+ public void setBuild(Build build) {
this.build = build;
}
/** {@inheritDoc} */
- public Build getBuild()
- {
+ public Build getBuild() {
return build;
}
@@ -981,8 +857,7 @@ public class MavenProjectStub
*
* @see MavenProject#getResources()
*/
- public List<Resource> getResources()
- {
+ public List<Resource> getResources() {
return Collections.<Resource>emptyList();
}
@@ -991,8 +866,7 @@ public class MavenProjectStub
*
* @see MavenProject#getTestResources()
*/
- public List<Resource> getTestResources()
- {
+ public List<Resource> getTestResources() {
return Collections.<Resource>emptyList();
}
@@ -1001,8 +875,7 @@ public class MavenProjectStub
*
* @see MavenProject#addResource(Resource)
*/
- public void addResource( Resource resource )
- {
+ public void addResource(Resource resource) {
// nop
}
@@ -1011,8 +884,7 @@ public class MavenProjectStub
*
* @see MavenProject#addTestResource(Resource)
*/
- public void addTestResource( Resource resource )
- {
+ public void addTestResource(Resource resource) {
// nop
}
@@ -1021,8 +893,7 @@ public class MavenProjectStub
*
* @see MavenProject#setReporting(Reporting)
*/
- public void setReporting( Reporting reporting )
- {
+ public void setReporting(Reporting reporting) {
// nop
}
@@ -1031,20 +902,17 @@ public class MavenProjectStub
*
* @see MavenProject#getReporting()
*/
- public Reporting getReporting()
- {
+ public Reporting getReporting() {
return null;
}
/** {@inheritDoc} */
- public void setLicenses( List<License> licenses )
- {
+ public void setLicenses(List<License> licenses) {
this.licenses = licenses;
}
/** {@inheritDoc} */
- public List<License> getLicenses()
- {
+ public List<License> getLicenses() {
return licenses;
}
@@ -1053,8 +921,7 @@ public class MavenProjectStub
*
* @see MavenProject#addLicense(License)
*/
- public void addLicense( License license )
- {
+ public void addLicense(License license) {
// nop
}
@@ -1063,8 +930,7 @@ public class MavenProjectStub
*
* @see MavenProject#setArtifacts(Set)
*/
- public void setArtifacts( Set<Artifact> set )
- {
+ public void setArtifacts(Set<Artifact> set) {
// nop
}
@@ -1073,8 +939,7 @@ public class MavenProjectStub
*
* @see MavenProject#getArtifacts()
*/
- public Set<Artifact> getArtifacts()
- {
+ public Set<Artifact> getArtifacts() {
return Collections.<Artifact>emptySet();
}
@@ -1083,8 +948,7 @@ public class MavenProjectStub
*
* @see MavenProject#getArtifactMap()
*/
- public Map<String, Artifact> getArtifactMap()
- {
+ public Map<String, Artifact> getArtifactMap() {
return Collections.<String, Artifact>emptyMap();
}
@@ -1093,8 +957,7 @@ public class MavenProjectStub
*
* @see MavenProject#setPluginArtifacts(Set)
*/
- public void setPluginArtifacts( Set<Artifact> set )
- {
+ public void setPluginArtifacts(Set<Artifact> set) {
// nop
}
@@ -1103,8 +966,7 @@ public class MavenProjectStub
*
* @see MavenProject#getPluginArtifacts()
*/
- public Set<Artifact> getPluginArtifacts()
- {
+ public Set<Artifact> getPluginArtifacts() {
return Collections.<Artifact>emptySet();
}
@@ -1113,8 +975,7 @@ public class MavenProjectStub
*
* @see MavenProject#getPluginArtifactMap()
*/
- public Map<String, Artifact> getPluginArtifactMap()
- {
+ public Map<String, Artifact> getPluginArtifactMap() {
return Collections.<String, Artifact>emptyMap();
}
@@ -1123,8 +984,7 @@ public class MavenProjectStub
*
* @see MavenProject#setReportArtifacts(Set)
*/
- public void setReportArtifacts( Set<Artifact> set )
- {
+ public void setReportArtifacts(Set<Artifact> set) {
// nop
}
@@ -1133,8 +993,7 @@ public class MavenProjectStub
*
* @see MavenProject#getReportArtifacts()
*/
- public Set<Artifact> getReportArtifacts()
- {
+ public Set<Artifact> getReportArtifacts() {
return Collections.<Artifact>emptySet();
}
@@ -1143,8 +1002,7 @@ public class MavenProjectStub
*
* @see MavenProject#getReportArtifactMap()
*/
- public Map<String, Artifact> getReportArtifactMap()
- {
+ public Map<String, Artifact> getReportArtifactMap() {
return Collections.<String, Artifact>emptyMap();
}
@@ -1153,8 +1011,7 @@ public class MavenProjectStub
*
* @see MavenProject#setExtensionArtifacts(Set)
*/
- public void setExtensionArtifacts( Set<Artifact> set )
- {
+ public void setExtensionArtifacts(Set<Artifact> set) {
// nop
}
@@ -1163,8 +1020,7 @@ public class MavenProjectStub
*
* @see MavenProject#getExtensionArtifacts()
*/
- public Set<Artifact> getExtensionArtifacts()
- {
+ public Set<Artifact> getExtensionArtifacts() {
return Collections.<Artifact>emptySet();
}
@@ -1173,8 +1029,7 @@ public class MavenProjectStub
*
* @see MavenProject#getExtensionArtifactMap()
*/
- public Map<String, Artifact> getExtensionArtifactMap()
- {
+ public Map<String, Artifact> getExtensionArtifactMap() {
return Collections.<String, Artifact>emptyMap();
}
@@ -1183,8 +1038,7 @@ public class MavenProjectStub
*
* @see MavenProject#setParentArtifact(Artifact)
*/
- public void setParentArtifact( Artifact artifact )
- {
+ public void setParentArtifact(Artifact artifact) {
// nop
}
@@ -1193,8 +1047,7 @@ public class MavenProjectStub
*
* @see MavenProject#getParentArtifact()
*/
- public Artifact getParentArtifact()
- {
+ public Artifact getParentArtifact() {
return null;
}
@@ -1203,8 +1056,7 @@ public class MavenProjectStub
*
* @see MavenProject#getRepositories()
*/
- public List<Repository> getRepositories()
- {
+ public List<Repository> getRepositories() {
return Collections.<Repository>emptyList();
}
@@ -1213,8 +1065,7 @@ public class MavenProjectStub
*
* @see MavenProject#getReportPlugins()
*/
- public List<ReportPlugin> getReportPlugins()
- {
+ public List<ReportPlugin> getReportPlugins() {
return Collections.<ReportPlugin>emptyList();
}
@@ -1223,8 +1074,7 @@ public class MavenProjectStub
*
* @see MavenProject#getBuildPlugins()
*/
- public List<Plugin> getBuildPlugins()
- {
+ public List<Plugin> getBuildPlugins() {
return Collections.<Plugin>emptyList();
}
@@ -1233,8 +1083,7 @@ public class MavenProjectStub
*
* @see MavenProject#getModules()
*/
- public List<String> getModules()
- {
+ public List<String> getModules() {
return Collections.<String>emptyList();
}
@@ -1243,8 +1092,7 @@ public class MavenProjectStub
*
* @see MavenProject#getPluginManagement()
*/
- public PluginManagement getPluginManagement()
- {
+ public PluginManagement getPluginManagement() {
return null;
}
@@ -1253,8 +1101,7 @@ public class MavenProjectStub
*
* @see MavenProject#addPlugin(Plugin)
*/
- public void addPlugin( Plugin plugin )
- {
+ public void addPlugin(Plugin plugin) {
// nop
}
@@ -1263,32 +1110,27 @@ public class MavenProjectStub
*
* @param plugin
*/
- public void injectPluginManagementInfo( Plugin plugin )
- {
+ public void injectPluginManagementInfo(Plugin plugin) {
// nop
}
/** {@inheritDoc} */
- public List<MavenProject> getCollectedProjects()
- {
+ public List<MavenProject> getCollectedProjects() {
return collectedProjects;
}
/** {@inheritDoc} */
- public void setCollectedProjects( List<MavenProject> list )
- {
+ public void setCollectedProjects(List<MavenProject> list) {
this.collectedProjects = list;
}
/** {@inheritDoc} */
- public void setPluginArtifactRepositories( List<ArtifactRepository> list )
- {
+ public void setPluginArtifactRepositories(List<ArtifactRepository> list) {
this.pluginArtifactRepositories = list;
}
/** {@inheritDoc} */
- public List<ArtifactRepository> getPluginArtifactRepositories()
- {
+ public List<ArtifactRepository> getPluginArtifactRepositories() {
return pluginArtifactRepositories;
}
@@ -1297,8 +1139,7 @@ public class MavenProjectStub
*
* @see MavenProject#getDistributionManagementArtifactRepository()
*/
- public ArtifactRepository getDistributionManagementArtifactRepository()
- {
+ public ArtifactRepository getDistributionManagementArtifactRepository() {
return null;
}
@@ -1307,39 +1148,31 @@ public class MavenProjectStub
*
* @see MavenProject#getPluginRepositories()
*/
- public List<Repository> getPluginRepositories()
- {
+ public List<Repository> getPluginRepositories() {
return Collections.<Repository>emptyList();
}
/** {@inheritDoc} */
- public void setActiveProfiles( List<Profile> list )
- {
+ public void setActiveProfiles(List<Profile> list) {
activeProfiles = list;
}
/** {@inheritDoc} */
- public List<Profile> getActiveProfiles()
- {
+ public List<Profile> getActiveProfiles() {
return activeProfiles;
}
/** {@inheritDoc} */
- public void addAttachedArtifact( Artifact artifact )
- {
- if ( attachedArtifacts == null )
- {
- this.attachedArtifacts = new ArrayList<Artifact>( Collections.singletonList( artifact ) );
- }
- else
- {
- attachedArtifacts.add( artifact );
+ public void addAttachedArtifact(Artifact artifact) {
+ if (attachedArtifacts == null) {
+ this.attachedArtifacts = new ArrayList<Artifact>(Collections.singletonList(artifact));
+ } else {
+ attachedArtifacts.add(artifact);
}
}
/** {@inheritDoc} */
- public List<Artifact> getAttachedArtifacts()
- {
+ public List<Artifact> getAttachedArtifacts() {
return attachedArtifacts;
}
@@ -1348,8 +1181,7 @@ public class MavenProjectStub
*
* @see MavenProject#getGoalConfiguration(String, String, String, String)
*/
- public Xpp3Dom getGoalConfiguration( String string, String string1, String string2, String string3 )
- {
+ public Xpp3Dom getGoalConfiguration(String string, String string1, String string2, String string3) {
return null;
}
@@ -1358,8 +1190,7 @@ public class MavenProjectStub
*
* @see MavenProject#getReportConfiguration(String, String, String)
*/
- public Xpp3Dom getReportConfiguration( String string, String string1, String string2 )
- {
+ public Xpp3Dom getReportConfiguration(String string, String string1, String string2) {
return null;
}
@@ -1368,8 +1199,7 @@ public class MavenProjectStub
*
* @see MavenProject#getExecutionProject()
*/
- public MavenProject getExecutionProject()
- {
+ public MavenProject getExecutionProject() {
return null;
}
@@ -1378,8 +1208,7 @@ public class MavenProjectStub
*
* @see MavenProject#setExecutionProject(MavenProject)
*/
- public void setExecutionProject( MavenProject mavenProject )
- {
+ public void setExecutionProject(MavenProject mavenProject) {
// nop
}
@@ -1388,9 +1217,7 @@ public class MavenProjectStub
*
* @see MavenProject#writeModel(Writer)
*/
- public void writeModel( Writer writer )
- throws IOException
- {
+ public void writeModel(Writer writer) throws IOException {
// nop
}
@@ -1399,45 +1226,37 @@ public class MavenProjectStub
*
* @see MavenProject#writeOriginalModel(Writer)
*/
- public void writeOriginalModel( Writer writer )
- throws IOException
- {
+ public void writeOriginalModel(Writer writer) throws IOException {
// nop
}
/** {@inheritDoc} */
- public Set<Artifact> getDependencyArtifacts()
- {
+ public Set<Artifact> getDependencyArtifacts() {
return dependencyArtifacts;
}
/** {@inheritDoc} */
- public void setDependencyArtifacts( Set<Artifact> set )
- {
+ public void setDependencyArtifacts(Set<Artifact> set) {
this.dependencyArtifacts = set;
}
/** {@inheritDoc} */
- public void setReleaseArtifactRepository( ArtifactRepository artifactRepository )
- {
+ public void setReleaseArtifactRepository(ArtifactRepository artifactRepository) {
this.releaseArtifactRepository = artifactRepository;
}
/** {@inheritDoc} */
- public void setSnapshotArtifactRepository( ArtifactRepository artifactRepository )
- {
+ public void setSnapshotArtifactRepository(ArtifactRepository artifactRepository) {
this.snapshotArtifactRepository = artifactRepository;
}
/** {@inheritDoc} */
- public void setOriginalModel( Model model )
- {
+ public void setOriginalModel(Model model) {
this.originalModel = model;
}
/** {@inheritDoc} */
- public Model getOriginalModel()
- {
+ public Model getOriginalModel() {
return originalModel;
}
@@ -1446,8 +1265,7 @@ public class MavenProjectStub
*
* @see MavenProject#getBuildExtensions()
*/
- public List<Extension> getBuildExtensions()
- {
+ public List<Extension> getBuildExtensions() {
return Collections.<Extension>emptyList();
}
@@ -1456,8 +1274,8 @@ public class MavenProjectStub
*
* @see MavenProject#createArtifacts(ArtifactFactory, String, ArtifactFilter)
*/
- public Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter )
- {
+ public Set<Artifact> createArtifacts(
+ ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter) {
return Collections.<Artifact>emptySet();
}
@@ -1466,8 +1284,7 @@ public class MavenProjectStub
*
* @see MavenProject#addProjectReference(MavenProject)
*/
- public void addProjectReference( MavenProject mavenProject )
- {
+ public void addProjectReference(MavenProject mavenProject) {
// nop
}
@@ -1476,8 +1293,7 @@ public class MavenProjectStub
*
* @see MavenProject#attachArtifact(String, String, File)
*/
- public void attachArtifact( String string, String string1, File file )
- {
+ public void attachArtifact(String string, String string1, File file) {
// nop
}
@@ -1486,8 +1302,7 @@ public class MavenProjectStub
*
* @see MavenProject#getProperties()
*/
- public Properties getProperties()
- {
+ public Properties getProperties() {
return new Properties();
}
@@ -1496,8 +1311,7 @@ public class MavenProjectStub
*
* @see MavenProject#getFilters()
*/
- public List<String> getFilters()
- {
+ public List<String> getFilters() {
return Collections.<String>emptyList();
}
@@ -1506,26 +1320,22 @@ public class MavenProjectStub
*
* @see MavenProject#getProjectReferences()
*/
- public Map<String, MavenProject> getProjectReferences()
- {
+ public Map<String, MavenProject> getProjectReferences() {
return Collections.<String, MavenProject>emptyMap();
}
/** {@inheritDoc} */
- public boolean isExecutionRoot()
- {
+ public boolean isExecutionRoot() {
return executionRoot;
}
/** {@inheritDoc} */
- public void setExecutionRoot( boolean b )
- {
+ public void setExecutionRoot(boolean b) {
this.executionRoot = b;
}
/** {@inheritDoc} */
- public String getDefaultGoal()
- {
+ public String getDefaultGoal() {
return defaultGoal;
}
@@ -1534,8 +1344,7 @@ public class MavenProjectStub
*
* @see MavenProject#replaceWithActiveArtifact(Artifact)
*/
- public Artifact replaceWithActiveArtifact( Artifact artifact )
- {
+ public Artifact replaceWithActiveArtifact(Artifact artifact) {
return null;
}
}
diff --git a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java
index 2482fa7..b426d4f 100644
--- a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java
+++ b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.tools.stubs;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.doxia.tools.stubs;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.tools.stubs;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.tools.stubs;
import java.io.File;
import java.io.FileInputStream;
@@ -38,9 +37,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
-public class SiteToolMavenProjectStub
- extends MavenProjectStub
-{
+public class SiteToolMavenProjectStub extends MavenProjectStub {
private Build build;
private File basedir;
@@ -49,103 +46,90 @@ public class SiteToolMavenProjectStub
private Properties properties;
- public SiteToolMavenProjectStub( String projectName )
- {
- basedir = new File( super.getBasedir() + "/src/test/resources/unit/" + projectName );
+ public SiteToolMavenProjectStub(String projectName) {
+ basedir = new File(super.getBasedir() + "/src/test/resources/unit/" + projectName);
Model model = null;
- try
- {
- model = new MavenXpp3Reader().read( new FileInputStream( new File( getBasedir(), "pom.xml" ) ) );
- setModel( model );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e );
+ try {
+ model = new MavenXpp3Reader().read(new FileInputStream(new File(getBasedir(), "pom.xml")));
+ setModel(model);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
- setGroupId( model.getGroupId() );
- setArtifactId( model.getArtifactId() );
- setVersion( model.getVersion() );
- setName( model.getName() );
- setUrl( model.getUrl() );
- setPackaging( model.getPackaging() );
- setProperties( model.getProperties() );
+ setGroupId(model.getGroupId());
+ setArtifactId(model.getArtifactId());
+ setVersion(model.getVersion());
+ setName(model.getName());
+ setUrl(model.getUrl());
+ setPackaging(model.getPackaging());
+ setProperties(model.getProperties());
build = new Build();
- build.setFinalName( model.getArtifactId() );
- build.setDirectory( super.getBasedir() + "/target/test/unit/" + projectName + "/target" );
- build.setSourceDirectory( getBasedir() + "/src/main/java" );
- build.setOutputDirectory( build.getDirectory() + "/classes" );
- build.setTestSourceDirectory( getBasedir() + "/src/test/java" );
- build.setTestOutputDirectory( build.getDirectory() + "/test-classes" );
+ build.setFinalName(model.getArtifactId());
+ build.setDirectory(super.getBasedir() + "/target/test/unit/" + projectName + "/target");
+ build.setSourceDirectory(getBasedir() + "/src/main/java");
+ build.setOutputDirectory(build.getDirectory() + "/classes");
+ build.setTestSourceDirectory(getBasedir() + "/src/test/java");
+ build.setTestOutputDirectory(build.getDirectory() + "/test-classes");
List<String> compileSourceRoots = new ArrayList<String>();
- compileSourceRoots.add( getBasedir() + "/src/main/java" );
- setCompileSourceRoots( compileSourceRoots );
+ compileSourceRoots.add(getBasedir() + "/src/main/java");
+ setCompileSourceRoots(compileSourceRoots);
List<String> testCompileSourceRoots = new ArrayList<String>();
- testCompileSourceRoots.add( getBasedir() + "/src/test/java" );
- setTestCompileSourceRoots( testCompileSourceRoots );
+ testCompileSourceRoots.add(getBasedir() + "/src/test/java");
+ setTestCompileSourceRoots(testCompileSourceRoots);
}
/** {@inheritDoc} */
- public Build getBuild()
- {
+ public Build getBuild() {
return build;
}
/** {@inheritDoc} */
- public void setBuild( Build build )
- {
+ public void setBuild(Build build) {
this.build = build;
}
/** {@inheritDoc} */
- public File getBasedir()
- {
+ public File getBasedir() {
return basedir;
}
/** {@inheritDoc} */
- public void setBasedir( File basedir )
- {
+ public void setBasedir(File basedir) {
this.basedir = basedir;
}
/** {@inheritDoc} */
- public List<ArtifactRepository> getRemoteArtifactRepositories()
- {
- ArtifactRepository repository = new DefaultArtifactRepository( "central", "https://repo1.maven.org/maven2",
- new DefaultRepositoryLayout() );
+ public List<ArtifactRepository> getRemoteArtifactRepositories() {
+ ArtifactRepository repository = new DefaultArtifactRepository(
+ "central", "https://repo1.maven.org/maven2", new DefaultRepositoryLayout());
- return Collections.singletonList( repository );
+ return Collections.singletonList(repository);
}
/** {@inheritDoc} */
- public Properties getProperties()
- {
+ public Properties getProperties() {
return properties;
}
/** {@inheritDoc} */
- public void setProperties( Properties properties )
- {
+ public void setProperties(Properties properties) {
this.properties = properties;
}
- public void setDistgributionManagementSiteUrl( String url )
- {
+ public void setDistgributionManagementSiteUrl(String url) {
Site site = new Site();
- site.setUrl( url );
+ site.setUrl(url);
distributionManagement = new DistributionManagement();
- distributionManagement.setSite( site );
+ distributionManagement.setSite(site);
}
/** {@inheritDoc} */
- public DistributionManagement getDistributionManagement()
- {
+ public DistributionManagement getDistributionManagement() {
return distributionManagement;
}
}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
index c895f80..f41d085 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import javax.inject.Inject;
import javax.inject.Named;
@@ -63,12 +62,12 @@ import org.apache.maven.doxia.Doxia;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
-import org.apache.maven.doxia.site.decoration.DecorationModel;
-import org.apache.maven.doxia.site.skin.SkinModel;
-import org.apache.maven.doxia.site.skin.io.xpp3.SkinXpp3Reader;
import org.apache.maven.doxia.parser.module.ParserModule;
import org.apache.maven.doxia.parser.module.ParserModuleManager;
import org.apache.maven.doxia.parser.module.ParserModuleNotFoundException;
+import org.apache.maven.doxia.site.decoration.DecorationModel;
+import org.apache.maven.doxia.site.skin.SkinModel;
+import org.apache.maven.doxia.site.skin.io.xpp3.SkinXpp3Reader;
import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
import org.apache.maven.doxia.util.XmlValidator;
import org.apache.velocity.Template;
@@ -120,10 +119,8 @@ import org.slf4j.LoggerFactory;
*/
@Singleton
@Named
-public class DefaultSiteRenderer
- implements Renderer
-{
- private static final Logger LOGGER = LoggerFactory.getLogger( DefaultSiteRenderer.class );
+public class DefaultSiteRenderer implements Renderer {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSiteRenderer.class);
// ----------------------------------------------------------------------
// Requirements
@@ -152,328 +149,279 @@ public class DefaultSiteRenderer
// ----------------------------------------------------------------------
/** {@inheritDoc} */
- public Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext )
- throws IOException, RendererException
- {
- return locateDocumentFiles( siteRenderingContext, false );
+ public Map<String, DocumentRenderer> locateDocumentFiles(SiteRenderingContext siteRenderingContext)
+ throws IOException, RendererException {
+ return locateDocumentFiles(siteRenderingContext, false);
}
/** {@inheritDoc} */
- public Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext,
- boolean editable )
- throws IOException, RendererException
- {
+ public Map<String, DocumentRenderer> locateDocumentFiles(
+ SiteRenderingContext siteRenderingContext, boolean editable) throws IOException, RendererException {
Map<String, DocumentRenderer> files = new LinkedHashMap<String, DocumentRenderer>();
Map<String, String> moduleExcludes = siteRenderingContext.getModuleExcludes();
// look in every site directory (in general src/site or target/generated-site)
- for ( File siteDirectory : siteRenderingContext.getSiteDirectories() )
- {
- if ( siteDirectory.exists() )
- {
+ for (File siteDirectory : siteRenderingContext.getSiteDirectories()) {
+ if (siteDirectory.exists()) {
Collection<ParserModule> modules = parserModuleManager.getParserModules();
// use every Doxia parser module
- for ( ParserModule module : modules )
- {
- File moduleBasedir = new File( siteDirectory, module.getSourceDirectory() );
+ for (ParserModule module : modules) {
+ File moduleBasedir = new File(siteDirectory, module.getSourceDirectory());
- String excludes = ( moduleExcludes == null ) ? null : moduleExcludes.get( module.getParserId() );
+ String excludes = (moduleExcludes == null) ? null : moduleExcludes.get(module.getParserId());
- addModuleFiles( siteRenderingContext.getRootDirectory(), moduleBasedir, module, excludes, files,
- editable );
+ addModuleFiles(
+ siteRenderingContext.getRootDirectory(), moduleBasedir, module, excludes, files, editable);
}
}
}
// look in specific modules directories (used for old Maven 1.x site layout: xdoc and fml docs in /xdocs)
- for ( ExtraDoxiaModuleReference module : siteRenderingContext.getModules() )
- {
- try
- {
- ParserModule parserModule = parserModuleManager.getParserModule( module.getParserId() );
+ for (ExtraDoxiaModuleReference module : siteRenderingContext.getModules()) {
+ try {
+ ParserModule parserModule = parserModuleManager.getParserModule(module.getParserId());
- String excludes = ( moduleExcludes == null ) ? null : moduleExcludes.get( module.getParserId() );
+ String excludes = (moduleExcludes == null) ? null : moduleExcludes.get(module.getParserId());
- addModuleFiles( siteRenderingContext.getRootDirectory(), module.getBasedir(), parserModule, excludes,
- files, editable );
- }
- catch ( ParserModuleNotFoundException e )
- {
- throw new RendererException( "Unable to find module", e );
+ addModuleFiles(
+ siteRenderingContext.getRootDirectory(),
+ module.getBasedir(),
+ parserModule,
+ excludes,
+ files,
+ editable);
+ } catch (ParserModuleNotFoundException e) {
+ throw new RendererException("Unable to find module", e);
}
}
return files;
}
- private List<String> filterExtensionIgnoreCase( List<String> fileNames, String extension )
- {
- List<String> filtered = new LinkedList<String>( fileNames );
- for ( Iterator<String> it = filtered.iterator(); it.hasNext(); )
- {
+ private List<String> filterExtensionIgnoreCase(List<String> fileNames, String extension) {
+ List<String> filtered = new LinkedList<String>(fileNames);
+ for (Iterator<String> it = filtered.iterator(); it.hasNext(); ) {
String name = it.next();
// Take care of extension case
- if ( !endsWithIgnoreCase( name, extension ) )
- {
+ if (!endsWithIgnoreCase(name, extension)) {
it.remove();
}
}
return filtered;
}
- private void addModuleFiles( File rootDir, File moduleBasedir, ParserModule module, String excludes,
- Map<String, DocumentRenderer> files, boolean editable )
- throws IOException, RendererException
- {
- if ( !moduleBasedir.exists() || ArrayUtils.isEmpty( module.getExtensions() ) )
- {
+ private void addModuleFiles(
+ File rootDir,
+ File moduleBasedir,
+ ParserModule module,
+ String excludes,
+ Map<String, DocumentRenderer> files,
+ boolean editable)
+ throws IOException, RendererException {
+ if (!moduleBasedir.exists() || ArrayUtils.isEmpty(module.getExtensions())) {
return;
}
String moduleRelativePath =
- PathTool.getRelativeFilePath( rootDir.getAbsolutePath(), moduleBasedir.getAbsolutePath() );
+ PathTool.getRelativeFilePath(rootDir.getAbsolutePath(), moduleBasedir.getAbsolutePath());
- List<String> allFiles = FileUtils.getFileNames( moduleBasedir, "**/*", excludes, false );
+ List<String> allFiles = FileUtils.getFileNames(moduleBasedir, "**/*", excludes, false);
- for ( String extension : module.getExtensions() )
- {
+ for (String extension : module.getExtensions()) {
String fullExtension = "." + extension;
- List<String> docs = filterExtensionIgnoreCase( allFiles, fullExtension );
+ List<String> docs = filterExtensionIgnoreCase(allFiles, fullExtension);
// *.<extension>.vm
- List<String> velocityFiles = filterExtensionIgnoreCase( allFiles, fullExtension + ".vm" );
+ List<String> velocityFiles = filterExtensionIgnoreCase(allFiles, fullExtension + ".vm");
- docs.addAll( velocityFiles );
+ docs.addAll(velocityFiles);
- for ( String doc : docs )
- {
- RenderingContext context = new RenderingContext( moduleBasedir, moduleRelativePath, doc,
- module.getParserId(), extension, editable );
+ for (String doc : docs) {
+ RenderingContext context = new RenderingContext(
+ moduleBasedir, moduleRelativePath, doc, module.getParserId(), extension, editable);
// TODO: DOXIA-111: we need a general filter here that knows how to alter the context
- if ( endsWithIgnoreCase( doc, ".vm" ) )
- {
- context.setAttribute( "velocity", "true" );
+ if (endsWithIgnoreCase(doc, ".vm")) {
+ context.setAttribute("velocity", "true");
}
String key = context.getOutputName();
- key = StringUtils.replace( key, "\\", "/" );
+ key = StringUtils.replace(key, "\\", "/");
- if ( files.containsKey( key ) )
- {
- DocumentRenderer renderer = files.get( key );
+ if (files.containsKey(key)) {
+ DocumentRenderer renderer = files.get(key);
RenderingContext originalContext = renderer.getRenderingContext();
- File originalDoc = new File( originalContext.getBasedir(), originalContext.getInputName() );
+ File originalDoc = new File(originalContext.getBasedir(), originalContext.getInputName());
- throw new RendererException( "File '" + module.getSourceDirectory() + File.separator + doc
- + "' clashes with existing '" + originalDoc + "'." );
+ throw new RendererException("File '" + module.getSourceDirectory() + File.separator + doc
+ + "' clashes with existing '" + originalDoc + "'.");
}
// -----------------------------------------------------------------------
// Handle key without case differences
// -----------------------------------------------------------------------
- for ( Map.Entry<String, DocumentRenderer> entry : files.entrySet() )
- {
- if ( entry.getKey().equalsIgnoreCase( key ) )
- {
+ for (Map.Entry<String, DocumentRenderer> entry : files.entrySet()) {
+ if (entry.getKey().equalsIgnoreCase(key)) {
RenderingContext originalContext = entry.getValue().getRenderingContext();
- File originalDoc = new File( originalContext.getBasedir(), originalContext.getInputName() );
+ File originalDoc = new File(originalContext.getBasedir(), originalContext.getInputName());
- if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
- {
- throw new RendererException( "File '" + module.getSourceDirectory() + File.separator
- + doc + "' clashes with existing '" + originalDoc + "'." );
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ throw new RendererException("File '" + module.getSourceDirectory() + File.separator + doc
+ + "' clashes with existing '" + originalDoc + "'.");
}
- if ( LOGGER.isWarnEnabled() )
- {
- LOGGER.warn( "File '" + module.getSourceDirectory() + File.separator + doc
- + "' could clash with existing '" + originalDoc + "'." );
+ if (LOGGER.isWarnEnabled()) {
+ LOGGER.warn("File '" + module.getSourceDirectory() + File.separator + doc
+ + "' could clash with existing '" + originalDoc + "'.");
}
}
}
- files.put( key, new DoxiaDocumentRenderer( context ) );
+ files.put(key, new DoxiaDocumentRenderer(context));
}
}
}
/** {@inheritDoc} */
- public void render( Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext,
- File outputDirectory )
- throws RendererException, IOException
- {
- for ( DocumentRenderer docRenderer : documents )
- {
+ public void render(
+ Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, File outputDirectory)
+ throws RendererException, IOException {
+ for (DocumentRenderer docRenderer : documents) {
RenderingContext renderingContext = docRenderer.getRenderingContext();
- File outputFile = new File( outputDirectory, docRenderer.getOutputName() );
+ File outputFile = new File(outputDirectory, docRenderer.getOutputName());
- File inputFile = new File( renderingContext.getBasedir(), renderingContext.getInputName() );
+ File inputFile = new File(renderingContext.getBasedir(), renderingContext.getInputName());
- boolean modified = !outputFile.exists() || ( inputFile.lastModified() > outputFile.lastModified() )
- || ( siteRenderingContext.getDecoration().getLastModified() > outputFile.lastModified() );
+ boolean modified = !outputFile.exists()
+ || (inputFile.lastModified() > outputFile.lastModified())
+ || (siteRenderingContext.getDecoration().getLastModified() > outputFile.lastModified());
- if ( modified || docRenderer.isOverwrite() )
- {
- if ( !outputFile.getParentFile().exists() )
- {
+ if (modified || docRenderer.isOverwrite()) {
+ if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.debug( "Generating " + outputFile );
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Generating " + outputFile);
}
Writer writer = null;
- try
- {
- if ( !docRenderer.isExternalReport() )
- {
- writer = WriterFactory.newWriter( outputFile, siteRenderingContext.getOutputEncoding() );
+ try {
+ if (!docRenderer.isExternalReport()) {
+ writer = WriterFactory.newWriter(outputFile, siteRenderingContext.getOutputEncoding());
}
- docRenderer.renderDocument( writer, this, siteRenderingContext );
- }
- finally
- {
- IOUtil.close( writer );
+ docRenderer.renderDocument(writer, this, siteRenderingContext);
+ } finally {
+ IOUtil.close(writer);
}
- }
- else
- {
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.debug( inputFile + " unchanged, not regenerating..." );
+ } else {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(inputFile + " unchanged, not regenerating...");
}
}
}
}
/** {@inheritDoc} */
- public void renderDocument( Writer writer, RenderingContext docRenderingContext, SiteRenderingContext siteContext )
- throws RendererException, FileNotFoundException, UnsupportedEncodingException
- {
- SiteRendererSink sink = new SiteRendererSink( docRenderingContext );
+ public void renderDocument(Writer writer, RenderingContext docRenderingContext, SiteRenderingContext siteContext)
+ throws RendererException, FileNotFoundException, UnsupportedEncodingException {
+ SiteRendererSink sink = new SiteRendererSink(docRenderingContext);
- File doc = new File( docRenderingContext.getBasedir(), docRenderingContext.getInputName() );
+ File doc = new File(docRenderingContext.getBasedir(), docRenderingContext.getInputName());
Reader reader = null;
- try
- {
+ try {
String resource = doc.getAbsolutePath();
- Parser parser = doxia.getParser( docRenderingContext.getParserId() );
+ Parser parser = doxia.getParser(docRenderingContext.getParserId());
// DOXIASITETOOLS-146 don't render comments from source markup
- parser.setEmitComments( false );
+ parser.setEmitComments(false);
// TODO: DOXIA-111: the filter used here must be checked generally.
- if ( docRenderingContext.getAttribute( "velocity" ) != null )
- {
- LOGGER.debug( "Processing Velocity for " + docRenderingContext.getDoxiaSourcePath() );
- try
- {
- Context vc = createDocumentVelocityContext( docRenderingContext, siteContext );
+ if (docRenderingContext.getAttribute("velocity") != null) {
+ LOGGER.debug("Processing Velocity for " + docRenderingContext.getDoxiaSourcePath());
+ try {
+ Context vc = createDocumentVelocityContext(docRenderingContext, siteContext);
StringWriter sw = new StringWriter();
- velocity.getEngine().mergeTemplate( resource, siteContext.getInputEncoding(), vc, sw );
+ velocity.getEngine().mergeTemplate(resource, siteContext.getInputEncoding(), vc, sw);
String doxiaContent = sw.toString();
- if ( siteContext.getProcessedContentOutput() != null )
- {
+ if (siteContext.getProcessedContentOutput() != null) {
// save Velocity processing result, ie the Doxia content that will be parsed after
- saveVelocityProcessedContent( docRenderingContext, siteContext, doxiaContent );
+ saveVelocityProcessedContent(docRenderingContext, siteContext, doxiaContent);
}
- reader = new StringReader( doxiaContent );
- }
- catch ( VelocityException e )
- {
- throw new RendererException( "Error parsing " + docRenderingContext.getDoxiaSourcePath()
- + " as a Velocity template", e );
+ reader = new StringReader(doxiaContent);
+ } catch (VelocityException e) {
+ throw new RendererException(
+ "Error parsing " + docRenderingContext.getDoxiaSourcePath() + " as a Velocity template", e);
}
- if ( parser.getType() == Parser.XML_TYPE && siteContext.isValidate() )
- {
- reader = validate( reader, resource );
+ if (parser.getType() == Parser.XML_TYPE && siteContext.isValidate()) {
+ reader = validate(reader, resource);
}
- }
- else
- {
- switch ( parser.getType() )
- {
+ } else {
+ switch (parser.getType()) {
case Parser.XML_TYPE:
- reader = ReaderFactory.newXmlReader( doc );
- if ( siteContext.isValidate() )
- {
- reader = validate( reader, resource );
+ reader = ReaderFactory.newXmlReader(doc);
+ if (siteContext.isValidate()) {
+ reader = validate(reader, resource);
}
break;
case Parser.TXT_TYPE:
case Parser.UNKNOWN_TYPE:
default:
- reader = ReaderFactory.newReader( doc, siteContext.getInputEncoding() );
+ reader = ReaderFactory.newReader(doc, siteContext.getInputEncoding());
}
}
- doxia.parse( reader, docRenderingContext.getParserId(), sink, docRenderingContext.getInputName() );
- }
- catch ( ParserNotFoundException e )
- {
- throw new RendererException( "Error getting a parser for '" + doc + "'", e );
- }
- catch ( ParseException e )
- {
+ doxia.parse(reader, docRenderingContext.getParserId(), sink, docRenderingContext.getInputName());
+ } catch (ParserNotFoundException e) {
+ throw new RendererException("Error getting a parser for '" + doc + "'", e);
+ } catch (ParseException e) {
StringBuilder errorMsgBuilder = new StringBuilder();
- errorMsgBuilder.append( "Error parsing '" ).append( doc ).append( "'" );
- if ( e.getLineNumber() > 0 )
- {
- errorMsgBuilder.append( ", line " ).append( e.getLineNumber() );
- }
- throw new RendererException( errorMsgBuilder.toString(), e );
- }
- catch ( IOException e )
- {
- throw new RendererException( "Error while processing '" + doc + "'", e );
- }
- finally
- {
+ errorMsgBuilder.append("Error parsing '").append(doc).append("'");
+ if (e.getLineNumber() > 0) {
+ errorMsgBuilder.append(", line ").append(e.getLineNumber());
+ }
+ throw new RendererException(errorMsgBuilder.toString(), e);
+ } catch (IOException e) {
+ throw new RendererException("Error while processing '" + doc + "'", e);
+ } finally {
sink.flush();
sink.close();
- IOUtil.close( reader );
+ IOUtil.close(reader);
}
- mergeDocumentIntoSite( writer, (DocumentContent) sink, siteContext );
+ mergeDocumentIntoSite(writer, (DocumentContent) sink, siteContext);
}
- private void saveVelocityProcessedContent( RenderingContext docRenderingContext, SiteRenderingContext siteContext,
- String doxiaContent )
- throws IOException
- {
- if ( !siteContext.getProcessedContentOutput().exists() )
- {
+ private void saveVelocityProcessedContent(
+ RenderingContext docRenderingContext, SiteRenderingContext siteContext, String doxiaContent)
+ throws IOException {
+ if (!siteContext.getProcessedContentOutput().exists()) {
siteContext.getProcessedContentOutput().mkdirs();
}
String input = docRenderingContext.getInputName();
- File outputFile = new File( siteContext.getProcessedContentOutput(),
- input.substring( 0, input.length() - 3 ) );
+ File outputFile = new File(siteContext.getProcessedContentOutput(), input.substring(0, input.length() - 3));
File outputParent = outputFile.getParentFile();
- if ( !outputParent.exists() )
- {
+ if (!outputParent.exists()) {
outputParent.mkdirs();
}
- FileUtils.fileWrite( outputFile, siteContext.getInputEncoding(), doxiaContent );
+ FileUtils.fileWrite(outputFile, siteContext.getInputEncoding(), doxiaContent);
}
/**
@@ -482,41 +430,44 @@ public class DefaultSiteRenderer
* @param siteRenderingContext the site rendering context
* @return a Velocity tools managed context
*/
- protected Context createToolManagedVelocityContext( SiteRenderingContext siteRenderingContext )
- {
+ protected Context createToolManagedVelocityContext(SiteRenderingContext siteRenderingContext) {
Locale locale = siteRenderingContext.getLocale();
- String dateFormat = siteRenderingContext.getDecoration().getPublishDate().getFormat();
-
- EasyFactoryConfiguration config = new EasyFactoryConfiguration( false );
- config.property( "safeMode", Boolean.FALSE );
- config.toolbox( Scope.REQUEST )
- .tool( ContextTool.class )
- .tool( LinkTool.class )
- .tool( LoopTool.class )
- .tool( RenderTool.class );
- config.toolbox( Scope.APPLICATION ).property( "locale", locale )
- .tool( AlternatorTool.class )
- .tool( ClassTool.class )
- .tool( ComparisonDateTool.class ).property( "format", dateFormat )
- .tool( ConversionTool.class ).property( "dateFormat", dateFormat )
- .tool( DisplayTool.class )
- .tool( EscapeTool.class )
- .tool( FieldTool.class )
- .tool( MathTool.class )
- .tool( NumberTool.class )
- .tool( ResourceTool.class ).property( "bundles", new String[] { "site-renderer" } )
- .tool( SortTool.class )
- .tool( XmlTool.class );
-
- FactoryConfiguration customConfig = ConfigurationUtils.findInClasspath( TOOLS_LOCATION );
-
- if ( customConfig != null )
- {
- config.addConfiguration( customConfig );
- }
-
- ToolManager manager = new ToolManager( false, false );
- manager.configure( config );
+ String dateFormat =
+ siteRenderingContext.getDecoration().getPublishDate().getFormat();
+
+ EasyFactoryConfiguration config = new EasyFactoryConfiguration(false);
+ config.property("safeMode", Boolean.FALSE);
+ config.toolbox(Scope.REQUEST)
+ .tool(ContextTool.class)
+ .tool(LinkTool.class)
+ .tool(LoopTool.class)
+ .tool(RenderTool.class);
+ config.toolbox(Scope.APPLICATION)
+ .property("locale", locale)
+ .tool(AlternatorTool.class)
+ .tool(ClassTool.class)
+ .tool(ComparisonDateTool.class)
+ .property("format", dateFormat)
+ .tool(ConversionTool.class)
+ .property("dateFormat", dateFormat)
+ .tool(DisplayTool.class)
+ .tool(EscapeTool.class)
+ .tool(FieldTool.class)
+ .tool(MathTool.class)
+ .tool(NumberTool.class)
+ .tool(ResourceTool.class)
+ .property("bundles", new String[] {"site-renderer"})
+ .tool(SortTool.class)
+ .tool(XmlTool.class);
+
+ FactoryConfiguration customConfig = ConfigurationUtils.findInClasspath(TOOLS_LOCATION);
+
+ if (customConfig != null) {
+ config.addConfiguration(customConfig);
+ }
+
+ ToolManager manager = new ToolManager(false, false);
+ manager.configure(config);
return manager.createContext();
}
@@ -528,42 +479,38 @@ public class DefaultSiteRenderer
* @param siteRenderingContext the site rendering context
* @return a Velocity tools managed context
*/
- protected Context createDocumentVelocityContext( RenderingContext renderingContext,
- SiteRenderingContext siteRenderingContext )
- {
- Context context = createToolManagedVelocityContext( siteRenderingContext );
+ protected Context createDocumentVelocityContext(
+ RenderingContext renderingContext, SiteRenderingContext siteRenderingContext) {
+ Context context = createToolManagedVelocityContext(siteRenderingContext);
// ----------------------------------------------------------------------
// Data objects
// ----------------------------------------------------------------------
- context.put( "relativePath", renderingContext.getRelativePath() );
+ context.put("relativePath", renderingContext.getRelativePath());
- String currentFileName = renderingContext.getOutputName().replace( '\\', '/' );
- context.put( "currentFileName", currentFileName );
+ String currentFileName = renderingContext.getOutputName().replace('\\', '/');
+ context.put("currentFileName", currentFileName);
- context.put( "alignedFileName", PathTool.calculateLink( currentFileName, renderingContext.getRelativePath() ) );
+ context.put("alignedFileName", PathTool.calculateLink(currentFileName, renderingContext.getRelativePath()));
- context.put( "decoration", siteRenderingContext.getDecoration() );
+ context.put("decoration", siteRenderingContext.getDecoration());
Locale locale = siteRenderingContext.getLocale();
- context.put( "locale", locale );
- context.put( "supportedLocales", Collections.unmodifiableList( siteRenderingContext.getSiteLocales() ) );
+ context.put("locale", locale);
+ context.put("supportedLocales", Collections.unmodifiableList(siteRenderingContext.getSiteLocales()));
- context.put( "publishDate", siteRenderingContext.getPublishDate() );
+ context.put("publishDate", siteRenderingContext.getPublishDate());
- if ( DOXIA_SITE_RENDERER_VERSION != null )
- {
- context.put( "doxiaSiteRendererVersion", DOXIA_SITE_RENDERER_VERSION );
+ if (DOXIA_SITE_RENDERER_VERSION != null) {
+ context.put("doxiaSiteRendererVersion", DOXIA_SITE_RENDERER_VERSION);
}
// Add user properties
Map<String, ?> templateProperties = siteRenderingContext.getTemplateProperties();
- if ( templateProperties != null )
- {
- for ( Map.Entry<String, ?> entry : templateProperties.entrySet() )
- {
- context.put( entry.getKey(), entry.getValue() );
+ if (templateProperties != null) {
+ for (Map.Entry<String, ?> entry : templateProperties.entrySet()) {
+ context.put(entry.getKey(), entry.getValue());
}
}
@@ -571,11 +518,11 @@ public class DefaultSiteRenderer
// Tools
// ----------------------------------------------------------------------
- context.put( "PathTool", new PathTool() );
+ context.put("PathTool", new PathTool());
- context.put( "StringUtils", new StringUtils() );
+ context.put("StringUtils", new StringUtils());
- context.put( "plexus", plexus );
+ context.put("plexus", plexus);
return context;
}
@@ -587,279 +534,232 @@ public class DefaultSiteRenderer
* @param siteRenderingContext the site rendering context
* @return a Velocity tools managed context
*/
- protected Context createSiteTemplateVelocityContext( DocumentContent content,
- SiteRenderingContext siteRenderingContext )
- {
+ protected Context createSiteTemplateVelocityContext(
+ DocumentContent content, SiteRenderingContext siteRenderingContext) {
// first get the context from document
- Context context = createDocumentVelocityContext( content.getRenderingContext(), siteRenderingContext );
+ Context context = createDocumentVelocityContext(content.getRenderingContext(), siteRenderingContext);
// then add data objects from rendered document
// Add infos from document
- context.put( "authors", content.getAuthors() );
+ context.put("authors", content.getAuthors());
- context.put( "shortTitle", content.getTitle() );
+ context.put("shortTitle", content.getTitle());
// DOXIASITETOOLS-70: Prepend the project name to the title, if any
StringBuilder title = new StringBuilder();
- if ( siteRenderingContext.getDecoration() != null
- && StringUtils.isNotEmpty( siteRenderingContext.getDecoration().getName() ) )
- {
- title.append( siteRenderingContext.getDecoration().getName() );
- }
- else if ( StringUtils.isNotEmpty( siteRenderingContext.getDefaultTitle() ) )
- {
- title.append( siteRenderingContext.getDefaultTitle() );
+ if (siteRenderingContext.getDecoration() != null
+ && StringUtils.isNotEmpty(siteRenderingContext.getDecoration().getName())) {
+ title.append(siteRenderingContext.getDecoration().getName());
+ } else if (StringUtils.isNotEmpty(siteRenderingContext.getDefaultTitle())) {
+ title.append(siteRenderingContext.getDefaultTitle());
}
- if ( title.length() > 0 && StringUtils.isNotEmpty( content.getTitle() ) )
- {
- title.append( " – " ); // Symbol Name: En Dash, Html Entity: –
+ if (title.length() > 0 && StringUtils.isNotEmpty(content.getTitle())) {
+ title.append(" – "); // Symbol Name: En Dash, Html Entity: –
}
- if ( StringUtils.isNotEmpty( content.getTitle() ) )
- {
- title.append( content.getTitle() );
+ if (StringUtils.isNotEmpty(content.getTitle())) {
+ title.append(content.getTitle());
}
- context.put( "title", title.length() > 0 ? title.toString() : null );
+ context.put("title", title.length() > 0 ? title.toString() : null);
- context.put( "headContent", content.getHead() );
+ context.put("headContent", content.getHead());
- context.put( "bodyContent", content.getBody() );
+ context.put("bodyContent", content.getBody());
// document date (got from Doxia Sink date() API)
- context.put( "documentDate", content.getDate() );
+ context.put("documentDate", content.getDate());
// document rendering context, to get eventual inputName
- context.put( "docRenderingContext", content.getRenderingContext() );
+ context.put("docRenderingContext", content.getRenderingContext());
return context;
}
/** {@inheritDoc} */
- public void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext )
- throws RendererException
- {
- mergeDocumentIntoSite( writer, sink, siteRenderingContext );
+ public void generateDocument(Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext)
+ throws RendererException {
+ mergeDocumentIntoSite(writer, sink, siteRenderingContext);
}
/** {@inheritDoc} */
- public void mergeDocumentIntoSite( Writer writer, DocumentContent content,
- SiteRenderingContext siteRenderingContext )
- throws RendererException
- {
+ public void mergeDocumentIntoSite(Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext)
+ throws RendererException {
String templateName = siteRenderingContext.getTemplateName();
- LOGGER.debug( "Processing Velocity for template " + templateName + " on "
- + content.getRenderingContext().getInputName() );
+ LOGGER.debug("Processing Velocity for template " + templateName + " on "
+ + content.getRenderingContext().getInputName());
- Context context = createSiteTemplateVelocityContext( content, siteRenderingContext );
+ Context context = createSiteTemplateVelocityContext(content, siteRenderingContext);
ClassLoader old = null;
- if ( siteRenderingContext.getTemplateClassLoader() != null )
- {
+ if (siteRenderingContext.getTemplateClassLoader() != null) {
// -------------------------------------------------------------------------
// If no template classloader was set we'll just use the context classloader
// -------------------------------------------------------------------------
old = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader( siteRenderingContext.getTemplateClassLoader() );
+ Thread.currentThread().setContextClassLoader(siteRenderingContext.getTemplateClassLoader());
}
- try
- {
+ try {
Template template;
Artifact skin = siteRenderingContext.getSkin();
- try
- {
+ try {
SkinModel skinModel = siteRenderingContext.getSkinModel();
- String encoding = ( skinModel == null ) ? null : skinModel.getEncoding();
-
- template = ( encoding == null ) ? velocity.getEngine().getTemplate( templateName )
- : velocity.getEngine().getTemplate( templateName, encoding );
- }
- catch ( ParseErrorException pee )
- {
- throw new RendererException( "Velocity parsing error while reading the site decoration template "
- + "from " + skin.getId() + " skin", pee );
- }
- catch ( ResourceNotFoundException rnfe )
- {
- throw new RendererException( "Could not find the site decoration template "
- + "from " + skin.getId() + " skin", rnfe );
- }
-
- try
- {
+ String encoding = (skinModel == null) ? null : skinModel.getEncoding();
+
+ template = (encoding == null)
+ ? velocity.getEngine().getTemplate(templateName)
+ : velocity.getEngine().getTemplate(templateName, encoding);
+ } catch (ParseErrorException pee) {
+ throw new RendererException(
+ "Velocity parsing error while reading the site decoration template " + "from " + skin.getId()
+ + " skin",
+ pee);
+ } catch (ResourceNotFoundException rnfe) {
+ throw new RendererException(
+ "Could not find the site decoration template " + "from " + skin.getId() + " skin", rnfe);
+ }
+
+ try {
StringWriter sw = new StringWriter();
- template.merge( context, sw );
- writer.write( sw.toString().replaceAll( "\r?\n", SystemUtils.LINE_SEPARATOR ) );
- }
- catch ( VelocityException ve )
- {
- throw new RendererException( "Velocity error while merging site decoration template.", ve );
- }
- catch ( IOException ioe )
- {
- throw new RendererException( "IO exception while merging site decoration template.", ioe );
+ template.merge(context, sw);
+ writer.write(sw.toString().replaceAll("\r?\n", SystemUtils.LINE_SEPARATOR));
+ } catch (VelocityException ve) {
+ throw new RendererException("Velocity error while merging site decoration template.", ve);
+ } catch (IOException ioe) {
+ throw new RendererException("IO exception while merging site decoration template.", ioe);
}
- }
- finally
- {
- IOUtil.close( writer );
+ } finally {
+ IOUtil.close(writer);
- if ( old != null )
- {
- Thread.currentThread().setContextClassLoader( old );
+ if (old != null) {
+ Thread.currentThread().setContextClassLoader(old);
}
}
}
- private SiteRenderingContext createSiteRenderingContext( Map<String, ?> attributes, DecorationModel decoration,
- String defaultTitle, Locale locale )
- {
+ private SiteRenderingContext createSiteRenderingContext(
+ Map<String, ?> attributes, DecorationModel decoration, String defaultTitle, Locale locale) {
SiteRenderingContext context = new SiteRenderingContext();
- context.setTemplateProperties( attributes );
- context.setLocale( locale );
- context.setDecoration( decoration );
- context.setDefaultTitle( defaultTitle );
+ context.setTemplateProperties(attributes);
+ context.setLocale(locale);
+ context.setDecoration(decoration);
+ context.setDefaultTitle(defaultTitle);
return context;
}
/** {@inheritDoc} */
- public SiteRenderingContext createContextForSkin( Artifact skin, Map<String, ?> attributes,
- DecorationModel decoration, String defaultTitle,
- Locale locale )
- throws IOException, RendererException
- {
- SiteRenderingContext context = createSiteRenderingContext( attributes, decoration, defaultTitle, locale );
+ public SiteRenderingContext createContextForSkin(
+ Artifact skin, Map<String, ?> attributes, DecorationModel decoration, String defaultTitle, Locale locale)
+ throws IOException, RendererException {
+ SiteRenderingContext context = createSiteRenderingContext(attributes, decoration, defaultTitle, locale);
- context.setSkin( skin );
+ context.setSkin(skin);
- ZipFile zipFile = getZipFile( skin.getFile() );
+ ZipFile zipFile = getZipFile(skin.getFile());
InputStream in = null;
- try
- {
- if ( zipFile.getEntry( SKIN_TEMPLATE_LOCATION ) == null )
- {
- throw new RendererException( "Skin does not contain template at " + SKIN_TEMPLATE_LOCATION );
+ try {
+ if (zipFile.getEntry(SKIN_TEMPLATE_LOCATION) == null) {
+ throw new RendererException("Skin does not contain template at " + SKIN_TEMPLATE_LOCATION);
}
- context.setTemplateName( SKIN_TEMPLATE_LOCATION );
- context.setTemplateClassLoader( new URLClassLoader( new URL[]{skin.getFile().toURI().toURL()} ) );
+ context.setTemplateName(SKIN_TEMPLATE_LOCATION);
+ context.setTemplateClassLoader(
+ new URLClassLoader(new URL[] {skin.getFile().toURI().toURL()}));
- ZipEntry skinDescriptorEntry = zipFile.getEntry( SkinModel.SKIN_DESCRIPTOR_LOCATION );
- if ( skinDescriptorEntry != null )
- {
- in = zipFile.getInputStream( skinDescriptorEntry );
+ ZipEntry skinDescriptorEntry = zipFile.getEntry(SkinModel.SKIN_DESCRIPTOR_LOCATION);
+ if (skinDescriptorEntry != null) {
+ in = zipFile.getInputStream(skinDescriptorEntry);
- SkinModel skinModel = new SkinXpp3Reader().read( in );
- context.setSkinModel( skinModel );
+ SkinModel skinModel = new SkinXpp3Reader().read(in);
+ context.setSkinModel(skinModel);
- String toolsPrerequisite =
- skinModel.getPrerequisites() == null ? null : skinModel.getPrerequisites().getDoxiaSitetools();
+ String toolsPrerequisite = skinModel.getPrerequisites() == null
+ ? null
+ : skinModel.getPrerequisites().getDoxiaSitetools();
Package p = DefaultSiteRenderer.class.getPackage();
- String current = ( p == null ) ? null : p.getImplementationVersion();
+ String current = (p == null) ? null : p.getImplementationVersion();
- if ( StringUtils.isNotBlank( toolsPrerequisite ) && ( current != null )
- && !matchVersion( current, toolsPrerequisite ) )
- {
- throw new RendererException( "Cannot use skin: has " + toolsPrerequisite
- + " Doxia Sitetools prerequisite, but current is " + current );
+ if (StringUtils.isNotBlank(toolsPrerequisite)
+ && (current != null)
+ && !matchVersion(current, toolsPrerequisite)) {
+ throw new RendererException("Cannot use skin: has " + toolsPrerequisite
+ + " Doxia Sitetools prerequisite, but current is " + current);
}
}
- }
- catch ( XmlPullParserException e )
- {
- throw new RendererException( "Failed to parse " + SkinModel.SKIN_DESCRIPTOR_LOCATION
- + " skin descriptor from " + skin.getId() + " skin", e );
- }
- finally
- {
- IOUtil.close( in );
- closeZipFile( zipFile );
+ } catch (XmlPullParserException e) {
+ throw new RendererException(
+ "Failed to parse " + SkinModel.SKIN_DESCRIPTOR_LOCATION + " skin descriptor from " + skin.getId()
+ + " skin",
+ e);
+ } finally {
+ IOUtil.close(in);
+ closeZipFile(zipFile);
}
return context;
}
- boolean matchVersion( String current, String prerequisite )
- throws RendererException
- {
- try
- {
- ArtifactVersion v = new DefaultArtifactVersion( current );
- VersionRange vr = VersionRange.createFromVersionSpec( prerequisite );
+ boolean matchVersion(String current, String prerequisite) throws RendererException {
+ try {
+ ArtifactVersion v = new DefaultArtifactVersion(current);
+ VersionRange vr = VersionRange.createFromVersionSpec(prerequisite);
boolean matched = false;
ArtifactVersion recommendedVersion = vr.getRecommendedVersion();
- if ( recommendedVersion == null )
- {
+ if (recommendedVersion == null) {
List<Restriction> restrictions = vr.getRestrictions();
- for ( Restriction restriction : restrictions )
- {
- if ( restriction.containsVersion( v ) )
- {
+ for (Restriction restriction : restrictions) {
+ if (restriction.containsVersion(v)) {
matched = true;
break;
}
}
- }
- else
- {
+ } else {
// only singular versions ever have a recommendedVersion
- @SuppressWarnings( "unchecked" )
- int compareTo = recommendedVersion.compareTo( v );
- matched = ( compareTo <= 0 );
+ @SuppressWarnings("unchecked")
+ int compareTo = recommendedVersion.compareTo(v);
+ matched = (compareTo <= 0);
}
- if ( LOGGER.isDebugEnabled() )
- {
- LOGGER.debug( "Skin doxia-sitetools prerequisite: " + prerequisite + ", current: " + current
- + ", matched = " + matched );
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Skin doxia-sitetools prerequisite: " + prerequisite + ", current: " + current
+ + ", matched = " + matched);
}
return matched;
- }
- catch ( InvalidVersionSpecificationException e )
- {
- throw new RendererException( "Invalid skin doxia-sitetools prerequisite: " + prerequisite, e );
+ } catch (InvalidVersionSpecificationException e) {
+ throw new RendererException("Invalid skin doxia-sitetools prerequisite: " + prerequisite, e);
}
}
/** {@inheritDoc} */
- public void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory,
- File outputDirectory )
- throws IOException
- {
- throw new AssertionError( "copyResources( SiteRenderingContext, File, File ) is deprecated." );
+ public void copyResources(SiteRenderingContext siteRenderingContext, File resourcesDirectory, File outputDirectory)
+ throws IOException {
+ throw new AssertionError("copyResources( SiteRenderingContext, File, File ) is deprecated.");
}
/** {@inheritDoc} */
- public void copyResources( SiteRenderingContext siteRenderingContext, File outputDirectory )
- throws IOException
- {
- ZipFile file = getZipFile( siteRenderingContext.getSkin().getFile() );
-
- try
- {
- for ( Enumeration<? extends ZipEntry> e = file.entries(); e.hasMoreElements(); )
- {
+ public void copyResources(SiteRenderingContext siteRenderingContext, File outputDirectory) throws IOException {
+ ZipFile file = getZipFile(siteRenderingContext.getSkin().getFile());
+
+ try {
+ for (Enumeration<? extends ZipEntry> e = file.entries(); e.hasMoreElements(); ) {
ZipEntry entry = e.nextElement();
- if ( !entry.getName().startsWith( "META-INF/" ) )
- {
- File destFile = new File( outputDirectory, entry.getName() );
- if ( !entry.isDirectory() )
- {
- if ( destFile.exists() )
- {
+ if (!entry.getName().startsWith("META-INF/")) {
+ File destFile = new File(outputDirectory, entry.getName());
+ if (!entry.isDirectory()) {
+ if (destFile.exists()) {
// don't override existing content: avoids extra rewrite with same content or extra site
// resource
continue;
@@ -867,76 +767,58 @@ public class DefaultSiteRenderer
destFile.getParentFile().mkdirs();
- copyFileFromZip( file, entry, destFile );
- }
- else
- {
+ copyFileFromZip(file, entry, destFile);
+ } else {
destFile.mkdirs();
}
}
}
- }
- finally
- {
- closeZipFile( file );
+ } finally {
+ closeZipFile(file);
}
// Copy extra site resources
- for ( File siteDirectory : siteRenderingContext.getSiteDirectories() )
- {
- File resourcesDirectory = new File( siteDirectory, "resources" );
+ for (File siteDirectory : siteRenderingContext.getSiteDirectories()) {
+ File resourcesDirectory = new File(siteDirectory, "resources");
- if ( resourcesDirectory != null && resourcesDirectory.exists() )
- {
- copyDirectory( resourcesDirectory, outputDirectory );
+ if (resourcesDirectory != null && resourcesDirectory.exists()) {
+ copyDirectory(resourcesDirectory, outputDirectory);
}
}
// Check for the existence of /css/site.css
- File siteCssFile = new File( outputDirectory, "/css/site.css" );
- if ( !siteCssFile.exists() )
- {
+ File siteCssFile = new File(outputDirectory, "/css/site.css");
+ if (!siteCssFile.exists()) {
// Create the subdirectory css if it doesn't exist, DOXIA-151
- File cssDirectory = new File( outputDirectory, "/css/" );
+ File cssDirectory = new File(outputDirectory, "/css/");
boolean created = cssDirectory.mkdirs();
- if ( created && LOGGER.isDebugEnabled() )
- {
- LOGGER.debug(
- "The directory '" + cssDirectory.getAbsolutePath() + "' did not exist. It was created." );
+ if (created && LOGGER.isDebugEnabled()) {
+ LOGGER.debug("The directory '" + cssDirectory.getAbsolutePath() + "' did not exist. It was created.");
}
// If the file is not there - create an empty file, DOXIA-86
- if ( LOGGER.isDebugEnabled() )
- {
+ if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
- "The file '" + siteCssFile.getAbsolutePath() + "' does not exist. Creating an empty file." );
+ "The file '" + siteCssFile.getAbsolutePath() + "' does not exist. Creating an empty file.");
}
Writer writer = null;
- try
- {
- writer = WriterFactory.newWriter( siteCssFile, siteRenderingContext.getOutputEncoding() );
- //DOXIA-290...the file should not be 0 bytes.
- writer.write( "/* You can override this file with your own styles */" );
- }
- finally
- {
- IOUtil.close( writer );
+ try {
+ writer = WriterFactory.newWriter(siteCssFile, siteRenderingContext.getOutputEncoding());
+ // DOXIA-290...the file should not be 0 bytes.
+ writer.write("/* You can override this file with your own styles */");
+ } finally {
+ IOUtil.close(writer);
}
}
}
- private static void copyFileFromZip( ZipFile file, ZipEntry entry, File destFile )
- throws IOException
- {
- FileOutputStream fos = new FileOutputStream( destFile );
+ private static void copyFileFromZip(ZipFile file, ZipEntry entry, File destFile) throws IOException {
+ FileOutputStream fos = new FileOutputStream(destFile);
- try
- {
- IOUtil.copy( file.getInputStream( entry ), fos );
- }
- finally
- {
- IOUtil.close( fos );
+ try {
+ IOUtil.copy(file.getInputStream(entry), fos);
+ } finally {
+ IOUtil.close(fos);
}
}
@@ -947,119 +829,91 @@ public class DefaultSiteRenderer
* @param destination destination file
* @throws java.io.IOException if any
*/
- protected void copyDirectory( File source, File destination )
- throws IOException
- {
- if ( source.exists() )
- {
+ protected void copyDirectory(File source, File destination) throws IOException {
+ if (source.exists()) {
DirectoryScanner scanner = new DirectoryScanner();
String[] includedResources = {"**/*"};
- scanner.setIncludes( includedResources );
+ scanner.setIncludes(includedResources);
scanner.addDefaultExcludes();
- scanner.setBasedir( source );
+ scanner.setBasedir(source);
scanner.scan();
- List<String> includedFiles = Arrays.asList( scanner.getIncludedFiles() );
+ List<String> includedFiles = Arrays.asList(scanner.getIncludedFiles());
- for ( String name : includedFiles )
- {
- File sourceFile = new File( source, name );
+ for (String name : includedFiles) {
+ File sourceFile = new File(source, name);
- File destinationFile = new File( destination, name );
+ File destinationFile = new File(destination, name);
- FileUtils.copyFile( sourceFile, destinationFile );
+ FileUtils.copyFile(sourceFile, destinationFile);
}
}
}
- private Reader validate( Reader source, String resource )
- throws ParseException, IOException
- {
- LOGGER.debug( "Validating: " + resource );
+ private Reader validate(Reader source, String resource) throws ParseException, IOException {
+ LOGGER.debug("Validating: " + resource);
- try
- {
- String content = IOUtil.toString( new BufferedReader( source ) );
+ try {
+ String content = IOUtil.toString(new BufferedReader(source));
- new XmlValidator( ).validate( content );
+ new XmlValidator().validate(content);
- return new StringReader( content );
- }
- finally
- {
- IOUtil.close( source );
+ return new StringReader(content);
+ } finally {
+ IOUtil.close(source);
}
}
// TODO replace with StringUtils.endsWithIgnoreCase() from maven-shared-utils 0.7
- static boolean endsWithIgnoreCase( String str, String searchStr )
- {
- if ( str.length() < searchStr.length() )
- {
+ static boolean endsWithIgnoreCase(String str, String searchStr) {
+ if (str.length() < searchStr.length()) {
return false;
}
- return str.regionMatches( true, str.length() - searchStr.length(), searchStr, 0, searchStr.length() );
+ return str.regionMatches(true, str.length() - searchStr.length(), searchStr, 0, searchStr.length());
}
- private static ZipFile getZipFile( File file )
- throws IOException
- {
- if ( file == null )
- {
- throw new IOException( "Error opening ZipFile: null" );
+ private static ZipFile getZipFile(File file) throws IOException {
+ if (file == null) {
+ throw new IOException("Error opening ZipFile: null");
}
- try
- {
+ try {
// TODO: plexus-archiver, if it could do the excludes
- return new ZipFile( file );
- }
- catch ( ZipException ex )
- {
- IOException ioe = new IOException( "Error opening ZipFile: " + file.getAbsolutePath() );
- ioe.initCause( ex );
+ return new ZipFile(file);
+ } catch (ZipException ex) {
+ IOException ioe = new IOException("Error opening ZipFile: " + file.getAbsolutePath());
+ ioe.initCause(ex);
throw ioe;
}
}
- private static void closeZipFile( ZipFile zipFile )
- {
+ private static void closeZipFile(ZipFile zipFile) {
// TODO: move to plexus utils
- try
- {
+ try {
zipFile.close();
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
// ignore
}
}
- private static String getSiteRendererVersion()
- {
- InputStream inputStream = DefaultSiteRenderer.class.getResourceAsStream( "/META-INF/"
- + "maven/org.apache.maven.doxia/doxia-site-renderer/pom.properties" );
- if ( inputStream == null )
- {
- LOGGER.debug( "pom.properties for doxia-site-renderer not found" );
- }
- else
- {
+ private static String getSiteRendererVersion() {
+ InputStream inputStream = DefaultSiteRenderer.class.getResourceAsStream(
+ "/META-INF/" + "maven/org.apache.maven.doxia/doxia-site-renderer/pom.properties");
+ if (inputStream == null) {
+ LOGGER.debug("pom.properties for doxia-site-renderer not found");
+ } else {
Properties properties = new Properties();
- try ( InputStream in = inputStream )
- {
- properties.load( in );
- return properties.getProperty( "version" );
- }
- catch ( IOException e )
- {
- LOGGER.debug( "Failed to load pom.properties, so Doxia SiteRenderer version will not be available", e );
+ try (InputStream in = inputStream) {
+ properties.load(in);
+ return properties.getProperty("version");
+ } catch (IOException e) {
+ LOGGER.debug("Failed to load pom.properties, so Doxia SiteRenderer version will not be available", e);
}
}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentContent.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentContent.java
index 4bcbb9e..8b799bc 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentContent.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentContent.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import java.util.List;
@@ -26,8 +25,7 @@ import java.util.List;
*
* @since 1.8
*/
-public interface DocumentContent
-{
+public interface DocumentContent {
/**
* Get the title of the document.
* @return the document title
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java
index 74485a6..c8443a1 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DocumentRenderer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
@@ -29,8 +28,7 @@ import java.io.Writer;
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @see RenderingContext document rendering context
*/
-public interface DocumentRenderer
-{
+public interface DocumentRenderer {
/**
* Render a document in a site.
*
@@ -41,8 +39,8 @@ public interface DocumentRenderer
* @throws java.io.FileNotFoundException if it bombs.
* @throws java.io.UnsupportedEncodingException if it bombs.
*/
- void renderDocument( Writer writer, Renderer siteRenderer, SiteRenderingContext siteRenderingContext )
- throws RendererException, FileNotFoundException, UnsupportedEncodingException;
+ void renderDocument(Writer writer, Renderer siteRenderer, SiteRenderingContext siteRenderingContext)
+ throws RendererException, FileNotFoundException, UnsupportedEncodingException;
/**
* The name of the output document.
@@ -64,10 +62,10 @@ public interface DocumentRenderer
* @return whether to overwrite
*/
boolean isOverwrite();
-
+
/**
* Whether this document is an external report, independent from the site templating.
- *
+ *
* @return {@code true} if report is external, otherwise {@code false}
* @since 1.7
*/
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java
index 30ffda0..f2b0eb4 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DoxiaDocumentRenderer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
@@ -30,9 +29,7 @@ import java.io.Writer;
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
-public class DoxiaDocumentRenderer
- implements DocumentRenderer
-{
+public class DoxiaDocumentRenderer implements DocumentRenderer {
private RenderingContext renderingContext;
/**
@@ -40,39 +37,32 @@ public class DoxiaDocumentRenderer
*
* @param renderingContext the document's RenderingContext to use.
*/
- public DoxiaDocumentRenderer( RenderingContext renderingContext )
- {
+ public DoxiaDocumentRenderer(RenderingContext renderingContext) {
this.renderingContext = renderingContext;
}
/** {@inheritDoc} */
- public void renderDocument( Writer writer, Renderer siteRenderer, SiteRenderingContext siteRenderingContext )
- throws RendererException, FileNotFoundException, UnsupportedEncodingException
- {
- siteRenderer.renderDocument( writer, renderingContext, siteRenderingContext );
+ public void renderDocument(Writer writer, Renderer siteRenderer, SiteRenderingContext siteRenderingContext)
+ throws RendererException, FileNotFoundException, UnsupportedEncodingException {
+ siteRenderer.renderDocument(writer, renderingContext, siteRenderingContext);
}
/** {@inheritDoc} */
- public String getOutputName()
- {
+ public String getOutputName() {
return renderingContext.getOutputName();
}
/** {@inheritDoc} */
- public RenderingContext getRenderingContext()
- {
+ public RenderingContext getRenderingContext() {
return renderingContext;
}
/** {@inheritDoc} */
- public boolean isOverwrite()
- {
+ public boolean isOverwrite() {
return false;
}
- public boolean isExternalReport()
- {
+ public boolean isExternalReport() {
return false;
}
-
}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ExtraDoxiaModuleReference.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ExtraDoxiaModuleReference.java
index 5327b33..75f2820 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ExtraDoxiaModuleReference.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ExtraDoxiaModuleReference.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import java.io.File;
@@ -27,14 +26,12 @@ import java.io.File;
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
@Deprecated
-class ExtraDoxiaModuleReference
-{
+class ExtraDoxiaModuleReference {
private final String parserId;
private final File basedir;
- ExtraDoxiaModuleReference( String parserId, File basedir )
- {
+ ExtraDoxiaModuleReference(String parserId, File basedir) {
this.parserId = parserId;
this.basedir = basedir;
}
@@ -44,8 +41,7 @@ class ExtraDoxiaModuleReference
*
* @return Doxia parser id associated to this source module.
*/
- String getParserId()
- {
+ String getParserId() {
return parserId;
}
@@ -54,8 +50,7 @@ class ExtraDoxiaModuleReference
*
* @return The base directory for module's source files.
*/
- File getBasedir()
- {
+ File getBasedir() {
return basedir;
}
}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
index 8bb2a14..a327184 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import java.io.File;
import java.io.FileNotFoundException;
@@ -37,7 +36,7 @@ import org.apache.maven.doxia.site.decoration.DecorationModel;
* @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
*/
public interface Renderer // TODO rename to SiteRenderer
-{
+ {
/**
* Render a collection of documents into a site.
*
@@ -47,9 +46,8 @@ public interface Renderer // TODO rename to SiteRenderer
* @throws RendererException if it bombs.
* @throws IOException if it bombs.
*/
- void render( Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext,
- File outputDirectory )
- throws RendererException, IOException;
+ void render(Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, File outputDirectory)
+ throws RendererException, IOException;
/**
* Generate a document output integrated in a site from a document content,
@@ -61,8 +59,8 @@ public interface Renderer // TODO rename to SiteRenderer
* @throws RendererException if it bombs.
* @since 1.8
*/
- void mergeDocumentIntoSite( Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext )
- throws RendererException;
+ void mergeDocumentIntoSite(Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext)
+ throws RendererException;
/**
* Create a Site Rendering Context for a site using a skin.
@@ -77,9 +75,9 @@ public interface Renderer // TODO rename to SiteRenderer
* @throws java.io.IOException if it bombs.
* @since 1.7.3 was previously with skin as File instead of Artifact
*/
- SiteRenderingContext createContextForSkin( Artifact skin, Map<String, ?> attributes, DecorationModel decoration,
- String defaultTitle, Locale locale )
- throws RendererException, IOException;
+ SiteRenderingContext createContextForSkin(
+ Artifact skin, Map<String, ?> attributes, DecorationModel decoration, String defaultTitle, Locale locale)
+ throws RendererException, IOException;
/**
* Copy resource files from skin, template, and site resources.
@@ -89,8 +87,7 @@ public interface Renderer // TODO rename to SiteRenderer
* @throws IOException if it bombs.
* @since 1.7
*/
- void copyResources( SiteRenderingContext siteRenderingContext, File outputDirectory )
- throws IOException;
+ void copyResources(SiteRenderingContext siteRenderingContext, File outputDirectory) throws IOException;
/**
* Locate Doxia document source files in the site source context.
@@ -102,8 +99,8 @@ public interface Renderer // TODO rename to SiteRenderer
* @throws RendererException if it bombs.
* @since 1.8
*/
- Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext, boolean editable )
- throws IOException, RendererException;
+ Map<String, DocumentRenderer> locateDocumentFiles(SiteRenderingContext siteRenderingContext, boolean editable)
+ throws IOException, RendererException;
/**
* Render a document written in a Doxia markup language. This method is an internal method, used by
@@ -116,6 +113,6 @@ public interface Renderer // TODO rename to SiteRenderer
* @throws FileNotFoundException if it bombs.
* @throws UnsupportedEncodingException if it bombs.
*/
- void renderDocument( Writer writer, RenderingContext docRenderingContext, SiteRenderingContext siteContext )
- throws RendererException, FileNotFoundException, UnsupportedEncodingException;
+ void renderDocument(Writer writer, RenderingContext docRenderingContext, SiteRenderingContext siteContext)
+ throws RendererException, FileNotFoundException, UnsupportedEncodingException;
}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RendererException.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RendererException.java
index b664eaa..0e6f305 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RendererException.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RendererException.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,15 +16,14 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
/**
* <p>RendererException class.</p>
*
* @author Emmanuel Venisse
*/
-public class RendererException
- extends Exception
-{
+public class RendererException extends Exception {
private static final long serialVersionUID = 3141592653589793238L;
@@ -35,9 +32,8 @@ public class RendererException
*
* @param message a custom message.
*/
- public RendererException( String message )
- {
- super( message );
+ public RendererException(String message) {
+ super(message);
}
/**
@@ -46,8 +42,7 @@ public class RendererException
* @param message a custom message.
* @param t the cause.
*/
- public RendererException( String message, Throwable t )
- {
- super( message, t );
+ public RendererException(String message, Throwable t) {
+ super(message, t);
}
}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
index aa7cdaa..0c31c1d 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import java.io.File;
import java.util.HashMap;
@@ -34,7 +33,7 @@ import org.codehaus.plexus.util.StringUtils;
* @since 1.5 (was since 1.1 in o.a.m.d.sink.render)
*/
public class RenderingContext // TODO rename to DocumentRenderingContext
-{
+ {
private final File basedir;
private final String basedirRelativePath;
@@ -66,15 +65,18 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @param generator the generator (in general a reporting goal: <code>groupId:artifactId:version:goal</code>)
* @since 1.8
*/
- public RenderingContext( File basedir, String document, String generator )
- {
- this( basedir, null, document, null, null, false, generator );
+ public RenderingContext(File basedir, String document, String generator) {
+ this(basedir, null, document, null, null, false, generator);
}
- public RenderingContext( File basedir, String basedirRelativePath, String document, String parserId,
- String extension, boolean editable )
- {
- this( basedir, basedirRelativePath, document, parserId, extension, editable, null );
+ public RenderingContext(
+ File basedir,
+ String basedirRelativePath,
+ String document,
+ String parserId,
+ String extension,
+ boolean editable) {
+ this(basedir, basedirRelativePath, document, parserId, extension, editable, null);
}
/**
@@ -93,9 +95,14 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @param generator the generator (in general a reporting goal: <code>groupId:artifactId:version:goal</code>)
* @since 1.8
*/
- public RenderingContext( File basedir, String basedirRelativePath, String document, String parserId,
- String extension, boolean editable, String generator )
- {
+ public RenderingContext(
+ File basedir,
+ String basedirRelativePath,
+ String document,
+ String parserId,
+ String extension,
+ boolean editable,
+ String generator) {
this.basedir = basedir;
this.basedirRelativePath = basedirRelativePath;
this.inputName = document;
@@ -104,8 +111,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
this.generator = generator;
this.attributes = new HashMap<String, String>();
- if ( StringUtils.isNotEmpty( extension ) )
- {
+ if (StringUtils.isNotEmpty(extension)) {
// document comes from a Doxia source: see DoxiaDocumentRenderer
this.editable = editable;
@@ -113,22 +119,19 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
// - index.xml -> index.html
// - index.xml.vm -> index.html
// - download.apt.vm --> download.html
- if ( DefaultSiteRenderer.endsWithIgnoreCase( document, ".vm" ) )
- {
- document = document.substring( 0, document.length() - 3 );
+ if (DefaultSiteRenderer.endsWithIgnoreCase(document, ".vm")) {
+ document = document.substring(0, document.length() - 3);
}
- String fileNameWithoutExt = document.substring( 0, document.length() - extension.length() - 1 );
+ String fileNameWithoutExt = document.substring(0, document.length() - extension.length() - 1);
this.outputName = fileNameWithoutExt + ".html";
- }
- else
- {
+ } else {
// document does not come from a Doxia source but direct Sink API
this.editable = false;
// make sure output name ends in .html
- this.outputName = document.substring( 0, document.lastIndexOf( '.' ) ).replace( '\\', '/' ) + ".html";
+ this.outputName = document.substring(0, document.lastIndexOf('.')).replace('\\', '/') + ".html";
}
- this.relativePath = PathTool.getRelativePath( basedir.getPath(), new File( basedir, inputName ).getPath() );
+ this.relativePath = PathTool.getRelativePath(basedir.getPath(), new File(basedir, inputName).getPath());
}
/**
@@ -136,8 +139,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
*
* @return a {@link java.io.File} object.
*/
- public File getBasedir()
- {
+ public File getBasedir() {
return basedir;
}
@@ -146,8 +148,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
*
* @return a {@link java.lang.String} object.
*/
- public String getInputName()
- {
+ public String getInputName() {
return inputName;
}
@@ -157,8 +158,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @return html output name
* @see PathTool#getRelativePath(String)
*/
- public String getOutputName()
- {
+ public String getOutputName() {
return outputName;
}
@@ -167,8 +167,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
*
* @return parser id, or <code>null</code> if not froma DOxia source.
*/
- public String getParserId()
- {
+ public String getParserId() {
return parserId;
}
@@ -177,8 +176,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
*
* @return the relative path to site root
*/
- public String getRelativePath()
- {
+ public String getRelativePath() {
return relativePath;
}
@@ -188,9 +186,8 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @param key a {@link java.lang.String} object.
* @param value a {@link java.lang.String} object.
*/
- public void setAttribute( String key, String value )
- {
- attributes.put( key, value );
+ public void setAttribute(String key, String value) {
+ attributes.put(key, value);
}
/**
@@ -199,9 +196,8 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @param key a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
*/
- public String getAttribute( String key )
- {
- return attributes.get( key );
+ public String getAttribute(String key) {
+ return attributes.get(key);
}
/**
@@ -209,8 +205,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
*
* @return the source document filename extension when a Doxia source, or <code>null</code> if not a Doxia source
*/
- public String getExtension()
- {
+ public String getExtension() {
return extension;
}
@@ -220,8 +215,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @return <code>true</code> if comes from an editable Doxia source (not generated one).
* @since 1.8
*/
- public boolean isEditable()
- {
+ public boolean isEditable() {
return editable;
}
@@ -231,9 +225,8 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @return <code>true</code> if comes from a Doxia source.
* @since 1.8
*/
- public boolean isDoxiaSource()
- {
- return StringUtils.isNotEmpty( extension );
+ public boolean isDoxiaSource() {
+ return StringUtils.isNotEmpty(extension);
}
/**
@@ -242,8 +235,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @return <code>null</code> if no known generator
* @since 1.8
*/
- public String getGenerator()
- {
+ public String getGenerator() {
return generator;
}
@@ -253,8 +245,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @return the relative path of basedir when a Doxia source, or <code>null</code> if not a Doxia source
* @since 1.8
*/
- public String getBasedirRelativePath()
- {
+ public String getBasedirRelativePath() {
return basedirRelativePath;
}
@@ -264,9 +255,8 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @return the relative path to Doxia source from build root, or <code>null</code> if not a Doxia source
* @since 1.8
*/
- public String getDoxiaSourcePath()
- {
- return isDoxiaSource() ? ( basedirRelativePath + '/' + inputName ) : null;
+ public String getDoxiaSourcePath() {
+ return isDoxiaSource() ? (basedirRelativePath + '/' + inputName) : null;
}
/**
@@ -276,8 +266,7 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
* @return the resulting url
* @since 1.8
*/
- public String getDoxiaSourcePath( String base )
- {
- return PathTool.calculateLink( getDoxiaSourcePath(), base );
+ public String getDoxiaSourcePath(String base) {
+ return PathTool.calculateLink(getDoxiaSourcePath(), base);
}
}
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
index 0e8e8dd..9165901 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
@@ -1,5 +1,3 @@
-package org.apache.maven.doxia.siterenderer;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.doxia.siterenderer;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.doxia.siterenderer;
import java.io.File;
import java.util.ArrayList;
@@ -38,8 +37,7 @@ import org.codehaus.plexus.util.WriterFactory;
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
-public class SiteRenderingContext
-{
+public class SiteRenderingContext {
private String inputEncoding = ReaderFactory.FILE_ENCODING;
private String outputEncoding = WriterFactory.UTF_8;
@@ -84,8 +82,7 @@ public class SiteRenderingContext
* @return true if validation is switched on.
* @since 1.1.3
*/
- public boolean isValidate()
- {
+ public boolean isValidate() {
return validate;
}
@@ -95,8 +92,7 @@ public class SiteRenderingContext
* @param validate true to switch on validation.
* @since 1.1.3
*/
- public void setValidate( boolean validate )
- {
+ public void setValidate(boolean validate) {
this.validate = validate;
}
@@ -105,8 +101,7 @@ public class SiteRenderingContext
*
* @return a {@link java.lang.String} object.
*/
- public String getTemplateName()
- {
+ public String getTemplateName() {
return templateName;
}
@@ -115,8 +110,7 @@ public class SiteRenderingContext
*
* @return a {@link java.lang.ClassLoader} object.
*/
- public ClassLoader getTemplateClassLoader()
- {
+ public ClassLoader getTemplateClassLoader() {
return templateClassLoader;
}
@@ -125,8 +119,7 @@ public class SiteRenderingContext
*
* @param templateClassLoader a {@link java.lang.ClassLoader} object.
*/
- public void setTemplateClassLoader( ClassLoader templateClassLoader )
- {
+ public void setTemplateClassLoader(ClassLoader templateClassLoader) {
this.templateClassLoader = templateClassLoader;
}
@@ -135,8 +128,7 @@ public class SiteRenderingContext
*
* @return a {@link java.util.Map} object.
*/
- public Map<String, ?> getTemplateProperties()
- {
+ public Map<String, ?> getTemplateProperties() {
return templateProperties;
}
@@ -145,9 +137,8 @@ public class SiteRenderingContext
*
* @param templateProperties a {@link java.util.Map} object.
*/
- public void setTemplateProperties( Map<String, ?> templateProperties )
- {
- this.templateProperties = Collections.unmodifiableMap( templateProperties );
+ public void setTemplateProperties(Map<String, ?> templateProperties) {
+ this.templateProperties = Collections.unmodifiableMap(templateProperties);
}
/**
@@ -155,8 +146,7 @@ public class SiteRenderingContext
*
* @return a {@link java.util.Locale} object.
*/
- public Locale getLocale()
- {
+ public Locale getLocale() {
return locale;
}
@@ -165,30 +155,27 @@ public class SiteRenderingContext
*
* @param locale a {@link java.util.Locale} object.
*/
- public void setLocale( Locale locale )
- {
+ public void setLocale(Locale locale) {
this.locale = locale;
}
- /**
+ /**
* <p>Getter for the field <code>siteLocales</code> -
* a list of locales available for this site context.</p>
*
* @return a {@link java.util.List} object with {@link java.util.Locale} objects.
*/
- public List<Locale> getSiteLocales()
- {
+ public List<Locale> getSiteLocales() {
return siteLocales;
}
- /**
- * <p>Adds passed locales to the list of site locales.</p>
- *
- * @param locales List of {@link java.util.Locale} objects to add to the site locales list.
- */
- public void addSiteLocales( List<Locale> locales )
- {
- siteLocales.addAll( locales );
+ /**
+ * <p>Adds passed locales to the list of site locales.</p>
+ *
+ * @param locales List of {@link java.util.Locale} objects to add to the site locales list.
+ */
+ public void addSiteLocales(List<Locale> locales) {
+ siteLocales.addAll(locales);
}
/**
@@ -196,8 +183,7 @@ public class SiteRenderingContext
*
* @return a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object.
*/
- public DecorationModel getDecoration()
- {
+ public DecorationModel getDecoration() {
return decoration;
}
@@ -206,8 +192,7 @@ public class SiteRenderingContext
*
* @param decoration a {@link org.apache.maven.doxia.site.decoration.DecorationModel} object.
*/
- public void setDecoration( DecorationModel decoration )
- {
+ public void setDecoration(DecorationModel decoration) {
this.decoration = decoration;
}
@@ -215,9 +200,8 @@ public class SiteRenderingContext
* @deprecated use {@link #setDefaultTitle(String)}
*/
@Deprecated
- public void setDefaultWindowTitle( String defaultWindowsTitle )
- {
- setDefaultTitle( defaultWindowsTitle );
+ public void setDefaultWindowTitle(String defaultWindowsTitle) {
+ setDefaultTitle(defaultWindowsTitle);
}
/**
@@ -225,8 +209,7 @@ public class SiteRenderingContext
*
* @param defaultTitle a {@link java.lang.String} object.
*/
- public void setDefaultTitle( String defaultTitle )
- {
+ public void setDefaultTitle(String defaultTitle) {
this.defaultTitle = defaultTitle;
}
@@ -234,8 +217,7 @@ public class SiteRenderingContext
* @deprecated use {@link #getDefaultTitle()}
*/
@Deprecated
- public String getDefaultWindowTitle()
- {
+ public String getDefaultWindowTitle() {
return getDefaultTitle();
}
@@ -244,8 +226,7 @@ public class SiteRenderingContext
*
* @return a {@link java.lang.String} object.
*/
- public String getDefaultTitle()
- {
+ public String getDefaultTitle() {
return defaultTitle;
}
@@ -254,8 +235,7 @@ public class SiteRenderingContext
*
* @return a {@link Artifact} object.
*/
- public Artifact getSkin()
- {
+ public Artifact getSkin() {
return skin;
}
@@ -264,8 +244,7 @@ public class SiteRenderingContext
*
* @param skin an {@link Artifact} object.
*/
- public void setSkin( Artifact skin )
- {
+ public void setSkin(Artifact skin) {
this.skin = skin;
}
@@ -274,8 +253,7 @@ public class SiteRenderingContext
*
* @return a {@link SkinModel} object.
*/
- public SkinModel getSkinModel()
- {
+ public SkinModel getSkinModel() {
return skinModel;
}
@@ -284,8 +262,7 @@ public class SiteRenderingContext
*
* @param skinModel a {@link SkinModel} object.
*/
- public void setSkinModel( SkinModel skinModel )
- {
+ public void setSkinModel(SkinModel skinModel) {
this.skinModel = skinModel;
}
@@ -294,8 +271,7 @@ public class SiteRenderingContext
*
* @param templateName a {@link java.lang.String} object.
*/
- public void setTemplateName( String templateName )
- {
+ public void setTemplateName(String templateName) {
this.templateName = templateName;
}
@@ -305,9 +281,8 @@ public class SiteRenderingContext
*
* @param siteDirectory a {@link java.io.File} object.
*/
- public void addSiteDirectory( File siteDirectory )
- {
- this.siteDirectories.add( siteDirectory );
+ public void addSiteDirectory(File siteDirectory) {
+ this.siteDirectories.add(siteDirectory);
}
/**
@@ -318,9 +293,8 @@ public class SiteRenderingContext
* @param moduleParserId module's Doxia parser id.
*/
@Deprecated
- public void addModuleDirectory( File moduleBasedir, String moduleParserId )
- {
- this.modules.add( new ExtraDoxiaModuleReference( moduleParserId, moduleBasedir ) );
+ public void addModuleDirectory(File moduleBasedir, String moduleParserId) {
+ this.modules.add(new ExtraDoxiaModuleReference(moduleParserId, moduleBasedir));
}
/**
@@ -328,8 +302,7 @@ public class SiteRenderingContext
*
* @return List of site directories files.
*/
- public List<File> getSiteDirectories()
- {
+ public List<File> getSiteDirectories() {
return siteDirectories;
}
@@ -339,8 +312,7 @@ public class SiteRenderingContext
* @return a {@link java.util.List} object.
*/
@Deprecated
- public List<ExtraDoxiaModuleReference> getModules()
- {
+ public List<ExtraDoxiaModuleReference> getModules() {
return modules;
}
@@ -349,8 +321,7 @@ public class SiteRenderingContext
*
* @return a map defining exclude patterns (comma separated) by parser id.
*/
- public Map<String, String> getModuleExcludes()
- {
+ public Map<String, String> getModuleExcludes() {
return moduleExcludes;
}
@@ -359,8 +330,7 @@ public class SiteRenderingContext
*
* @param moduleExcludes a {@link java.util.Map} object.
*/
- public void setModuleExcludes( Map<String, String> moduleExcludes )
- {
+ public void setModuleExcludes(Map<String, String> moduleExcludes) {
this.moduleExcludes = moduleExcludes;
}
@@ -369,8 +339,7 @@ public class SiteRenderingContext
*
* @return a {@link java.lang.String} object.
*/
- public String getInputEncoding()
- {
+ public String getInputEncoding() {
return inputEncoding;
}
@@ -379,8 +348,7 @@ public class SiteRenderingContext
*
* @param inputEncoding a {@link java.lang.String} object.
*/
- public void setInputEncoding( String inputEncoding )
- {
+ public void setInputEncoding(String inputEncoding) {
this.inputEncoding = inputEncoding;
}
@@ -389,8 +357,7 @@ public class SiteRenderingContext
*
* @return a {@link java.lang.String} object.
*/
- public String getOutputEncoding()
- {
+ public String getOutputEncoding() {
return outputEncoding;
}
@@ -399,8 +366,7 @@ public class SiteRenderingContext
*
* @param outputEncoding a {@link java.lang.String} object.
*/
- public void setOutputEncoding( String outputEncoding )
- {
+ public void setOutputEncoding(String outputEncoding) {
this.outputEncoding = outputEncoding;
}
@@ -409,8 +375,7 @@ public class SiteRenderingContext
*
* @return the publish date, can be {@code null}
*/
- public Date getPublishDate()
- {
+ public Date getPublishDate() {
return publishDate;
}
@@ -419,8 +384,7 @@ public class SiteRenderingContext
*
* @param publishDate the publish date
*/
- public void setPublishDate( Date publishDate )
- {
+ public void setPublishDate(Date publishDate) {
this.publishDate = publishDate;
}
@@ -430,8 +394,7 @@ public class SiteRenderingContext
* @return not null if the documents are to be saved
* @since 1.7
*/
- public File getProcessedContentOutput()
- {
+ public File getProcessedContentOutput() {
return processedContentOutput;
}
@@ -442,8 +405,7 @@ public class SiteRenderingContext
* @param processedContentOutput not null if the documents are to be saved
* @since 1.7
*/
- public void setProcessedContentOutput( File processedContentOutput )
- {
+ public void setProcessedContentOutput(File processedContentOutput) {
this.processedContentOutput = processedContentOutput;
}
@@ -454,8 +416,7 @@ public class SiteRenderingContext
* @return the root directory
* @since 1.8
*/
- public File getRootDirectory()
- {
+ public File getRootDirectory() {
return rootDirectory;
}
... 2849 lines suppressed ...