Allow user to change the template

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@179471 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-06-02 00:23:46 +00:00
parent a1d0973a13
commit 0ce22ce966
1 changed files with 31 additions and 3 deletions

View File

@ -39,6 +39,9 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.LineNumberReader; import java.io.LineNumberReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -87,12 +90,17 @@ public class DoxiaMojo
private File resourcesDirectory; private File resourcesDirectory;
/** /**
* @parameterX expression="${template} * @parameter expression="${templateDirectory}
*/
private String templateDirectory;
/**
* @parameter expression="${template}
*/ */
private String template = DEFAULT_TEMPLATE; private String template = DEFAULT_TEMPLATE;
/** /**
* @parameterX expression="${attributes} * @parameter expression="${attributes}
*/ */
private Map attributes; private Map attributes;
@ -138,7 +146,27 @@ public class DoxiaMojo
public void execute() public void execute()
throws MojoExecutionException 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 try
{ {