blob: cab5b0bf1ffac16b1561e1918bc04150dae7e367 [file] [log] [blame]
Title: Apache(tm) FOP: Building from Source Code
#Apache™ FOP: Building from Source Code
## Do You Need To Build? { #build-needed}
Apache™ FOP snapshots are either pre-compiled binary or source. If you are using a binary snapshot, it is already built and there is no need to build it again. If you got the source code from a repository snapshot or via Git you will need to build FOP. See the [Download Instructions](../download.html) for information about where to obtain binary or repository snapshots, and whether a binary or source snapshot is best for your needs.
## Set Up Your Environment { #env}
### JDK { #env-jdk}
Building FOP requires a minimum Java Development Kit (JDK/SDK) of {{ fop_minimal_java_requirement }} (A Java Runtime Environment is not sufficient).
### CLASSPATH { #env-classpath}
There is generally no need to setup a classpath. All libraries needed to compile FOP are included in the source distribution and are referenced by the build script. You will only need to adjust the classpath if you build FOP in some other way. See the build script pom.xml for details.
### JAVA_HOME { #env-java-home}
The build script uses [Apache Maven](https://maven.apache.org/), a popular Java-based build tool, which usually requires that the environment variable JAVA_HOME point to your local JDK root directory. This is true even if you use JDK 1.5 or above, which normally does not need this setting.
### Apache Maven { #env-maven}
[Apache Maven](https://maven.apache.org/) (Version 3.6 or later) must be installed in order to build FOP. You can find the [instructions to install Maven in the Maven manual](https://maven.apache.org/install.html) on the web.
## Run the Build Script { #build-script}
Change to the FOP root directory and build FOP by executing the build script (pom.xml) using the "mvn" command.
<note>The "mvn" command is only available on your system if you've properly [installed Apache Maven](https://maven.apache.org/install.html) and added Maven's location to the PATH environment variable.</note>
The file pom.xml in the FOP root directory is the blueprint that Maven uses for the build.
The most useful targets are:
- **install**: Generates the JAR files (default). This is the normal build that produces a jar file usable for running FOP.
- **clean**: Cleans the build directory. This is useful for making sure that any build errors are cleaned up before starting a new build. It should not ordinarily be needed, but may be helpful if you are having problems with the build process itself.
- **javadoc:javadoc**: Creates the FOP API documentation.
To run the build:
mvn [target ...]
For example to do a normal build for the "install" target (which is the default):
mvn clean install -DskipTests
<note>If you want to shorten the build time you can just add the "-DskipTests" argument which doesn't perform any automated tests during the build.</note>
## Troubleshooting { #problems}
If you have problems building FOP, please try the following:
- Run the build with the target of "clean", then rerun the build.
- Delete the target directory completely, then rerun the build.
- Make sure you do not have a non-FOP version of xerces.jar, xalan.jar, batik.jar, or another dependency product somewhere in your CLASSPATH.
- If the build still fails, see the [Getting Help](../gethelp.html) page for further help.