From 77dc613c7a01946b183846bafb91e8a37bdebcdc Mon Sep 17 00:00:00 2001 From: Simon Pepping Date: Sat, 6 Jan 2007 14:18:57 +0000 Subject: [PATCH] Added fop.home to Main.getJARList. Adapted the documentation. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@493473 13f79535-47bb-0310-9956-ffa450edef68 --- .../content/xdocs/trunk/running.xml | 57 ++++++++++++------- src/java/org/apache/fop/cli/Main.java | 8 ++- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/documentation/content/xdocs/trunk/running.xml b/src/documentation/content/xdocs/trunk/running.xml index 4b488ef12..5ab36f4a2 100644 --- a/src/documentation/content/xdocs/trunk/running.xml +++ b/src/documentation/content/xdocs/trunk/running.xml @@ -184,7 +184,7 @@ Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl

FOP's entry point for your own scripts is the class org.apache.fop.cli.Main. The general pattern for the command line is: java -classpath <CLASSPATH> - org.apache.fop.cli.Main <arguments>. The arguments + org.apache.fop.cli.Main <arguments>. The arguments consist of the options and infile and outfile specifications as shown above for the standard scripts. You may wish to review the standard scripts to make sure that @@ -195,35 +195,48 @@ Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl Running with java's <code>-jar</code> option

As an alternative to the start scripts you can run java - -jar build/fop.jar from the FOP_HOME directory. In this - case FOP tries to build the classpath for running FOP - dynamically, see below. If - you use hyphenation, you must put fop-hyph.jar in - the lib directory. + -jar path/to/build/fop.jar <arguments>, relying on + FOP to build the classpath for running FOP dynamically, see below. If you use hyphenation, + you must put fop-hyph.jar in the lib + directory.

-

You can also run java -jar fop.jar from any - other working directory. This only works if you put + +

You can also run java -jar path/to/fop.jar + <arguments>, relying on the Class-Path + entry in the manifest file. This works if you put fop.jar and all jar files from the lib - directory in a single directory. See the Class-Path - entry in the manifest file. If you use hyphenation, you + directory in a single directory. If you use hyphenation, you must also put fop-hyph.jar in that directory.

+ +

In both cases the arguments consist of the options and + infile and outfile specifications as shown above for the + standard scripts.

FOP's dynamical classpath construction

If FOP is started without a proper classpath, it tries to - add its dependencies dynamically. FOP expects to find - fop.jar in the build directory, - which is either the current working directory or one of its - subdirectories. Then FOP adds all jar files in - the lib directory to the classpath. The - lib directory is a sibling directory of the - build directory, or, if that does not exist, the - parent directory of the build directory. If the - system property fop.optional.lib contains the - name of a directory, then all jar files in that - directory are also added to the classpath. See the methods - getJARList and checkDependencies in + add its dependencies dynamically. If the system property + fop.home contains the name of a directory, then + FOP uses that directory as the base directory for its + search. Otherwise the current working directory is the base + directory. If the base directory is called build, + then its parent directory becomes the base directory.

+ +

FOP expects to find fop.jar in the + build subdirectory of the base directory, and + adds it to the classpath. Subsequently FOP adds all + jar files in the lib directory to the + classpath. The lib directory is either the lib + subdirectory of the base directory, or, if that does not + exist, the base directory itself.

+ +

If the system property fop.optional.lib + contains the name of a directory, then all jar + files in that directory are also added to the classpath. See + the methods getJARList and + checkDependencies in org.apache.fop.cli.Main.

diff --git a/src/java/org/apache/fop/cli/Main.java b/src/java/org/apache/fop/cli/Main.java index cf793e2c0..e2297380d 100644 --- a/src/java/org/apache/fop/cli/Main.java +++ b/src/java/org/apache/fop/cli/Main.java @@ -42,7 +42,13 @@ public class Main { * instances to URLs. */ public static URL[] getJARList() throws MalformedURLException { - File baseDir = new File(".").getAbsoluteFile().getParentFile(); + String fopHome = System.getProperty("fop.home"); + File baseDir; + if (fopHome != null) { + baseDir = new File(fopHome).getAbsoluteFile(); + } else { + baseDir = new File(".").getAbsoluteFile().getParentFile(); + } File buildDir; if ("build".equals(baseDir.getName())) { buildDir = baseDir; -- 2.39.5