Child pages
  • Maven Kicking the tyres without changing your project structure
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

So you're interested in kicking the maven tyres, so to speak, or just want to see what it's all about. The following provides hints on how to try maven with your current WebObjects projects without having to adopt a different file structure. Whilst this is not the recommended approach for the long term it allows you to try things out side-by-side with your current build system.

Recommended Homework (or pre-requisites)

It's really worth doing your homework on maven in order to understand it. The place to start is Learning Maven found at http://maven.apache.org. Various guides are also found at http://maven.apache.org/guides/.

At the very least you want to have read through, and understood, the Getting Started Tutorial.

The mailing list is also very helpful for getting help. See Getting Help.

Defining the Car - what's the aim

This might be stating the obvious, but an OO developer will, in the course of time (or is supposed to anyway), build up various encapsulated, reusable, libraries or frameworks that can be tapped into for differing projects. So let's assume we have multiple frameworks and applications in our build. Each of these has some common ground, such as their dependencies on certain WebObjects frameworks, and of course they each may have something distinctive about them.

So the car, i.e., the layout of the frameworks and applications, might look like this:

/
/apps/
/apps/ApplicationA/
/apps/ApplicationB/
/frameworks/
/frameworks/CustomExtensions/
/frameworks/CustomBusinessLogic/
/frameworks/etc/

Our aim is to put as much configuration that's shared between all frameworks, for example, into /frameworks/pom.xml as possible so we only have to define it once. The configuration is inherited by a child pom.

Key Concepts

Typical things that make up a pom...

  1. pom parent identification (who do I belong to?)
  2. pom identification (who am I?)
  3. modules (a.k.a kids; who belongs to me?)
  4. dependencies (what do I need?)
  5. build sources/resources (what do I have?)
  6. properties and filtering resources (variable definitions)
  7. dependency/plugin management (shared configuration and versioning)
  8. repositories (where to find dependencies and plugins)

Of course, with the plethora of plugins available for maven, this is only the tip of the iceberg but these main concepts will suffice for now.

Alternate File System Layout Concepts

As you would (i.e., should) have read by now, Maven has what it calls standards. One such standard is the standard directory layout. One of the advantages of following the standards is that you get something for free: you have less to configure (or even almost nothing) in order to build a jar, for example, from your sources and resources. When that's not possible, options are available that allow you to subvert these standards or provide extra resouces.

Mavan Model Reference Doco

To see what built-in options are available for maven see Maven Model.

The following roughly resembles the current WebObjects WOLips produced project layout (a.k.a Fluffy Bunny layout).

/MyProject
/MyProject/Components
/MyProject/Resources
/MyProject/Sources
/MyProject/Tests
/MyProject/WebServerResources

Assuming your building a framework, for example, the following is an extract from the relevant pom.xml. It specifies where to find your java source files and resources. Notice we've also defined the target path for each resource. (See the Maven Model#class_resource for a definition of targetPath)

pom.xml
<...>
  <build>
    <sourceDirectory>Sources</sourceDirectory>
    <testSourceDirectory>Tests</testSourceDirectory>
    <resources>
      <resource>
        <targetPath>Resources</targetPath>
        <filtering>false</filtering>
        <directory>Components</directory>
      </resource>
      <resource>
        <targetPath>Resources</targetPath>
        <filtering>false</filtering>
        <directory>Resources</directory>
      </resource>
      <resource>
        <targetPath>WebServerResources</targetPath>
        <filtering>false</filtering>
        <directory>WebServerResources</directory>
      </resource>
    </resources>
    <...>
  </build>
<...>

So, concentrating on our frameworks alone for the moment, assuming all of your frameworks share the above project layout the above can happily go into your /frameworks/pom.xml file and as such be shared by all sub-modules (i.e., frameworks).

Project Dependencies Concepts

Most projects, of course, have dependencies on other libraries or frameworks.

Project Dependencies Prerequisites

details to come...

Packaging Frameworks as Jars

details to come...

Packaging Applications

details to come...

Project Inheritance

details to come...

Eclipse Integration

details to come...

Putting It All Together

details to come...

  • No labels