Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
Have you ever been assigned to an existing project where the original programmers are nowhere to be found? Or given source code from a third party and told to fix a bug, only to find there isn't any decent documentation? Avoid some of these resulting headaches by using Maven to generate code-level documentation for your projects. Maven ties together a build management system and various third-party source code analysis tools to help you get your projects out the door faster.
Maven is a project-oriented tool from the Apache Jakarta Project that builds upon Jelly (see the Jelly Website), Ant, and other open source projects to give developers a complete picture of their projects. Maven bundles many open source projects under one umbrella to let developers easily integrate these third-party tools into their build processes. Maven uses plug-ins for various tools, including:
For a complete list of Maven's functionalities, check the plug-ins page on the Maven Website.
The Krysalis Centipede project achieves similar goals. An open source build tool based on Ant, Centipede features cents, which are equivalent to plug-ins, and includes many of the same tools as Maven, along with some that Maven omits. Discussions in the Jakarta Project mailing lists have focused on how the two could work together moving forward. If you decide to evaluate Maven, also evaluate Centipede; either one could be appropriate for your project.
In this article, I discuss some key Maven concepts to give you an idea of how Maven works and then launch into a walkthrough
of an example project.xml file from a project already using Maven: the Jakarta Project's Torque, which is an object-relational database tool. You should
be able to adapt the Torque example for your own use by simply changing some values to match your existing configuration and
project setup.
Maven's central concept is that all code belongs in projects, each one defined by a project descriptor. These projects are either discrete components or a full application that can be
built on its own with various dependencies. The descriptor consists of a Project Object Model (POM), which can be a project.xml file, or another storage format such as a database. The XML format for the POM is specified by the maven-project.xsd XML Schema file in your Maven installation's root directory. Generally speaking, copying an example project.xml file from an existing Maven installation and customizing it for your own needs proves easier than creating a new one from
scratch.
Maven defines some common goals for projects. Goals resemble Ant targets; you use them to generate source code documentation, compile your application, unit test the compiled project, or run the
plug-ins shipped with Maven. To find a project's available goals, run the command maven -g in the directory that contains your project.xml file. This command will return a list of plug-ins and their defined goals. A sample of this output:
[java] ( NO DEFAULT GOAL )
compile .................... Compile the project
jar ........................ Create the deliverable jar file
jar-resources .............. Copy any resources that must be present in the
deployed JAR file
prepare-filesystem ......... Create the directory structure needed to compile
[javadoc] : Generate API documentation
generate ................... Generate API documentation
[jdepend] : Generate a dependency report with JDepend
generate-report ............ Generate a dependency report with JDepend
[junit-report] : Generate a report from the test results
The names in brackets refer to installed Maven plug-ins, with their goals listed underneath. To run the javadoc generate goal, call Maven from the command line with the following syntax: maven javadoc:generate. As it turns out, generate is the javadoc plug-in's default goal, so you can also run it with this command: maven javadoc. However, don't rely on that command for the generate goal.
Additional goals and processing can be defined in the maven.xml file, which is specific to each project. File maven.xml should reside in the same directory as project.xml. Goals originate from the Werken Company's open source werkz project. As mentioned earlier, each goal is identical to an
Ant target, except that <goal> replaces the Ant <target> element. The <goal> element has attributes for a name and a description. It can also have a list of prerequisite goals, much like Ant has targets
that require other targets to run. The prereqs attribute specifies these goals. Here is an example goal declaration from the Torque 3.0 beta 4 maven.xml:
<goal name="runtime:prepare" prereqs="java:jar">
Goals can also use the attainGoal command to run a goal directly. An example would look like this:
<attainGoal name="java:jar">
You can also extend a goal so that pre- or post-processing occurs before or after the goal runs. This proves useful for extending
Maven's built-in goals, for example, to archive an old jar file when a new build is created. Instead of using <goal>, use <preGoal> or <postGoal>. These dependent goals use the same syntax internally.
Maven has a strong dependency system for projects as well, although the implementations are quite different. Projects can share dependencies—mostly used for ensuring that every project uses common jar files. For instance, each of your projects may rely on the Jakarta POI jar file; Maven keeps each project current with the latest jar file.
These jar files are retrieved from a repository, which is a directory on a remote Web server that contains all jar files.
The jar files are mirrored in a local repository under the Maven installation. The remote repository location is configured
in the driver.properties file located in your Maven installation's bin subdirectory. A property called maven.repo.remote takes a comma-separated list of URLs. By default, Maven uses http://www.ibiblio.org/maven as its repository. You will need
to set up your own repository with copies of internal jar files, private builds of open source projects, and other resources
you might need. Additionally, Maven uses an XML element called repository in the project.xml POM to refer to the source control repository your project uses for storing its source. Maven's source control repository
attribute supports CVS (Concurrent Versioning System) and Subversion, an open source Java source control system.
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq