Last modified by Henrique Prange on 2015/09/11 17:57

From version 15.1
edited by Lachlan Deck
on 2008/06/15 04:51
Change comment: Fleshing it out some more. Still a work in progress.
To version 22.1
edited by Lachlan Deck
on 2008/06/24 00:39
Change comment: Add tip to hang in there with longish guide.

Summary

Details

Page properties
Content
... ... @@ -1,50 +1,118 @@
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.
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, if say you're using the standard WOLips ant builds, 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.
2 2  
3 3  {{info title="Recommended Homework (or pre-requisites)"}}
4 4  
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/.
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/].
6 6  
7 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 8  
9 -The mailing list is also very helpful for getting help. See [Getting Help|http://maven.apache.org/users/getting-help.html].
9 +The maven user mailing list is also recommended for getting help. It's quite active and, as you find for the WebObjects mailing lists, is an invaluable resource. See [Getting Help|http://maven.apache.org/users/getting-help.html].
10 10  
11 11  {{/info}}
12 12  
13 -=== Defining the Car - what's the aim ===
13 +{{tip title="Hang in there"}}
14 14  
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.
15 +This particular guide might look long but some of the xml is duplicated a few times to show differing examples.
16 16  
17 -So the car, i.e., the layout of the frameworks and applications, might look like this:
17 +{{/tip}}
18 18  
19 +=== What's the aim ===
20 +
21 +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, or the file layout, and of course they each may have something distinctive about them.
22 +
23 +The layout of the frameworks and applications might look like this:
24 +
19 19  {{noformat}}
20 20  
21 -/
22 -/apps/
23 -/apps/ApplicationA/
24 -/apps/ApplicationB/
25 -/frameworks/
26 -/frameworks/CustomExtensions/
27 -/frameworks/CustomBusinessLogic/
28 -/frameworks/etc/
27 +/trunk/
28 +/trunk/apps/
29 +/trunk/apps/ApplicationA/
30 +/trunk/apps/ApplicationB/
31 +/trunk/frameworks/
32 +/trunk/frameworks/CustomExtensions/
33 +/trunk/frameworks/CustomBusinessLogic/
34 +/trunk/frameworks/etc/
29 29  
30 30  {{/noformat}}
31 31  
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.
38 +Our aim is twofold:
33 33  
40 +1. put as much configuration as possible that's shared between all frameworks, for example, into /frameworks/pom.xml so we only have to define it once. The configuration is inherited by a child pom.
41 +1. Be able to issue a single command that will package each and every framework and application.
42 +
34 34  === Key Concepts ===
35 35  
36 -Typical things that make up a pom...
45 +Typical things that make up a pom are as follows. (Note: only pom identification is mandatory. All the others have defaults.)
37 37  
38 -1. pom parent identification (who do I belong to?)
39 39  1. pom identification (who am I?)
48 +The base triplet used to identify an artifact (i.e., product)
49 +
50 +{{noformat}}
51 +
52 + <artifactId>CustomExtensions</artifactId>
53 + <groupId>com.mywostuff.frameworks</groupId>
54 + <version>0.0.1-SNAPSHOT</version>
55 +
56 +{{/noformat}}
57 +
58 +1. pom packaging (i.e., what are we building?)
59 +The default value for the packaging element is JAR if not specified. For the purposes of this exercise, we'll use JAR for the frameworks and woapplication for the applications, which requires the woproject maven plugin (TODO revisit this scenario with the apple maven plugin)
60 +
61 +{{noformat}}
62 +
63 + <packaging>woapplication</artifactId>
64 +
65 +{{/noformat}}
66 +
67 +1. pom parent identification (who do I belong to?)
68 +
69 +{{noformat}}
70 +
71 + <parent>
72 + <artifactId>frameworks</artifactId>
73 + <groupId>com.mywostuff</groupId>
74 + </parent>
75 +
76 +{{/noformat}}
77 +
40 40  1. modules (a.k.a kids; who belongs to me?)
79 +
80 +{{noformat}}
81 +
82 + <modules>
83 + <module>CustomExtensions</module>
84 + <module>CustomBusinessLogic</module>
85 + </modules>
86 +
87 +{{/noformat}}
88 +
41 41  1. dependencies (what do I need?)
90 +
91 +{{noformat}}
92 +
93 + <dependencies>
94 + <dependency>
95 + <groupId>log4j</groupId>
96 + <artifactId>log4j</artifactId>
97 + <version>1.2.12</version>
98 + <scope>compile</scope>
99 + </dependency>
100 + <dependency>
101 + <groupId>junit</groupId>
102 + <artifactId>junit</artifactId>
103 + <version>4.4</version>
104 + <scope>test</scope>
105 + </dependency>
106 + </dependencies>
107 +
108 +{{/noformat}}
109 +
42 42  1. build sources/resources (what do I have?)
43 43  1. properties and filtering resources (variable definitions)
44 44  1. dependency/plugin management (shared configuration and versioning)
45 45  1. repositories (where to find dependencies and plugins)
46 46  
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.
115 +Of course, with the plethora of plugins available for maven, this is only the tip of the iceberg. However, these main concepts will suffice for now.
48 48  
49 49  === Alternate File System Layout Concepts ===
50 50  
... ... @@ -104,20 +104,297 @@
104 104  
105 105  === Project Dependencies Concepts ===
106 106  
107 -Most projects, of course, have dependencies on other libraries or frameworks.
175 +Most projects, of course, have dependencies on other libraries or frameworks. See the [[Maven Getting Started#How//do//I//use//external//dependencies//>>http://maven.apache.org/guides/getting-started/index.html#How_do_I_use_external_dependencies]].
108 108  
109 -=== Project Dependencies Prerequisites ===
177 +The following shows the mixture of third party dependencies and custom framework dependencies. Notice that the scope element determines the life cycle phase each dependency is relevant for. See [[Maven Model#class//dependency//>>http://maven.apache.org/ref/2.0.9/maven-model/maven.html#class_dependency]] for specific definitions.
110 110  
111 -details to come...
179 +{{noformat}}
112 112  
181 + <dependencies>
182 + <dependency>
183 + <artifactId>CustomExtensions</artifactId>
184 + <groupId>com.mywostuff.frameworks</groupId>
185 + <version>0.0.1-SNAPSHOT</version>
186 + <scope>compile</scope>
187 + </dependency>
188 + <dependency>
189 + <groupId>log4j</groupId>
190 + <artifactId>log4j</artifactId>
191 + <version>1.2.12</version>
192 + <scope>compile</scope>
193 + </dependency>
194 + <dependency>
195 + <groupId>junit</groupId>
196 + <artifactId>junit</artifactId>
197 + <version>4.4</version>
198 + <scope>test</scope>
199 + </dependency>
200 + </dependencies>
201 +
202 +{{/noformat}}
203 +
204 +=== Repositories ===
205 +
206 +So far we have assumed that maven just knows where to find third party libraries. There is the default local repository (e.g., ,,/.m2/repository) and a remote one at ibiblio.org or a mirror of the same. See [[http://maven.apache.org/guides/introduction/introduction-to-repositories.html]].,,
207 +
208 +{{noformat}}
209 +
210 +<repositories>
211 + <repository>
212 + <id>system-repo</id>
213 + <name>internal repository</name>
214 + <!-- TODO switch over to your intranet.domain -->
215 + <url>file://${user.home}/.myarchiva</url>
216 + <snapshots>
217 + <enabled>true</enabled>
218 + <updatePolicy>always</updatePolicy>
219 + <checksumPolicy>ignore</checksumPolicy>
220 + </snapshots>
221 + <releases>
222 + <enabled>true</enabled>
223 + <updatePolicy>always</updatePolicy>
224 + <checksumPolicy>ignore</checksumPolicy>
225 + </releases>
226 + </repository>
227 + <repository>
228 + <id>maven2-repository.dev.java.net</id>
229 + <name>Java.net Repository for Maven</name>
230 + <url>http://download.java.net/maven/2</url>
231 + <snapshots>
232 + <enabled>true</enabled>
233 + <updatePolicy>daily</updatePolicy>
234 + </snapshots>
235 + <releases>
236 + <enabled>true</enabled>
237 + <updatePolicy>daily</updatePolicy>
238 + </releases>
239 + </repository>
240 + <repository>
241 + <id>webobjects.mdimension.com/releases</id>
242 + <name>mdimension maven 2 releases repo</name>
243 + <url>http://webobjects.mdimension.com/maven2/releases</url>
244 + <snapshots>
245 + <enabled>false</enabled>
246 + </snapshots>
247 + <releases>
248 + <enabled>true</enabled>
249 + </releases>
250 + </repository>
251 + <repository>
252 + <id>webobjects.mdimension.com/snapshots</id>
253 + <name>mdimension maven 2 snapshots repo</name>
254 + <url>http://webobjects.mdimension.com/maven2/snapshots</url>
255 + <snapshots>
256 + <enabled>true</enabled>
257 + </snapshots>
258 + <releases>
259 + <enabled>false</enabled>
260 + </releases>
261 + </repository>
262 + <repository>
263 + <id>objectstyle-maven2</id>
264 + <name>objectstyle maven2 repo</name>
265 + <url>http://objectstyle.org/maven2</url>
266 + <snapshots>
267 + <enabled>false</enabled>
268 + </snapshots>
269 + <releases>
270 + <enabled>true</enabled>
271 + </releases>
272 + </repository>
273 +</repositories>
274 +
275 +{{/noformat}}
276 +
277 +Note: A remote repository is not guaranteed to keep older versions of libraries, for example, indefinitely. It's recommended that you set up one for your intranet which stores what you need for longevity. See both the above intro to repositories and [[http://www.theserverside.com/tt/articles/article.tss?l=SettingUpMavenRepository]].
278 +
113 113  === Packaging Frameworks as Jars ===
114 114  
115 -details to come...
281 +Here's the definition for /frameworks/pom.xml.
116 116  
283 +{{code title="/frameworks/pom.xml"}}
284 +
285 +<?xml version="1.0" encoding="UTF-8"?>
286 +<project xmlns="http://maven.apache.org/POM/4.0.0"
287 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
288 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
289 + http://maven.apache.org/xsd/maven-4.0.0.xsd">
290 +
291 + <modelVersion>4.0.0</modelVersion>
292 +
293 + <!-- parent artifact -->
294 + <parent>
295 + <artifactId>mywostuff</artifactId>
296 + <groupId>com</groupId>
297 + <version>1.0-SNAPSHOT</version>
298 + </parent>
299 +
300 + <!-- artifact identity -->
301 + <artifactId>frameworks</artifactId>
302 + <groupId>com.mywostuff</groupId>
303 + <packaging>pom</packaging>
304 +
305 + <!-- framework relevant properties -->
306 + <properties>
307 + <!-- NS related properties fills in Info.plist etc-->
308 + <CFBundleDevelopmentRegion>English</CFBundleDevelopmentRegion>
309 + <CFBundleGetInfoString></CFBundleGetInfoString>
310 + <CFBundlePackageType>FMWK</CFBundlePackageType>
311 + <CFBundleIconFile>WOAfile.icns</CFBundleIconFile>
312 + <CFBundleInfoDictionaryVersion>6.0</CFBundleInfoDictionaryVersion>
313 + <CFBundleVersion>5.3.1</CFBundleVersion>
314 + <Has_WOComponents>true</Has_WOComponents>
315 + <NSPrincipalClass>${mainclass}</NSPrincipalClass>
316 + <NSResourcesBundlePath></NSResourcesBundlePath>
317 + </properties>
318 +
319 + <!-- modules -->
320 + <modules>
321 + <module>CustomExtensions</module>
322 + <module>CustomBusinessLogic</module>
323 + </modules>
324 +
325 + <!-- specific dependencies (for modules) -->
326 + <dependencies>
327 + <dependency>
328 + <artifactId>ERExtensions</artifactId>
329 + <groupId>${wonder.common.groupId}</groupId>
330 + </dependency>
331 + <dependency>
332 + <artifactId>JavaWOExtensions</artifactId>
333 + <groupId>${wonder.common.groupId}</groupId>
334 + </dependency>
335 + <dependency>
336 + <artifactId>JavaFoundation</artifactId>
337 + <groupId>${webobjects.groupId}</groupId>
338 + </dependency>
339 + <dependency>
340 + <artifactId>JavaJDBCAdaptor</artifactId>
341 + <groupId>${webobjects.groupId}</groupId>
342 + </dependency>
343 + <dependency>
344 + <artifactId>JavaWebObjects</artifactId>
345 + <groupId>${webobjects.groupId}</groupId>
346 + </dependency>
347 + <dependency>
348 + <artifactId>JavaEOControl</artifactId>
349 + <groupId>${webobjects.groupId}</groupId>
350 + </dependency>
351 + <dependency>
352 + <artifactId>JavaEOAccess</artifactId>
353 + <groupId>${webobjects.groupId}</groupId>
354 + </dependency>
355 + <dependency>
356 + <artifactId>JavaWebObjects</artifactId>
357 + <groupId>${webobjects.groupId}</groupId>
358 + </dependency>
359 + <dependency>
360 + <artifactId>JavaXML</artifactId>
361 + <groupId>${webobjects.groupId}</groupId>
362 + </dependency>
363 + </dependencies>
364 +
365 +
366 + <!-- build config (for modules) -->
367 + <build>
368 + <sourceDirectory>src</sourceDirectory>
369 + <testSourceDirectory>tests</testSourceDirectory>
370 + <resources>
371 + <!-- relative dir for Info.plist -->
372 + <resource>
373 + <targetPath>Resources</targetPath>
374 + <filtering>true</filtering>
375 + <directory>../src/main/resources</directory>
376 + </resource>
377 + <resource>
378 + <targetPath>Resources</targetPath>
379 + <filtering>false</filtering>
380 + <directory>Components</directory>
381 + </resource>
382 + <resource>
383 + <targetPath>Resources</targetPath>
384 + <filtering>false</filtering>
385 + <directory>Resources</directory>
386 + </resource>
387 + <resource>
388 + <targetPath>WebServerResources</targetPath>
389 + <filtering>false</filtering>
390 + <directory>WebServerResources</directory>
391 + </resource>
392 + </resources>
393 + <plugins>
394 + <plugin>
395 + <groupId>org.apache.maven.plugins</groupId>
396 + <artifactId>maven-compiler-plugin</artifactId>
397 + <configuration>
398 + <source>${java.target}</source>
399 + <target>${java.target}</target>
400 + </configuration>
401 + </plugin>
402 + </plugins>
403 + </build>
404 +</project>
405 +
406 +{{/code}}
407 +
408 +and CustomExtensions which has no further dependencies
409 +
410 +{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
411 +
412 +<?xml version="1.0"?>
413 +<project>
414 + <!-- parent artifact -->
415 + <parent>
416 + <artifactId>frameworks</artifactId>
417 + <groupId>com.mywostuff</groupId>
418 + <version>1.0-SNAPSHOT</version>
419 + </parent>
420 +
421 + <!-- artifact identity -->
422 + <artifactId>CustomBusinessLogic</artifactId>
423 + <groupId>com.mywostuff.frameworks</groupId>
424 +</project>
425 +
426 +{{/code}}
427 +
428 +and CustomBusinessLogic (which has a further dependency on CustomExtensions)
429 +
430 +{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
431 +
432 +<?xml version="1.0"?>
433 +<project>
434 + <!-- parent artifact -->
435 + <parent>
436 + <artifactId>frameworks</artifactId>
437 + <groupId>com.mywostuff</groupId>
438 + <version>1.0-SNAPSHOT</version>
439 + </parent>
440 +
441 + <!-- artifact identity -->
442 + <artifactId>CustomBusinessLogic</artifactId>
443 + <groupId>com.mywostuff.frameworks</groupId>
444 +
445 + <!-- specific dependencies -->
446 + <dependencies>
447 + <dependency>
448 + <artifactId>CustomExtensions</artifactId>
449 + <groupId>${pom.groupId}</groupId>
450 + </dependency>
451 + </dependencies>
452 +</project>
453 +
454 +{{/code}}
455 +
117 117  === Packaging Applications ===
118 118  
119 119  details to come...
120 120  
460 +=== Packaging Applications as True WAR ===
461 +
462 +You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]].
463 +
464 +more details to come...
465 +
121 121  === Project Inheritance ===
122 122  
123 123  details to come...