Extending Oracle WebLogic Workshop 10 with Ant
by John Liptak
Learn how to extend the built-in features of Oracle WebLogic Workshop using a combination of generated and custom Ant build files.
Published July 2008
Oracle WebLogic Workshop has made major advances with version 10, particularly in the design-build-run development cycle. The productivity gains from using the publish capabilities of Workshop make the development process qualitatively better. Advanced products such as Oracle WebLogic Portal are very difficult, if not impossible, to use without the help of the IDE.
Unit testing (JUnit), continuous integration, and code coverage tools—made popular by Agile software development—have grown into being viewed as industry best practices for many development methodologies.
Being able to integrate customized command-line Ant capabilities is no longer optional for many development teams. You should not have to give up these incredibly valuable tools in order to use an IDE. The answer is not to choose one or the other but to use both techniques.
This article shows how to extend the built-in features of WebLogic Workshop using a combination of generated and custom Ant build files. Getting the best out of both of them is not difficult, requiring only a little additional work, planning, and the help of some of the newer features of Ant.
My minimal requirements for command-line use are the following:
Upgrading to WebLogic Workshop 10
When it came time to start our first WebLogic Workshop 10 application, there were enough changes from our older 8.1 applications that I had to discover new ways of integrating our build process. CruiseControl, in particular the
Setting the classpath for the
WebLogic Workshop 10's classpath structure is far more complicated. Figure 1 illustrates how the various components combine to make up the classpath.
This new structure is far more functional. It allows a single project to have a single copy of a jar file in the APP-INF/lib. It also allows collections of shared libraries to be installed as WLS libraries.
There are obvious solutions to the problem, but they have major drawbacks:
I wanted to find a better way. The good news is, there
is a better way, and once you know the principal technique, it's straightforward. Step 1 is to use Workshop to generate a base set of Ant
Exporting Workshop Ant scripts
Exporting your project to a series of Ant build files is documented here. In short, you need to export three things: the build file for the entire application (in an ear project); the build files for dependent library and web projects; and a metadata file.
The build.xml file generated for the ear project will call each of the sub-project's build.xml files. This will correctly build all of the necessary sub-projects and then assemble the ear file.
Now you have all of your generated
build.xml files. Assuming that you don't like the obvious solutions for extending the build files, what should you do? I will describe using an Ant
Adding an Application Project to the Workspace
The second step in supporting both the command-line Ant and the Workshop IDE approach is to make sure they don't step on each other's build files. Our team choose to create what we call the application project "above" the ear project in the workspace.
There are two main reasons for creating a separate application project. First, Workshop will not generate a build.xml file for that project, so we don't have to worry about Workshop generating any conflicting build instructions for the project. Second, it's a great place to put configuration files, WLST domain creation and configuration scripts, property files, deployment plans, and the like.
Because we have different applications being developed against different versions of Workshop, CruiseControl is configured to call a build.xml build script. Rather than have a different configuration for Workshop applications and those that pre-date the Eclipse-based version of Workshop, we can use our application project build script, which provides another level of redirection to resolve that conflict.