You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/09/30 08:15:57 UTC
svn commit: r292641 - in /maven/jxr/trunk: ./
src/main/java/org/apache/maven/jxr/ src/main/java/org/apache/maven/jxr/ant/
src/main/java/org/apache/maven/jxr/log/
src/main/java/org/apache/maven/jxr/pacman/ src/main/resources/
src/main/resources/template...
Author: brett
Date: Thu Sep 29 23:15:37 2005
New Revision: 292641
URL: http://svn.apache.org/viewcvs?rev=292641&view=rev
Log:
o switch to Velocity (thanks to Fabrice Bellingard)
o clean up
o encapsulate API in JXR class, remove extra bean
Added:
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrException.java (with props)
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/Log.java (with props)
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/VelocityLogger.java (with props)
maven/jxr/trunk/src/main/resources/
maven/jxr/trunk/src/main/resources/jxr-report.properties (with props)
maven/jxr/trunk/src/main/resources/jxr-report_fr.properties (with props)
maven/jxr/trunk/src/main/resources/templates/
maven/jxr/trunk/src/main/resources/templates/allclasses-frame.vm
maven/jxr/trunk/src/main/resources/templates/index.vm
maven/jxr/trunk/src/main/resources/templates/overview-frame.vm
maven/jxr/trunk/src/main/resources/templates/overview-summary.vm
maven/jxr/trunk/src/main/resources/templates/package-frame.vm
maven/jxr/trunk/src/main/resources/templates/package-summary.vm
maven/jxr/trunk/src/test/java/org/apache/maven/jxr/DummyLog.java (with props)
Removed:
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrBean.java
Modified:
maven/jxr/trunk/ (props changed)
maven/jxr/trunk/pom.xml
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java
maven/jxr/trunk/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java
maven/jxr/trunk/src/test/java/org/apache/maven/jxr/CodeTransformTest.java
maven/jxr/trunk/src/test/java/org/apache/maven/jxr/JxrBeanTest.java
Propchange: maven/jxr/trunk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Sep 29 23:15:37 2005
@@ -0,0 +1,4 @@
+target
+*.ipr
+*.iml
+*.iws
Modified: maven/jxr/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/pom.xml?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/pom.xml (original)
+++ maven/jxr/trunk/pom.xml Thu Sep 29 23:15:37 2005
@@ -109,43 +109,39 @@
<timezone>+10</timezone>
</developer>
</developers>
+ <contributors>
+ <contributor>
+ <name>Fabrice Bellingard</name>
+ <email>bellingard@gmail.com</email>
+ <timezone>+1</timezone>
+ </contributor>
+ </contributors>
<dependencies>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.7</version>
</dependency>
- <!-- TODO: remove these -->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <!-- TODO: remove this -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.5</version>
- </dependency>
- <dependency>
- <groupId>commons-jelly</groupId>
- <artifactId>commons-jelly</artifactId>
- <version>1.0</version>
- <exclusions>
- <exclusion>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6</version>
+ <groupId>plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.0.3</version>
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.0</version>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/CodeTransform.java Thu Sep 29 23:15:37 2005
@@ -30,7 +30,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.apache.commons.lang.StringUtils;
import org.apache.maven.jxr.pacman.ClassType;
import org.apache.maven.jxr.pacman.FileManager;
import org.apache.maven.jxr.pacman.ImportType;
@@ -39,11 +38,11 @@
import org.apache.maven.jxr.pacman.PackageType;
import org.apache.maven.jxr.util.SimpleWordTokenizer;
import org.apache.maven.jxr.util.StringEntry;
+import org.codehaus.plexus.util.StringUtils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
@@ -57,6 +56,7 @@
import java.io.Serializable;
import java.io.Writer;
import java.util.Hashtable;
+import java.util.Locale;
import java.util.Vector;
/**
@@ -195,7 +195,7 @@
private String outputEncoding = null;
- private String lang = null;
+ private Locale locale = null;
/**
* Relative path to javadocs, suitable for hyperlinking
@@ -207,6 +207,8 @@
*/
private PackageManager packageManager;
+ private FileManager fileManager;
+
/**
* Constructor for the CodeTransform object
*
@@ -216,6 +218,7 @@
{
this.packageManager = packageManager;
loadHash();
+ this.fileManager = packageManager.getFileManager();
}
/**
@@ -494,11 +497,8 @@
int i = 0;
while ( ( i = line.indexOf( oldString, i ) ) >= 0 )
{
- line = ( new StringBuffer()
- .append( line.substring( 0, i ) )
- .append( newString )
- .append( line.substring( i + oldString.length() ) ) )
- .toString();
+ line = ( new StringBuffer().append( line.substring( 0, i ) ).append( newString ).append(
+ line.substring( i + oldString.length() ) ) ).toString();
i += newString.length();
}
return line;
@@ -630,11 +630,6 @@
{
StringBuffer buffer = new StringBuffer();
- String lang = this.lang;
- if ( lang == null )
- {
- lang = "en";
- }
String outputEncoding = this.outputEncoding;
if ( outputEncoding == null )
{
@@ -645,19 +640,16 @@
buffer
.append(
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" )
- .append( "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"" ).append( lang ).append(
- "\" lang=\"" ).append( lang ).append( "\">\n" )
- .append( "<head>\n" )
- .append( "<meta http-equiv=\"content-type\" content=\"text/html; charset=" ).append(
- outputEncoding ).append( "\" />" );
+ .append( "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"" ).append( locale )
+ .append( "\" lang=\"" ).append( locale ).append( "\">\n" ).append( "<head>\n" )
+ .append( "<meta http-equiv=\"content-type\" content=\"text/html; charset=" ).append( outputEncoding )
+ .append( "\" />" );
// title ("classname xref")
try
{
- buffer
- .append( "<title>" )
- .append( FileManager.getInstance().getFile( this.getCurrentFilename() ).getClassType().getName() )
- .append( " xref</title>\n" );
+ buffer.append( "<title>" ).append( fileManager.getFile( this.getCurrentFilename() )
+ .getClassType().getName() ).append( " xref</title>\n" );
}
catch ( IOException e )
@@ -667,11 +659,8 @@
}
// stylesheet link
- buffer
- .append( "<link type=\"text/css\" rel=\"stylesheet\" href=\"" )
- .append( this.getPackageRoot() )
- .append( STYLESHEET_FILENAME )
- .append( "\" />\n" );
+ buffer.append( "<link type=\"text/css\" rel=\"stylesheet\" href=\"" ).append( this.getPackageRoot() )
+ .append( STYLESHEET_FILENAME ).append( "\" />\n" );
buffer.append( "</head>\n" ).append( "<body>\n" ).append( this.getFileOverview() );
@@ -696,14 +685,14 @@
*
* @param sourcefile String
* @param destfile String
- * @param lang String
+ * @param locale String
* @param inputEncoding String
* @param outputEncoding String
* @param javadocLinkDir String
* @param revision String
* @throws IOException
*/
- public final void transform( String sourcefile, String destfile, String lang, String inputEncoding,
+ public final void transform( String sourcefile, String destfile, Locale locale, String inputEncoding,
String outputEncoding, String javadocLinkDir, String revision )
throws IOException
{
@@ -712,7 +701,7 @@
this.sourcefile = sourcefile;
this.destfile = destfile;
- this.lang = lang;
+ this.locale = locale;
this.inputEncoding = inputEncoding;
this.outputEncoding = outputEncoding;
this.javadocLinkDir = javadocLinkDir;
@@ -766,15 +755,9 @@
out.println( getFooter() );
out.flush();
}
- catch ( FileNotFoundException e )
- {
- System.out.println(
- "IGNORING: FileNotFoundException - file is probably in use by another process! Unable to process " +
- sourcefile + " => " + destfile );
- }
catch ( RuntimeException e )
{
- System.out.println( "Unable to process " + sourcefile + " => " + destfile );
+ System.out.println( "Unable to processPath " + sourcefile + " => " + destfile );
throw e;
}
finally
@@ -824,7 +807,7 @@
try
{
- JavaFile jf = FileManager.getInstance().getFile( this.getCurrentFilename() );
+ JavaFile jf = fileManager.getFile( this.getCurrentFilename() );
javadocURI.append( StringUtils.replace( jf.getPackageType().getName(), ".", "/" ) );
javadocURI.append( "/" );
@@ -898,7 +881,7 @@
return line;
}
- jf = FileManager.getInstance().getFile( this.getCurrentFilename() );
+ jf = fileManager.getFile( this.getCurrentFilename() );
}
catch ( IOException e )
{
@@ -1129,12 +1112,12 @@
int start = -1;
/*
- Used for determining if this is a package declaration. If it is
- then we can make some additional assumptions:
- - that this isn't a Class import so the full String is valid
- - that it WILL be on the disk since this is based on the current
- - file.
- */
+ Used for determining if this is a package declaration. If it is
+ then we can make some additional assumptions:
+ - that this isn't a Class import so the full String is valid
+ - that it WILL be on the disk since this is based on the current
+ - file.
+ */
boolean isPackage = line.trim().startsWith( "package " );
boolean isImport = line.trim().startsWith( "import " );
@@ -1235,7 +1218,7 @@
try
{
- jf = FileManager.getInstance().getFile( this.getCurrentFilename() );
+ jf = fileManager.getFile( this.getCurrentFilename() );
}
catch ( IOException e )
{
@@ -1452,4 +1435,4 @@
return StringUtils.replace( line, find, link );
}
-}
+}
\ No newline at end of file
Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/DirectoryIndexer.java Thu Sep 29 23:15:37 2005
@@ -17,17 +17,23 @@
* ====================================================================
*/
-import org.apache.commons.jelly.JellyContext;
-import org.apache.commons.jelly.XMLOutput;
import org.apache.maven.jxr.pacman.ClassType;
import org.apache.maven.jxr.pacman.PackageManager;
import org.apache.maven.jxr.pacman.PackageType;
+import org.apache.maven.jxr.log.VelocityLogger;
+import org.apache.maven.jxr.log.Log;
import org.apache.oro.text.perl.Perl5Util;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.app.VelocityEngine;
+import org.codehaus.plexus.util.IOUtil;
import java.io.File;
-import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.IOException;
-import java.io.OutputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -52,6 +58,7 @@
* </ul>
* </ul>
*
+ * @author <a href="mailto:bellingard@gmail.com">Fabrice Bellingard </a>
* @author <a href="mailto:brian@brainslug.org">Brian Leonard</a>
* @version $Id$
*/
@@ -74,8 +81,8 @@
private PackageManager packageManager;
/*
- * see the getter/setter docs for these properties
- */
+ * see the getter/setter docs for these properties
+ */
private String outputEncoding;
private String templateDir;
@@ -86,7 +93,6 @@
private String bottom;
-
/**
* Constructor for the DirectoryIndexer object
*
@@ -111,8 +117,6 @@
/**
* see setOutputEncoding(String)
- *
- * @see setOutputEncoding(String)
*/
public String getOutputEncoding()
{
@@ -132,8 +136,6 @@
/**
* see setTemplateDir(String)
- *
- * @see setTemplateDir(String)
*/
public String getTemplateDir()
{
@@ -206,107 +208,132 @@
/**
* Does the actual indexing.
*
- * @throws Exception If something went wrong with jelly's processing.
+ * @throws JxrException If something went wrong
*/
- public void process()
- throws Exception
+ public void process( Log log )
+ throws JxrException
{
Map info = getPackageInfo();
- JellyContext mainContext = new JellyContext();
- mainContext.setVariable( "outputEncoding", getOutputEncoding() );
- mainContext.setVariable( "windowTitle", getWindowTitle() );
- mainContext.setVariable( "docTitle", getDocTitle() );
- mainContext.setVariable( "bottom", getBottom() );
- mainContext.setVariable( "info", info );
-
- doJellyFile( "index", root, mainContext );
- doJellyFile( "overview-frame", root, mainContext );
- doJellyFile( "allclasses-frame", root, mainContext );
- doJellyFile( "overview-summary", root, mainContext );
+ VelocityEngine engine = new VelocityEngine();
+ setProperties( engine, log );
+ try
+ {
+ engine.init();
+ }
+ catch ( Exception e )
+ {
+ throw new JxrException( "Error initialising Velocity", e );
+ }
+
+ VelocityContext context = new VelocityContext();
+ context.put( "outputEncoding", getOutputEncoding() );
+ context.put( "windowTitle", getWindowTitle() );
+ context.put( "docTitle", getDocTitle() );
+ context.put( "bottom", getBottom() );
+ context.put( "info", info );
+
+ doVelocity( "index", root, context, engine );
+ doVelocity( "overview-frame", root, context, engine );
+ doVelocity( "allclasses-frame", root, context, engine );
+ doVelocity( "overview-summary", root, context, engine );
Iterator iter = ( (Map) info.get( "allPackages" ) ).values().iterator();
while ( iter.hasNext() )
{
Map pkgInfo = (Map) iter.next();
- JellyContext subContext = mainContext.newJellyContext();
- subContext.setVariable( "pkgInfo", pkgInfo );
+ VelocityContext subContext = new VelocityContext( context );
+ subContext.put( "pkgInfo", pkgInfo );
String outDir = root + "/" + (String) pkgInfo.get( "dir" );
- doJellyFile( "package-summary", outDir, subContext );
- doJellyFile( "package-frame", outDir, subContext );
+ doVelocity( "package-summary", outDir, subContext, engine );
+ doVelocity( "package-frame", outDir, subContext, engine );
}
}
/*
- * executes a given jelly file with the given context and places the
- * generated file in outDir. File names are assumed to be
- * {templateName}.jelly for input and {templateName}.html for output
- *
+ * Set Velocity properties to find templates
*/
- private void doJellyFile( String templateName, String outDir, JellyContext context )
- throws Exception
+ private void setProperties( VelocityEngine engine, Log log )
{
- String outFile = outDir + "/" + templateName + ".html";
- OutputStream out = null;
- try
+ File templateDirFile = new File( getTemplateDir() );
+ if ( templateDirFile.isAbsolute() )
{
- // Throws FileNotFoundException
- out = new FileOutputStream( outFile );
+ // the property has been overriden: need to use a FileResourceLoader
+ engine.setProperty( "resource.loader", "file" );
+ engine.setProperty( "file.resource.loader.class",
+ "org.apache.velocity.runtime.resource.loader.FileResourceLoader" );
+ engine.setProperty( "file.resource.loader.path", templateDirFile.toString() );
+ }
+ else
+ {
+ // use of the default templates
+ engine.setProperty( "resource.loader", "classpath" );
+ engine.setProperty( "classpath.resource.loader.class",
+ "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader" );
+ }
+ engine.setProperty( Log.class.getName(), log );
+ engine.setProperty( "runtime.log.logsystem.class", VelocityLogger.class.getName() );
+ }
- String templateFileName = getTemplateDir() + "/" + templateName + ".jelly";
- File templateFile = new File( templateFileName );
+ /*
+ * Generate the HTML file according to the Velocity template
+ */
+ private void doVelocity( String templateName, String outDir, VelocityContext context, VelocityEngine engine )
+ throws JxrException
+ {
+ // output file
+ File file = new File( outDir, templateName + ".html" );
+ file.getParentFile().mkdirs();
+ FileWriter writer = null;
+
+ try
+ {
+ writer = new FileWriter( file );
- File theFile = new File( outFile );
- File dir = theFile.getParentFile();
- if ( dir != null )
+ // template file
+ StringBuffer templateFile = new StringBuffer();
+ File templateDirFile = new File( getTemplateDir() );
+ if ( !templateDirFile.isAbsolute() )
{
- dir.mkdirs();
+ // default templates
+ templateFile.append( getTemplateDir() );
+ templateFile.append( "/" );
}
-
- XMLOutput xmlOutput = XMLOutput.createXMLOutput( out, false );
- context.runScript( templateFile, xmlOutput );
- xmlOutput.flush();
+ templateFile.append( templateName );
+ templateFile.append( ".vm" );
+ Template template = engine.getTemplate( templateFile.toString() );
+
+ // do the merge
+ template.merge( context, writer );
+ writer.flush();
}
- catch ( Throwable e )
+ catch ( Exception e )
{
- System.out.println(
- "IGNORING: Failed to process file [" + outFile + "]. Closing streams and moving on. Exception: " + e );
+ throw new JxrException( "Error merging velocity template", e );
}
finally
{
- try
- {
- if ( out != null )
- {
- out.close();
- }
- }
- catch ( IOException e )
- {
- System.out.println( "Failed to close outputstream for file [" + outFile + "], which is a bad thing!" );
- throw e;
- }
+ IOUtil.close( writer );
}
}
-
/*
- * Creates a Map of other Maps containing information about
- * this project's packages and classes, obtained from the PackageManager.
- *
- * allPackages collection of Maps with package info, with the following format
- * {name} package name (e.g., "org.apache.maven.jxr")
- * {dir} package dir relative to the root output dir (e.g., "org/apache/maven/jxr")
- * {rootRef} relative link to root output dir (e.g., "../../../../") note trailing slash
- * {classes} collection of Maps with class info
- * {name} class name (e.g., "DirectoryIndexer")
- * {dir} duplicate of package {dir}
- *
- * allClasses collection of Maps with class info, format as above
- *
- */
+ * Creates a Map of other Maps containing information about
+ * this project's packages and classes, obtained from the PackageManager.
+ *
+ * allPackages collection of Maps with package info, with the following format
+ * {name} package name (e.g., "org.apache.maven.jxr")
+ * {dir} package dir relative to the root output dir (e.g., "org/apache/maven/jxr")
+ * {rootRef} relative link to root output dir (e.g., "../../../../") note trailing slash
+ * {classes} collection of Maps with class info
+ * {name} class name (e.g., "DirectoryIndexer")
+ * {dir} duplicate of package {dir}
+ *
+ * allClasses collection of Maps with class info, format as above
+ *
+ */
private Map getPackageInfo()
{
TreeMap allPackages = new TreeMap();
@@ -359,4 +386,4 @@
return info;
}
-}
+}
\ No newline at end of file
Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JXR.java Thu Sep 29 23:15:37 2005
@@ -17,13 +17,18 @@
* ====================================================================
*/
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.maven.jxr.ant.DirectoryScanner;
+import org.apache.maven.jxr.log.Log;
+import org.apache.maven.jxr.pacman.FileManager;
import org.apache.maven.jxr.pacman.PackageManager;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
/**
* Main entry point into Maven used to kick off the XReference code building.
@@ -36,25 +41,20 @@
/**
* Log.
*/
- private static final Log log = LogFactory.getLog( JxrBean.class );
+ private Log log;
/**
* Description of the Field
*/
- public final static String NOTICE = "This page was automatically generated by " +
+ public static final String NOTICE = "This page was automatically generated by " +
"<a href=\"http://maven.apache.org/\">Maven</a>";
/**
- * Path to all source.files
- */
- private String source = "";
-
- /**
* Path to destination
*/
private String dest = "";
- private String lang;
+ private Locale locale;
private String inputEncoding;
@@ -77,51 +77,28 @@
private String revision;
/**
- * The constructor for the JXR class.
- *
- * @param packageManager The Package Manager for this project
- * @param revision The CVS revision of this file.
- * @param source The directory that files are being read from (src/java)
- * @param source
- * @param dest
- */
- public JXR( PackageManager packageManager, String source, String dest, String lang, String inputEncoding,
- String outputEncoding, String javadocLinkDir, String revision )
- {
- this.transformer = new CodeTransform( packageManager );
- this.source = source;
- this.dest = dest;
- this.lang = lang;
- this.inputEncoding = inputEncoding;
- this.outputEncoding = outputEncoding;
- this.javadocLinkDir = javadocLinkDir;
- this.revision = revision;
-
- this.process();
- }
-
-
- /**
* Now that we have instantiated everythign. Process this JXR task.
*/
- private void process()
+ public void processPath( PackageManager packageManager, String source )
+ throws IOException
{
+ this.transformer = new CodeTransform( packageManager );
DirectoryScanner ds = new DirectoryScanner();
ds.addDefaultExcludes();
- File dir = new File( this.getSource() );
+ File dir = new File( source );
if ( !dir.exists() )
{
- if ( dir.mkdirs() == false )
+ if ( !dir.mkdirs() )
{
throw new IllegalStateException(
- "Your source directory does not exist and could not be created:" + this.getSource() );
+ "Your source directory does not exist and could not be created:" + source );
}
}
- ds.setBasedir( this.getSource() );
+ ds.setBasedir( source );
ds.scan();
//now get the list of included files
@@ -130,24 +107,13 @@
for ( int i = 0; i < files.length; ++i )
{
- if ( !updated( files[i] ) )
- {
- String source = this.getSource() + System.getProperty( "file.separator" ) + files[i];
-
- try
- {
-
- if ( isJavaFile( source ) )
- {
- transform( source, getDestination( source ) );
- }
+ String src = source + System.getProperty( "file.separator" ) + files[i];
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- }
+ if ( isJavaFile( source ) )
+ {
+ transform( src, getDestination( source, src ) );
}
+
}
}
@@ -182,17 +148,15 @@
* Given a filename get the destination on the filesystem of where to store
* the to be generated HTML file. Pay attention to the package name.
*
- * @param filename The name of the file to find
+ * @param source
+ * @param filename
* @return A String with the store destination.
*/
- private String getDestination( String filename )
+ private String getDestination( String source, String filename )
{
-
- String dest = new String( filename );
-
//remove the source directory from the filename.
- dest = dest.substring( this.getSource().length(), dest.length() );
+ String dest = filename.substring( source.length(), filename.length() );
int start = 0;
int end = dest.indexOf( ".java" );
@@ -224,48 +188,157 @@
private void transform( String source, String dest )
throws IOException
{
-
log.debug( source + " -> " + dest );
- transformer.transform( source, dest, lang, inputEncoding, outputEncoding, javadocLinkDir, this.revision );
-
+ // get a relative link to the javadocs
+ String javadocLinkDir = getRelativeLink( dest, this.javadocLinkDir );
+ transformer.transform( source, dest, locale, inputEncoding, outputEncoding, javadocLinkDir, this.revision );
}
/**
- * <p>
- *
- * Given a java source file determine if this needs updating. This is
- * determined by:</p>
- * <ul>
- * <li> The class doesn't exist in the destination directory</li>
- * <li> The file does exist in the destination directory but is older</li>
+ * Get the path to the destination files
*
- * </ul>
+ * @return The path to the destination files
*/
- private boolean updated( String file )
+ public String getDest()
{
- return false;
+ return this.dest;
}
- /**
- * Get the path to the source files
- *
- * @return The path to the source files
- */
- public String getSource()
+ public void setDest( String dest )
+ {
+ this.dest = dest;
+ }
+
+ public void setLocale( Locale locale )
+ {
+ this.locale = locale;
+ }
+
+ public void setInputEncoding( String inputEncoding )
{
- return this.source;
+ this.inputEncoding = inputEncoding;
+ }
+
+ public void setOutputEncoding( String outputEncoding )
+ {
+ this.outputEncoding = outputEncoding;
+ }
+
+ public void setJavadocLinkDir( String javadocLinkDir )
+ {
+ // get a relative link to the javadocs
+ this.javadocLinkDir = javadocLinkDir;
+ }
+
+ public void setTransformer( CodeTransform transformer )
+ {
+ this.transformer = transformer;
+ }
+
+ public void setRevision( String revision )
+ {
+ this.revision = revision;
+ }
+
+ public void setLog( Log log )
+ {
+ this.log = log;
}
/**
- * Get the path to the destination files
+ * Creates a relative link from one directory to another.
*
- * @return The path to the destination files
+ * Example:
+ * given /foo/bar/baz/oink
+ * and /foo/bar/schmoo
+ *
+ * this method will return a string of "../../schmoo/"
+ *
+ * @param fromDir The directory from which the link is relative.
+ * @param toDir The directory into which the link points.
+ * @return a string of format "../../schmoo/"
+ * @throws java.io.IOException If a problem is encountered while navigating through the directories.
*/
- public String getDest()
+ private static String getRelativeLink( String fromDir, String toDir )
+ throws IOException
{
- return this.dest;
+ StringBuffer toLink = new StringBuffer(); // up from fromDir
+ StringBuffer fromLink = new StringBuffer(); // down into toDir
+
+ // create a List of toDir's parent directories
+ List parents = new LinkedList();
+ File f = new File( toDir );
+ f = f.getCanonicalFile();
+ while ( f != null )
+ {
+ parents.add( f );
+ f = f.getParentFile();
+ }
+
+ // walk up fromDir to find the common parent
+ f = new File( fromDir );
+ f = f.getCanonicalFile();
+ f = f.getParentFile();
+ boolean found = false;
+ while ( f != null && !found )
+ {
+ for ( int i = 0; i < parents.size(); ++i )
+ {
+ File parent = (File) parents.get( i );
+ if ( f.equals( parent ) )
+ {
+ // when we find the common parent, add the subdirectories
+ // down to toDir itself
+ for ( int j = 0; j < i; ++j )
+ {
+ File p = (File) parents.get( j );
+ toLink.insert( 0, p.getName() + "/" );
+ }
+ found = true;
+ break;
+ }
+ }
+ f = f.getParentFile();
+ fromLink.append( "../" );
+ }
+
+ if ( !found )
+ {
+ throw new FileNotFoundException( fromDir + " and " + toDir + " have no common parent." );
+ }
+
+ return fromLink.append( toLink.toString() ).toString();
}
+ public void xref( List sourceDirs, String templateDir, String windowTitle, String docTitle, String bottom )
+ throws IOException, JxrException
+ {
+ // first collect package and class info
+ FileManager fileManager = new FileManager();
+ fileManager.setEncoding( inputEncoding );
+
+ PackageManager pkgmgr = new PackageManager( log, fileManager );
+
+ // go through each source directory and xref the java files
+ for ( Iterator i = sourceDirs.iterator(); i.hasNext(); )
+ {
+ String path = (String) i.next();
+ path = new File( path ).getCanonicalPath();
+
+ pkgmgr.process( path );
+
+ processPath( pkgmgr, path );
+ }
+
+ // once we have all the source files xref'd, create the index pages
+ DirectoryIndexer indexer = new DirectoryIndexer( pkgmgr, dest );
+ indexer.setOutputEncoding( outputEncoding );
+ indexer.setTemplateDir( templateDir );
+ indexer.setWindowTitle( windowTitle );
+ indexer.setDocTitle( docTitle );
+ indexer.setBottom( bottom );
+ indexer.process( log );
+ }
}
Added: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrException.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrException.java?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrException.java (added)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrException.java Thu Sep 29 23:15:37 2005
@@ -0,0 +1,32 @@
+package org.apache.maven.jxr;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Exception occuring in JXR.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class JxrException
+ extends Exception
+{
+ public JxrException( String message, Exception e )
+ {
+ super( message, e );
+ }
+}
Propchange: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/JxrException.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/ant/DirectoryScanner.java Thu Sep 29 23:15:37 2005
@@ -8,7 +8,7 @@
* @author Carlos Sanchez
*/
public class DirectoryScanner
- extends org.apache.tools.ant.DirectoryScanner
+ extends org.codehaus.plexus.util.DirectoryScanner
{
public void addDefaultExcludes()
Added: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/Log.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/Log.java?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/Log.java (added)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/Log.java Thu Sep 29 23:15:37 2005
@@ -0,0 +1,34 @@
+package org.apache.maven.jxr.log;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+/**
+ * Logging interface.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public interface Log
+{
+ void info( String message );
+
+ void debug( String message );
+
+ void warn( String message );
+
+ void error( String message );
+}
Propchange: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/Log.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/Log.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/VelocityLogger.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/VelocityLogger.java?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/VelocityLogger.java (added)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/VelocityLogger.java Thu Sep 29 23:15:37 2005
@@ -0,0 +1,60 @@
+package org.apache.maven.jxr.log;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.velocity.runtime.RuntimeServices;
+import org.apache.velocity.runtime.log.LogSystem;
+
+/**
+ * Logging interface for Velocity.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class VelocityLogger
+ implements LogSystem
+{
+ private Log log;
+
+ public void init( RuntimeServices runtimeServices )
+ {
+ log = (Log) runtimeServices.getProperty( Log.class.getName() );
+ }
+
+ public void logVelocityMessage( int level, String msg )
+ {
+ switch ( level )
+ {
+ case INFO_ID:
+ log.info( msg );
+ break;
+
+ case WARN_ID:
+ log.warn( msg );
+ break;
+
+ case ERROR_ID:
+ log.error( msg );
+ break;
+
+ default:
+ case DEBUG_ID:
+ log.debug( msg );
+ break;
+ }
+ }
+}
Propchange: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/VelocityLogger.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/log/VelocityLogger.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/jxr/trunk/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java (original)
+++ maven/jxr/trunk/src/main/java/org/apache/maven/jxr/pacman/PackageManager.java Thu Sep 29 23:15:37 2005
@@ -17,9 +17,8 @@
* ====================================================================
*/
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tools.ant.DirectoryScanner;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.apache.maven.jxr.log.Log;
import java.io.File;
import java.io.IOException;
@@ -33,10 +32,7 @@
*/
public class PackageManager
{
- /**
- * Log
- */
- private static final Log LOG = LogFactory.getLog( PackageManager.class );
+ private final Log log;
private Hashtable directories = new Hashtable();
@@ -50,6 +46,14 @@
*/
private PackageType defaultPackage = new PackageType();
+ private FileManager fileManager;
+
+ public PackageManager( Log log, FileManager fileManager )
+ {
+ this.log = log;
+ this.fileManager = fileManager;
+ }
+
/**
* Given the name of a package (Ex: org.apache.maven.util) obtain it from
* the PackageManager
@@ -89,7 +93,7 @@
{
// Go through each directory and get the java source
// files for this dir.
- LOG.info( "Scanning " + directory );
+ log.info( "Scanning " + directory );
DirectoryScanner directoryScanner = new DirectoryScanner();
File baseDir = new File( directory );
directoryScanner.setBasedir( baseDir );
@@ -100,13 +104,13 @@
for ( int j = 0; j < files.length; ++j )
{
- LOG.debug( "parsing... " + files[j] );
+ log.debug( "parsing... " + files[j] );
//now parse out this file to get the packages/classname/etc
try
{
String fileName = new File( baseDir, files[j] ).getAbsolutePath();
- JavaFile jfi = FileManager.getInstance().getFile( fileName );
+ JavaFile jfi = fileManager.getFile( fileName );
// now that we have this parsed out blend its information
// with the current package structure
@@ -160,20 +164,12 @@
}
/**
- * Simple logging facility
- */
- public final static void log( String message )
- {
- System.out.println( " PackageManager -> " + message );
- }
-
- /**
* Dump the package information to STDOUT. FOR DEBUG ONLY
*/
public void dump()
{
- LOG.debug( "Dumping out PackageManager structure" );
+ log.debug( "Dumping out PackageManager structure" );
Enumeration pts = this.getPackageTypes();
@@ -183,7 +179,7 @@
//get the current package and print it.
PackageType current = (PackageType) pts.nextElement();
- LOG.debug( current.getName() );
+ log.debug( current.getName() );
//get the classes under the package and print those too.
Enumeration classes = current.getClassTypes();
@@ -193,10 +189,15 @@
ClassType currentClass = (ClassType) classes.nextElement();
- LOG.debug( "\t" + currentClass.getName() );
+ log.debug( "\t" + currentClass.getName() );
}
}
+ }
+
+ public FileManager getFileManager()
+ {
+ return fileManager;
}
}
Added: maven/jxr/trunk/src/main/resources/jxr-report.properties
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/jxr-report.properties?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/jxr-report.properties (added)
+++ maven/jxr/trunk/src/main/resources/jxr-report.properties Thu Sep 29 23:15:37 2005
@@ -0,0 +1,11 @@
+report.jxr.name=Source Xref
+report.jxr.description=HTML based, cross-reference version of Java source code.
+report.xref.header=Source Xref report
+report.xref.mainTitle=Cross-reference Java source code
+report.xref.summary=This report includes a cross-reference of the project's sources. Each source entry is also linked with its corresponding Javadoc (if Javadoc was generated).
+report.xref.projectSources.title=Project sources
+report.xref.projectSources.link=The cross-reference project sources can be found here:\
+report.xref.projectSources.noSources=No project sources were found.
+report.xref.testSources.title=Test sources
+report.xref.testSources.link=The cross-reference test sources can be found here:\
+report.xref.testSources.noSources=No test sources were found.
\ No newline at end of file
Propchange: maven/jxr/trunk/src/main/resources/jxr-report.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/jxr/trunk/src/main/resources/jxr-report.properties
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/jxr/trunk/src/main/resources/jxr-report_fr.properties
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/jxr-report_fr.properties?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/jxr-report_fr.properties (added)
+++ maven/jxr/trunk/src/main/resources/jxr-report_fr.properties Thu Sep 29 23:15:37 2005
@@ -0,0 +1,11 @@
+report.taglist.name=Sources Xref
+report.taglist.description=Code source Java généré au format HTML.
+report.xref.header=Sources Xref
+report.xref.mainTitle=Code source Java
+report.xref.summary=Ce rapport permet d'avoir accès aux sources Java générées au format HTML. Chaque source est connectée à sa Javadoc, si celui-ci a été généré.
+report.xref.projectSources.title=Sources du projet
+report.xref.projectSources.link=Les sources du projet au format HTML ont été générées à l'endroit suivant :\
+report.xref.projectSources.noSources=Aucune source du projet n'a été trouvée.
+report.xref.testSources.title=Sources des tests
+report.xref.testSources.link=Les sources des tests au format HTML ont été générées à l'endroit suivant :\
+report.xref.testSources.noSources=Aucune source de test n'a été trouvée.
\ No newline at end of file
Propchange: maven/jxr/trunk/src/main/resources/jxr-report_fr.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/jxr/trunk/src/main/resources/jxr-report_fr.properties
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/jxr/trunk/src/main/resources/templates/allclasses-frame.vm
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/templates/allclasses-frame.vm?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/templates/allclasses-frame.vm (added)
+++ maven/jxr/trunk/src/main/resources/templates/allclasses-frame.vm Thu Sep 29 23:15:37 2005
@@ -0,0 +1,38 @@
+#*
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*#
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=$outputEncoding" />
+ <title>All Classes</title>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
+ </head>
+ <body>
+
+ <h3>All Classes</h3>
+
+ <ul>
+ #foreach ($classInfo in $info.allClasses.values())
+ <li>
+ <a href="${classInfo.dir}/${classInfo.name}.html" target="classFrame">$classInfo.name</a>
+ </li>
+ #end
+ </ul>
+
+ </body>
+ </html>
Added: maven/jxr/trunk/src/main/resources/templates/index.vm
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/templates/index.vm?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/templates/index.vm (added)
+++ maven/jxr/trunk/src/main/resources/templates/index.vm Thu Sep 29 23:15:37 2005
@@ -0,0 +1,38 @@
+#*
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*#
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=$outputEncoding" />
+ <title>$windowTitle</title>
+ </head>
+ <frameset cols="20%,80%">
+ <frameset rows="30%,70%">
+ <frame src="overview-frame.html" name="packageListFrame" />
+ <frame src="allclasses-frame.html" name="packageFrame" />
+ </frameset>
+ <frame src="overview-summary.html" name="classFrame" />
+ </frameset>
+ <noframes>
+ <h1>Frame Alert</h1>
+ <p>
+ You don't have frames. Go <a href="overview-summary.html">here</a>
+ </p>
+ </noframes>
+</html>
+
Added: maven/jxr/trunk/src/main/resources/templates/overview-frame.vm
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/templates/overview-frame.vm?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/templates/overview-frame.vm (added)
+++ maven/jxr/trunk/src/main/resources/templates/overview-frame.vm Thu Sep 29 23:15:37 2005
@@ -0,0 +1,43 @@
+#*
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*#
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=$outputEncoding" />
+ <title>$windowTitle</title>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
+ </head>
+ <body>
+
+ <h3>
+ <a href="allclasses-frame.html" target="packageFrame">All Classes</a>
+ </h3>
+
+ <h3>Packages</h3>
+
+ <ul>
+ #foreach ($pkgInfo in $info.allPackages.values())
+ <li>
+ <a href="${pkgInfo.dir}/package-frame.html" target="packageFrame">$pkgInfo.name</a>
+ </li>
+ #end
+ </ul>
+
+ </body>
+</html>
+
Added: maven/jxr/trunk/src/main/resources/templates/overview-summary.vm
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/templates/overview-summary.vm?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/templates/overview-summary.vm (added)
+++ maven/jxr/trunk/src/main/resources/templates/overview-summary.vm Thu Sep 29 23:15:37 2005
@@ -0,0 +1,88 @@
+#*
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*#
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=$outputEncoding" />
+ <title>$windowTitle</title>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
+ </head>
+ <body>
+ ## Navigation Bar -------- START --------
+ <div class="overview">
+ <ul>
+ <li class="selected">Overview</li>
+ <li>Package</li>
+ </ul>
+ </div>
+ <div class="framenoframe">
+ <ul>
+ <li>
+ <a href="index.html" target="_top">FRAMES</a>
+ </li>
+ <li>
+ <a href="overview-summary.html" target="_top">NO FRAMES</a>
+ </li>
+ </ul>
+ </div>
+ ## Navigation Bar -------- END --------
+
+ ## Overview Summary -------- START --------
+ <h2>$docTitle</h2>
+
+ <table class="summary">
+ <thead>
+ <tr>
+ <th>Packages</th>
+ </tr>
+ </thead>
+ <tbody>
+ #foreach ($pkgInfo in $info.allPackages.values())
+ <tr>
+ <td>
+ <a href="${pkgInfo.dir}/package-summary.html">$pkgInfo.name</a>
+ </td>
+ </tr>
+ #end
+ </tbody>
+ </table>
+ ## Overview Summary -------- END --------
+
+ ## Navigation Bar -------- START --------
+ <div class="overview">
+ <ul>
+ <li class="selected">Overview</li>
+ <li>Package</li>
+ </ul>
+ </div>
+ <div class="framenoframe">
+ <ul>
+ <li>
+ <a href="index.html" target="_top">FRAMES</a>
+ </li>
+ <li>
+ <a href="overview-summary.html" target="_top">NO FRAMES</a>
+ </li>
+ </ul>
+ </div>
+ ## Navigation Bar -------- END --------
+
+ <hr />
+ ${bottom}
+ </body>
+</html>
\ No newline at end of file
Added: maven/jxr/trunk/src/main/resources/templates/package-frame.vm
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/templates/package-frame.vm?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/templates/package-frame.vm (added)
+++ maven/jxr/trunk/src/main/resources/templates/package-frame.vm Thu Sep 29 23:15:37 2005
@@ -0,0 +1,42 @@
+#*
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*#
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=$outputEncoding" />
+ <title>$windowTitle Package $pkgInfo.name</title>
+ <link rel="stylesheet" type="text/css" href="${pkgInfo.rootRef}stylesheet.css" title="style" />
+ </head>
+ <body>
+
+ <h3>
+ <a href="package-summary.html" target="classFrame">$pkgInfo.name</a>
+ </h3>
+
+ <h3>Classes</h3>
+
+ <ul>
+ #foreach ($classInfo in $pkgInfo.classes.values())
+ <li>
+ <a href="${classInfo.name}.html" target="classFrame">$classInfo.name</a>
+ </li>
+ #end
+ </ul>
+
+ </body>
+</html>
\ No newline at end of file
Added: maven/jxr/trunk/src/main/resources/templates/package-summary.vm
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/main/resources/templates/package-summary.vm?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/main/resources/templates/package-summary.vm (added)
+++ maven/jxr/trunk/src/main/resources/templates/package-summary.vm Thu Sep 29 23:15:37 2005
@@ -0,0 +1,91 @@
+#*
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*#
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=$outputEncoding" />
+ <title>$windowTitle Package $name</title>
+ <link rel="stylesheet" type="text/css" href="${pkgInfo.rootRef}stylesheet.css" title="style" />
+ </head>
+ <body>
+ ## Navigation Bar -------- START --------
+ <div class="overview">
+ <ul>
+ <li>
+ <a href="${pkgInfo.rootRef}overview-summary.html">Overview</a>
+ </li>
+ <li class="selected">Package</li>
+ </ul>
+ </div>
+ <div class="framenoframe">
+ <ul>
+ <li>
+ <a href="${pkgInfo.rootRef}index.html" target="_top">FRAMES</a>
+ </li>
+ <li>
+ <a href="package-summary.html" target="_top">NO FRAMES</a>
+ </li>
+ </ul>
+ </div>
+ ## Navigation Bar -------- END --------
+
+ ## Package Summary -------- START --------
+ <h2>Package $pkgInfo.name</h2>
+
+ <table class="summary">
+ <thead>
+ <tr>
+ <th>Class Summary</th>
+ </tr>
+ </thead>
+ <tbody>
+ #foreach ($classInfo in $pkgInfo.classes.values())
+ <tr>
+ <td>
+ <a href="${classInfo.name}.html" target="classFrame">$classInfo.name</a>
+ </td>
+ </tr>
+ #end
+ </tbody>
+ </table>
+ ## Package Summary -------- END --------
+
+ ## Navigation Bar -------- START --------
+ <div class="overview">
+ <ul>
+ <li>
+ <a href="${pkgInfo.rootRef}overview-summary.html">Overview</a>
+ </li>
+ <li class="selected">Package</li>
+ </ul>
+ </div>
+ <div class="framenoframe">
+ <ul>
+ <li>
+ <a href="${pkgInfo.rootRef}index.html" target="_top">FRAMES</a>
+ </li>
+ <li>
+ <a href="package-summary.html" target="_top">NO FRAMES</a>
+ </li>
+ </ul>
+ </div>
+ ## Navigation Bar -------- END --------
+ <hr />
+ ${bottom}
+ </body>
+</html>
\ No newline at end of file
Modified: maven/jxr/trunk/src/test/java/org/apache/maven/jxr/CodeTransformTest.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/test/java/org/apache/maven/jxr/CodeTransformTest.java?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/src/test/java/org/apache/maven/jxr/CodeTransformTest.java (original)
+++ maven/jxr/trunk/src/test/java/org/apache/maven/jxr/CodeTransformTest.java Thu Sep 29 23:15:37 2005
@@ -1,9 +1,27 @@
package org.apache.maven.jxr;
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import junit.framework.TestCase;
import org.apache.maven.jxr.pacman.PackageManager;
+import org.apache.maven.jxr.pacman.FileManager;
import java.io.File;
+import java.util.Locale;
public class CodeTransformTest
extends TestCase
@@ -17,7 +35,7 @@
throws Exception
{
super.setUp();
- packageManager = new PackageManager();
+ packageManager = new PackageManager( new DummyLog(), new FileManager() );
codeTransform = new CodeTransform( packageManager );
}
@@ -25,16 +43,12 @@
throws Exception
{
File sourceFile = new File(
- System.getProperty( "basedir" ) + "/src/test/org/apache/maven/jxr/CodeTransformTest.java" );
+ System.getProperty( "basedir" ) + "/src/test/java/org/apache/maven/jxr/CodeTransformTest.java" );
assertTrue( sourceFile.exists() );
codeTransform.transform( sourceFile.getAbsolutePath(),
- System.getProperty( "basedir" ) + "/target/CodeTransformTest.html", "en", "ISO-8859-1",
- "ISO-8859-1", "", "" );
- // sourceFile = new File("src/test/org/apache/maven/jxr/package-info.java");
- // assertTrue(sourceFile.exists());
- // codeTransform.transform(sourceFile.getAbsolutePath(),
- // "target/pakage-info.html", "en", "ISO-8859-1", "ISO-8859-1",
- // "", "");
+ System.getProperty( "basedir" ) + "/target/CodeTransformTest.html", Locale.ENGLISH,
+ "ISO-8859-1", "ISO-8859-1", "", "" );
+ assertTrue( new File( System.getProperty( "basedir" ), "/target/CodeTransformTest.html" ).exists() );
}
}
Added: maven/jxr/trunk/src/test/java/org/apache/maven/jxr/DummyLog.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/test/java/org/apache/maven/jxr/DummyLog.java?rev=292641&view=auto
==============================================================================
--- maven/jxr/trunk/src/test/java/org/apache/maven/jxr/DummyLog.java (added)
+++ maven/jxr/trunk/src/test/java/org/apache/maven/jxr/DummyLog.java Thu Sep 29 23:15:37 2005
@@ -0,0 +1,49 @@
+package org.apache.maven.jxr;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.jxr.log.Log;
+
+/**
+ * Dummy logger.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class DummyLog
+ implements Log
+{
+ public void info( String message )
+ {
+ System.out.println( message );
+ }
+
+ public void debug( String message )
+ {
+ System.out.println( message );
+ }
+
+ public void warn( String message )
+ {
+ System.out.println( message );
+ }
+
+ public void error( String message )
+ {
+ System.out.println( message );
+ }
+}
Propchange: maven/jxr/trunk/src/test/java/org/apache/maven/jxr/DummyLog.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/jxr/trunk/src/test/java/org/apache/maven/jxr/DummyLog.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/jxr/trunk/src/test/java/org/apache/maven/jxr/JxrBeanTest.java
URL: http://svn.apache.org/viewcvs/maven/jxr/trunk/src/test/java/org/apache/maven/jxr/JxrBeanTest.java?rev=292641&r1=292640&r2=292641&view=diff
==============================================================================
--- maven/jxr/trunk/src/test/java/org/apache/maven/jxr/JxrBeanTest.java (original)
+++ maven/jxr/trunk/src/test/java/org/apache/maven/jxr/JxrBeanTest.java Thu Sep 29 23:15:37 2005
@@ -1,33 +1,48 @@
package org.apache.maven.jxr;
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import junit.framework.TestCase;
+import java.util.Collections;
+
public class JxrBeanTest
extends TestCase
{
- private JxrBean jxrBean;
+ private JXR jxrBean;
protected void setUp()
throws Exception
{
super.setUp();
- jxrBean = new JxrBean();
- jxrBean.setSourceDir( System.getProperty( "basedir" ) + "/src/test" );
- jxrBean.setDestDir( System.getProperty( "basedir" ) + "/target" );
+ jxrBean = new JXR();
+ jxrBean.setDest( System.getProperty( "basedir" ) + "/target" );
jxrBean.setInputEncoding( "ISO-8859-1" );
jxrBean.setOutputEncoding( "ISO-8859-1" );
- jxrBean.setTemplateDir( System.getProperty( "basedir" ) + "/src/plugin-resources/templates" );
- jxrBean.setJavadocDir( "" );
- jxrBean.setWindowTitle( "title" );
- jxrBean.setDocTitle( "title" );
- jxrBean.setBottom( "copyright" );
+ jxrBean.setJavadocLinkDir( "" );
+ jxrBean.setLog( new DummyLog() );
}
public void testXref()
throws Exception
{
- jxrBean.xref();
+ jxrBean.xref( Collections.singletonList( System.getProperty( "basedir" ) + "/src/test/java" ), "templates",
+ "title", "title", "copyright" );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org