View Javadoc

1   /***
2    * Copyright 2004 Fabrizio Giustina.
3    *
4    * Licensed under the Artistic License; you may not use this file
5    * except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://maven-taglib.sourceforge.net/license.html
9    *
10   * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
11   * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12   * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13   */
14  package net.sf.maventaglib;
15  
16  import java.io.File;
17  
18  
19  /***
20   * Generates a tag reference xdoc that can be integrated in a maven generated site.
21   * @author Fabrizio Giustina
22   * @version $Id: TaglibTagreferencePlugin.java,v 1.5 2005/08/23 12:29:52 fgiust Exp $
23   */
24  public class TaglibTagreferencePlugin extends TaglibPlugin
25  {
26  
27      /***
28       * Tag reference ouput file.
29       */
30      protected String tagreference;
31  
32      /***
33       * Sets the output file name for the tag reference xdoc.
34       * @param file output file name for the tag reference xdoc
35       */
36      public void setTagreference(String file)
37      {
38          this.tagreference = file;
39      }
40  
41      /***
42       * @see net.sf.maventaglib.TaglibPlugin#execute()
43       */
44      public void execute() throws Exception
45      {
46          File srcDirFile = new File(srcDir);
47          if (!srcDirFile.isDirectory())
48          {
49              throw new IllegalArgumentException("Not a directory: " + srcDirFile.getAbsolutePath());
50          }
51  
52          File[] files = srcDirFile.listFiles();
53          for (int i = 0; i < files.length; i++)
54          {
55              File current = files[i];
56              if (!current.isDirectory() && current.getName().toLowerCase().endsWith(".tld"))
57              {
58                  String fileName = current.getName();
59                  String fullName = this.tagreference + "-" + fileName.substring(0, fileName.indexOf(".tld")) + ".xml";
60  
61                  echo("Generating tag reference doc from " + fileName + ", saving as " + fullName);
62                  File output = new File(fullName);
63                  applyXslt(current, "/taglibdoc.xsl", output);
64              }
65          }
66  
67      }
68  }