Version 14.1 by Lachlan Deck on 2008/06/15 04:51

Hide last authors
Lachlan Deck 14.1 1 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.
Lachlan Deck 5.1 2
3 {{info title="Recommended Homework (or pre-requisites)"}}
4
Lachlan Deck 14.1 5 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/.
Lachlan Deck 5.1 6
7 At the very least you want to have read through, and understood, the [Getting Started Tutorial|http://maven.apache.org/guides/getting-started/index.html].
8
Lachlan Deck 14.1 9 The mailing list is also very helpful for getting help. See [Getting Help|http://maven.apache.org/users/getting-help.html].
Lachlan Deck 5.1 10
11 {{/info}}
12
Lachlan Deck 14.1 13 === Defining the Car - what's the aim ===
Lachlan Deck 5.1 14
Lachlan Deck 14.1 15 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.
Lachlan Deck 5.1 16
Lachlan Deck 14.1 17 So the car, i.e., the layout of the frameworks and applications, might look like this:
Lachlan Deck 5.1 18
19 {{noformat}}
20
Lachlan Deck 14.1 21 /
22 /apps/
23 /apps/ApplicationA/
24 /apps/ApplicationB/
25 /frameworks/
26 /frameworks/CustomExtensions/
27 /frameworks/CustomBusinessLogic/
28 /frameworks/etc/
Lachlan Deck 5.1 29
30 {{/noformat}}
31
Lachlan Deck 14.1 32 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.
Lachlan Deck 5.1 33
34 === Key Concepts ===
35
Lachlan Deck 14.1 36 Typical things that make up a pom...
Lachlan Deck 5.1 37
Lachlan Deck 14.1 38 1. pom parent identification (who do I belong to?)
Lachlan Deck 5.1 39 1. pom identification (who am I?)
40 1. modules (a.k.a kids; who belongs to me?)
41 1. dependencies (what do I need?)
42 1. build sources/resources (what do I have?)
43 1. properties and filtering resources (variable definitions)
44 1. dependency/plugin management (shared configuration and versioning)
45 1. repositories (where to find dependencies and plugins)
46
Lachlan Deck 14.1 47 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.
Lachlan Deck 5.1 48
49 === Alternate File System Layout Concepts ===
50
51 As you would (i.e., should) have read by now, Maven has what it calls //standards//. One such standard is the [[standard directory layout>>http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html_standard]]. 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.
52
53 {{tip title="Mavan Model Reference Doco"}}
54
55 To see what built-in options are available for maven see [Maven Model|http://maven.apache.org/ref/2.0.9/maven-model/maven.html].
56
57 {{/tip}}
58
Lachlan Deck 12.1 59 The following roughly resembles the current WebObjects WOLips produced project layout (a.k.a Fluffy Bunny layout).
Lachlan Deck 5.1 60
61 {{noformat}}
62
63 /MyProject
64 /MyProject/Components
65 /MyProject/Resources
66 /MyProject/Sources
67 /MyProject/Tests
68 /MyProject/WebServerResources
69
70 {{/noformat}}
71
Lachlan Deck 12.1 72 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//>>http://maven.apache.org/ref/2.0.9/maven-model/maven.html#class_resource]] for a definition of targetPath)
Lachlan Deck 5.1 73
74 {{code title="pom.xml"}}
75
76 <...>
77 <build>
78 <sourceDirectory>Sources</sourceDirectory>
79 <testSourceDirectory>Tests</testSourceDirectory>
80 <resources>
81 <resource>
82 <targetPath>Resources</targetPath>
83 <filtering>false</filtering>
84 <directory>Components</directory>
85 </resource>
86 <resource>
87 <targetPath>Resources</targetPath>
88 <filtering>false</filtering>
89 <directory>Resources</directory>
90 </resource>
91 <resource>
92 <targetPath>WebServerResources</targetPath>
93 <filtering>false</filtering>
94 <directory>WebServerResources</directory>
95 </resource>
96 </resources>
97 <...>
98 </build>
99 <...>
100
101 {{/code}}
102
103 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).
104
105 === Project Dependencies Concepts ===
106
Lachlan Deck 12.1 107 Most projects, of course, have dependencies on other libraries or frameworks.
Lachlan Deck 5.1 108
Lachlan Deck 12.1 109 === Project Dependencies Prerequisites ===
Lachlan Deck 5.1 110
Lachlan Deck 12.1 111 details to come...
Lachlan Deck 5.1 112
113 === Packaging Frameworks as Jars ===
114
Lachlan Deck 12.1 115 details to come...
Lachlan Deck 5.1 116
117 === Packaging Applications ===
118
Lachlan Deck 12.1 119 details to come...
Lachlan Deck 5.1 120
Lachlan Deck 12.1 121 === Project Inheritance ===
Lachlan Deck 5.1 122
Lachlan Deck 12.1 123 details to come...
Lachlan Deck 5.1 124
125 === Eclipse Integration ===
126
127 details to come...
128
129 === Putting It All Together ===
130
131 details to come...