Building and Installing a Framework with Ant

Version 40.1 by Steve Peery on 2012/10/23 21:56

Success

Pro Tip

If you use Hudson/Jenkins to build your WebObjects Frameworks and Applications, then you do not need to build or install either the Project Wonder frameworks or even your own Frameworks on your development machine, just having yours and the individual Wonder source code projects (ERJars, ERExtensions, AJAX, etc) open in your eclipse workspace is sufficient.

Before You Build

When building a Framework project, Ant needs to be able to find WebObjects. WebObjects itself is a set of Frameworks just like the one you are building. They can be installed anywhere using these instructions

Where Ant will look for WebObjects is specified by the wo.system.frameworks build property. This property can be set in a number of locations, or even passed as a command-line property to Ant. 

Where Ant looks for this property is different for each method of building a Framework:

  1. h6. WOJenkins Jobs
    1. Completely managed for you by WOJenkins
    2. Manually overridden as defined in Manual Jenkins Jobs below.
  2. h6. Manual Jenkins Jobs
    1. Properties specified in the Targets line of an Invoke Ant build task using -D<property>=<value> 
    2. Properties specified in the Properties line of an Invoke Ant build task using (the equivalent of -propertyfile <name>)
  3. h6. Eclipse/WOLips
    1. Properties specified for the Eclipse Workspace under Eclipse -> Preferences -> WOLips - > System Frameworks
    2. The build.properties file in the same directory as the build.xml file as specified by <property file="build.properties" /> task in the build.xml file.
  4. h6. Command Line
    1. Properties specified in the Ant command: -D<property>=<value>
    2. A properties file specified in the Ant command: -propertyfile <name>
    3. The build.properties file in the same directory as the build.xml file as specified by <property file="build.properties" /> task in the build.xml file.
Warning

Can

If Ant can't find the WebObjects frameworks, you will get compiler errors like this:
{noformat}
[wocompile] /MyProjects/MyFramework/Sources/com/mycompany/myapp/myclass:10:
            package com.webobjects.appserver does not exist
[wocompile] import com.webobjects.appserver.WOContext;
{noformat}

Building

WOJenkins

Using Jenkins is the recommended way to build a Framework and WOJenkins makes the process almost as easy as building from within Eclipse/WOLips.

Eclipse/WOLips

  • h5. Standard WebObjects Framework
    Right-Click on your project in Eclipse and select WOLips Ant Tools > Install
    WOLipsAntInstall.png
    This will build and install the framework in the location defined in the WOLips preferences, overwriting any previously installed version of the framework.
  • h5. Project Wonder Frameworks
    You can not build projects from Wonder this way. You must either use the command line or Hudson/Jenkins methods

Command Line / Terminal

You have to install woproject.jar first and make it available for ant before the following instructions will work. (see Building a WebObjects Project first)

  • h5. Standard WebObjects Framework
    You can build a standard WebObjects Framework project by calling Ant and passing it the Project directory, and the name of the build target contained in the build.xml file at your project's root.

cd /my/project/
ant build

By default, the built framework will be put in a dist directory in your project's root.

  • h5. Project Wonder Frameworks
    This assumes that you have already downloaded the Wonder source code. Make a note of the location of the Wonder directory.
    If you are building Project Wonder's frameworks you will use these commands instead:

cd /path/to/Wonder
ant frameworks

By default, all the Wonder frameworks will be built to (/Roots) (in your home directory).

Customizing the Build

By modifying the values in the build.properties and wolips.properties files or by passing in arguments to the Ant command, you can change where Ant will look for dependencies (binary frameworks, libraries, etc.) and where it will install the build products.

Installing

Assuming you already cloned and built Wonder from source using the method outlined above, you can use the following procedure pull the latest changes into your local repository.

Install the frameworks
sudo ant frameworks.install

This copies the built frameworks from /Roots to the runtime Frameworks directory:

  • Mac OS X: /Library/WebObjects/Versions/WebObjects543/Library/Frameworks/
  • Linux: /Local/Library/Frameworks

You can combine the build and install steps by simply executing this Ant command:

sudo ant frameworks frameworks.install

Upgrading

This will clean out the existing versions of the frameworks. This isn't strictly necessary, you could just re-install over the top of the old frameworks, but deleting then manually copying over the new ones will clean up any old frameworks that are no longer included in the standard build.

  1. h5. Navigate to the original Wonder source directory that you created above during initial source installation
cd /path/to/WonderSource
  1. h5. Pull the changes you do not have and merge them with your local repository
git pull
  1. h5. Build the frameworks.
ant frameworks
  1. h5. Navigate to the Roots directory that was automatically created by the initial Source installation procedure above
cd ~/Roots/
  1. h5. Delete all installed frameworks whose names match the built frameworks in this Roots build folder
for FRAMEWORK in `echo *.framework`; do sudo rm -r /Library/Frameworks/${FRAMEWORK}; done