You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2004/04/07 04:10:19 UTC
cvs commit: maven-components/maven-xdoc/src/main/java/org/apache/maven/xdoc XdocPlugin.java
jvanzyl 2004/04/06 19:10:19
Modified: maven-xdoc/src/main/java/org/apache/maven/xdoc
XdocPlugin.java
Log:
o pull default resources and images from within the JAR so the plugin doesn't
need to be expanded.
Revision Changes Path
1.2 +54 -8 maven-components/maven-xdoc/src/main/java/org/apache/maven/xdoc/XdocPlugin.java
Index: XdocPlugin.java
===================================================================
RCS file: /home/cvs/maven-components/maven-xdoc/src/main/java/org/apache/maven/xdoc/XdocPlugin.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XdocPlugin.java 7 Apr 2004 01:36:04 -0000 1.1
+++ XdocPlugin.java 7 Apr 2004 02:10:19 -0000 1.2
@@ -3,8 +3,11 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.xdoc.render.DefaultXdocRenderer;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
import java.io.File;
+import java.io.FileWriter;
+import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
@@ -24,6 +27,19 @@
private MavenProject project;
private DefaultXdocRenderer renderer;
+
+ private String[] css =
+ {
+ "style/maven-base.css",
+ "style/maven-theme.css"
+ };
+
+ private String[] image =
+ {
+ "images/collapsed.gif",
+ "images/expanded.gif",
+ "images/maven-button-1.png"
+ };
public void setXdocDirectory( String xdocDirectory )
{
@@ -43,12 +59,8 @@
public void execute()
throws Exception
{
- System.out.println( "Rendering xdocs ..." );
-
renderer = new DefaultXdocRenderer();
- // Read in all the xdocs
-
List files = FileUtils.getFileNames( new File( xdocDirectory ), "**/*.xml", "style/**,navigation.xml", false );
for ( Iterator i = files.iterator(); i.hasNext(); )
@@ -58,12 +70,46 @@
// Copy style directory
- FileUtils.copyDirectory( new File( "src/main/resources/style" ), new File( outputDirectory, "style" ) );
-
- FileUtils.copyDirectory( new File( "src/main/resources/images" ), new File( outputDirectory, "images" ) );
+ copyStyle();
+
+ copyImages();
FileUtils.copyDirectory( new File( xdocDirectory, "images" ), new File( outputDirectory, "images" ) );
+ }
+
+ private void copyStyle()
+ throws Exception
+ {
+ File styles = new File( outputDirectory, "style" );
+
+ styles.mkdirs();
+
+ for ( int i = 0; i < css.length; i++ )
+ {
+ File f = new File( outputDirectory, css[i] );
+
+ IOUtil.copy( getStream( css[i]), new FileWriter( f ) );
+ }
+ }
+
+ private void copyImages()
+ throws Exception
+ {
+ File images = new File( outputDirectory, "images" );
+
+ images.mkdirs();
+
+ for ( int i = 0; i < image.length; i++ )
+ {
+ File f = new File( outputDirectory, image[i] );
+
+ IOUtil.copy( getStream( image[i]), new FileWriter( f ) );
+ }
+ }
- System.out.println( "Done!" );
+ private InputStream getStream( String name )
+ throws Exception
+ {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream( name );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org