You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2005/08/23 21:13:35 UTC

svn commit: r239447 - in /xmlgraphics/fop/trunk: build.xml src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java

Author: spepping
Date: Tue Aug 23 12:13:28 2005
New Revision: 239447

URL: http://svn.apache.org/viewcvs?rev=239447&view=rev
Log:
Reintroduce they user's hyphenation patterns into the build process.
Fix a bug in the jar-hyphenation target.

Modified:
    xmlgraphics/fop/trunk/build.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java

Modified: xmlgraphics/fop/trunk/build.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/build.xml?rev=239447&r1=239446&r2=239447&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/build.xml (original)
+++ xmlgraphics/fop/trunk/build.xml Tue Aug 23 12:13:28 2005
@@ -171,6 +171,7 @@
   <property name="xdocs.dir" value="${src.dir}/documentation/content/xdocs"/>
   <property name="fo.examples.dir" value="${basedir}/examples/fo/basic"/>
   <property name="lib.dir" value="${basedir}/lib"/>
+  <property name="user.hyph.dir" value="${basedir}/hyph"/>
 
   <property name="build.dir" value="${basedir}/build"/>
   <property name="build.gensrc.dir" value="${build.dir}/gensrc"/>
@@ -385,9 +386,14 @@
     </path>
     <taskdef name="serHyph" classname="org.apache.fop.tools.anttasks.SerializeHyphPattern" classpathref="hyph-classpath"/>
     <mkdir dir="${build.dir}/hyph"/>
-    <serHyph includes="*.xml"
-             sourceDir="${src.hyph.dir}"
-             targetDir="${build.dir}/hyph"/>
+    <serHyph targetDir="${build.dir}/hyph">
+      <fileset dir="${user.hyph.dir}">
+        <include name="*.xml"/>
+      </fileset>
+      <fileset dir="${src.hyph.dir}">
+        <include name="*.xml"/>
+      </fileset>
+    </serHyph>
   </target>
 
   <target name="uptodate-jar-hyphenation" depends="compile-hyphenation">
@@ -400,7 +406,7 @@
     <tstamp>
       <format property="ts" pattern="yyyyMMdd-HHmmss-z"/>
     </tstamp>
-    <jar jarfile="${build.dir}/fop-hyph.jar" basedir="${build.dir}/hyph">
+    <jar jarfile="${build.dir}/fop-hyph.jar" basedir="${build.dir}" includes="hyph/*.hyp">
       <manifest>
         <attribute name="Implementation-Title" value="${Name}"/>
         <attribute name="Implementation-Version" value="${version}"/>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java?rev=239447&r1=239446&r2=239447&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/tools/anttasks/SerializeHyphPattern.java Tue Aug 23 12:13:28 2005
@@ -22,10 +22,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.ObjectOutputStream;
+import java.util.List;
 
 // Ant
-import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.Task;
 import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.types.FileSet;
 
 // FOP
 import org.apache.fop.hyphenation.HyphenationTree;
@@ -36,34 +38,42 @@
  */
 
 
-public class SerializeHyphPattern extends MatchingTask {
-    private File sourceDir, targetDir;
+public class SerializeHyphPattern extends Task {
+    private List filesets = new java.util.ArrayList();
+    private File targetDir;
     private boolean errorDump = false;
 
     /**
      * @see org.apache.tools.ant.Task#execute()
      */
     public void execute() throws org.apache.tools.ant.BuildException {
-        DirectoryScanner ds = this.getDirectoryScanner(sourceDir);
-        String[] files = ds.getIncludedFiles();
-        for (int i = 0; i < files.length; i++) {
-            processFile(files[i].substring(0, files[i].length() - 4));
+        // deal with the filesets
+        for (int i = 0; i < getFilesets().size(); i++) {
+            FileSet fs = (FileSet) getFilesets().get(i);
+            DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+            File basedir = ds.getBasedir();
+            String[] files = ds.getIncludedFiles();
+            for (int j = 0; j < files.length; j++) {
+                processFile(basedir, files[j].substring(0, files[j].length() - 4));
+            }
         }
     }    // end execute
 
 
     /**
-     * Sets the source directory.
-     * @param sourceDir source directory
+     * Adds a set of pattern files (nested fileset attribute).
+     * @param set a fileset
      */
-    public void setSourceDir(String sourceDir) {
-        File dir = new File(sourceDir);
-        if (!dir.exists()) {
-            System.err.println("Fatal Error: source directory " + sourceDir
-                               + " for hyphenation files doesn't exist.");
-            System.exit(1);
-        }
-        this.sourceDir = dir;
+    public void addFileset(FileSet set) {
+        filesets.add(set);
+    }
+
+    /**
+     * Returns the current list of filesets.
+     * @return the filesets
+     */
+    public List getFilesets() {
+        return this.filesets;
     }
 
     /**
@@ -88,8 +98,8 @@
      * checks whether input or output files exists or the latter is older than input file
      * and start build if necessary
      */
-    private void processFile(String filename) {
-        File infile = new File(sourceDir, filename + ".xml");
+    private void processFile(File basedir, String filename) {
+        File infile = new File(basedir, filename + ".xml");
         File outfile = new File(targetDir, filename + ".hyp");
         //long outfileLastModified = outfile.lastModified();
         boolean startProcess = true;
@@ -154,9 +164,11 @@
      * //quick access for debugging
      * public static void main (String args[]) {
      * SerializeHyphPattern ser = new SerializeHyphPattern();
-     * ser.setIncludes("*.xml");
-     * ser.setSourceDir("\\xml-fop\\hyph\\");
-     * ser.setTargetDir("\\xml-fop\\hyph\\");
+     * FileSet set = new FileSet();
+     * set.setDir(new File("src/hyph"));
+     * set.setIncludes("*.xml");
+     * ser.addFileset(set);
+     * ser.setTargetDir("build/hyph");
      * ser.execute();
      * }
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org