From 0ce22ce966e21d8e054a575582aad851068da5d3 Mon Sep 17 00:00:00 2001 From: Emmanuel Venisse Date: Thu, 2 Jun 2005 00:23:46 +0000 Subject: [PATCH] Allow user to change the template git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@179471 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/doxia/DoxiaMojo.java | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java index f852bd17d1..48417df834 100644 --- a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java +++ b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java @@ -39,6 +39,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.LineNumberReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -87,12 +90,17 @@ public class DoxiaMojo private File resourcesDirectory; /** - * @parameterX expression="${template} + * @parameter expression="${templateDirectory} + */ + private String templateDirectory; + + /** + * @parameter expression="${template} */ private String template = DEFAULT_TEMPLATE; /** - * @parameterX expression="${attributes} + * @parameter expression="${attributes} */ private Map attributes; @@ -138,7 +146,27 @@ public class DoxiaMojo public void execute() throws MojoExecutionException { - siteRenderer.setTemplateClassLoader( DoxiaMojo.class.getClassLoader() ); + if ( templateDirectory == null ) + { + siteRenderer.setTemplateClassLoader( DoxiaMojo.class.getClassLoader() ); + } + else + { + try + { + URL templateDirectoryUrl = new URL( templateDirectory ); + + URL[] urls = { templateDirectoryUrl }; + + URLClassLoader urlClassloader = new URLClassLoader( urls ); + + siteRenderer.setTemplateClassLoader( urlClassloader ); + } + catch( MalformedURLException e ) + { + throw new MojoExecutionException( templateDirectory + " isn't a valid URL." ); + } + } try {