Installing OT on the Mac

The DITA Open Toolkit User Guide devotes a lot of attention to Windows
and Linux but gives Mac OS X scant attention. The brief Mac installation section on page 58 simply says

Before installing DITA Open Toolkit and its prerequisite software on Mac OS X, check to see if any of the tools are already installed on your system and, if so, whether the version you have is supported (see System requirements and supported applications on page 47). Java is a core component of Mac OS X. Newer versions (10.5) of Mac OS X include JVM 1.5 by default. This version of the JDK includes Ant
and the Xalan-J XSLT processor, as well. Other tools you want to install may be included on the Mac OS X Developer's Tools on the product DVD.

To install the Toolkit, extract the zip file to your HOME directory, then edit your login rc file to include the Toolkit in your CLASSPATH.


You must use a Terminal window to enter commands on the command line.

If you have not changed your shell, enter this (you should be logged in as an account with adminsistrator privileges):

export CLASSPATH="$HOME/DITA-OT/lib:$HOME/DITA-OT/lib/dost.jar"

The .profile file and others created are "hidden" files. It's important to remember that Mac OS X is a BSD UNIX-based OS. All filenames that have a period before them are hidden under normal circumstances. However you can view these files in the Terminal using the ls -a option.

An easier method to install the OT on Mac is the following:

The DITA-OT "Full" aka "Easy" package has a "startcmd.sh" command,
which purports to work on Mac OS X as well as on Linux. You can
source it with something like these two commands:

export DITA_HOME="$HOME/DITA-OT"
"$DITA_HOME/startcmd.sh"

You may need to grant execute permissions on this startup script:

chmod +x startcmd.sh

Other notes:

There's a Java Preferences application in the Java folder under
Utilities. You can use this to set which J2SE version to run.

Automator and AppleScript can run shell commands. Once you've figured
out what you need to run in Terminal, you should be able to transfer
these to either Automator or AppleScript, and add appropriate variables.

 

-------------

 

 

 

Alternate instructions from David J. B. Hollis on the Yahoo DITA user group if the above instructions do not work (and did not for me):

Firstly check out: ant.apache.org/manual/running.html#libs

As of Ant 1.6, Ant looks in a user directory for config files and a lib.

I'm running Mac OS X.4, and I've installed the Developer Tools XCode 2

Mac OS X.4 is the min. spec. for running Java 1.5.

It's XCode 3 for OS X.5. I've not installed either, yet! (Soon,
hopefully...)

Installing XCode puts a symlink from /usr/bin/ant to /Developer/Java/
Ant/bin/ant

This means you can just call 'ant' from the Terminal, without
bothering with paths.

If you'd rather not install XCode, then you can do something similar.
But first, I'd suggest running:

ls -l -a /usr/bin

and just check what's there!

Assuming there's no sign of ant in /usr/bin, then enter the following
in Terminal:

sudo ln -s ~/DITA-OT1.4.2.1/tools/ant/bin/ant /usr/bin/ant

(~ is a shortcut to the User directory; sudo gives you temporary root
privileges, and you'll be asked for your password)

In this and the following, edit DITA-OT1.4.2.1 to wherever you've
installed DITA.

You'll probably also need to make this an executable with:

chmod 777 ~/DITA-OT1.4.2.1/tools/ant/bin/ant

So, you can now call ant from the Terminal!


The next stage is to configure ant.

Ant will look for both ~/.antrc and ~/.ant/ant.conf

Now both these files, and the .ant directory are hidden. I decided
I'd rather have an ant.conf file which I can see and edit easily, so
I used another symlink. YMMV, and you can ignore the symlink.

Note, you can always use:  open -a TextEdit /path/to/file to open a
file in TextEdit from Terminal.

I created an Ant folder in Home, and saved ant.conf to it. ant.conf
contains the following:

#!/bin/sh

DITA_HOME=~/DITA-OT1.4.2.1
DITA_HOME=`cd "$DITA_HOME" && pwd`

export ANT_HOME="$DITA_HOME"/tools/ant
#export ANT_HOME=/Developer/Java/Ant
export ANT_OPTS="-Xmx512m"
export ANT_ARGS="-lib $DITA_HOME/lib -Ddita.dir=$DITA_HOME"


OK, what does it do?

1. Sets up DITA_HOME, and makes sure it's a full path.

2. Uses DITA_HOME to define ANT_HOME

3. Commented out, if you have Developer Tools, uncomment this line to
use the XCode ant, and comment out the preceding.

4. Sets up ANT_OPTS with the memory requirements.

5. Sets up ANT_ARGS with the DITA OT lib directory, and the dita.dir
property.

The -lib property can be used instead of defining CLASSPATH, with the
long list of jars. An absolute boon if you change jar configurations
at all! No need to edit CLASSPATH to match the revised configuration!

DITA_HOME is subsequently available for use in the Terminal.

So you can save these 7 lines in either ~/.antrc or ~/.ant/ant.conf
or create the symlink, to hook up ant.conf.

For the symlink, in Terminal, make a .ant directory in Home:

mkdir .ant

Then add the symlink to ant.conf in the Ant folder:

ln -s ~/Ant/ant.conf ~/.ant/ant.conf


So, that's it! To check it all works:

ant -diagnostics

This will tell you where ANT_HOME is, and what's on the CLASSPATH.
Check that dost.jar is there, and everything else!

Now run:

ant all -f DITA_HOME/build_demo.xml

to run the demo build


In summary:

1. symlink from /usr/bin to call ant. From either Developer Tools or
DITA tools.

2. ant.conf file to set up not just ant but dita.dir as well. Place
this somewhere in the user directory, possibly with another symlink.

3. There's no need for startcmd.sh The symlinks and ant.conf are set
up once, and that's it!


Windows users can do something very similar. The syntaxt will be
different, and there's no equivalent to symlinks. But a local
ant.conf file is possible.

XML.org Focus Areas: BPEL | DITA | ebXML | IDtrust | OpenDocument | SAML | UBL | UDDI
OASIS sites: OASIS | Cover Pages | XML.org | AMQP | CGM Open | eGov | Emergency | IDtrust | LegalXML | Open CSA | OSLC | WS-I