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

From version 23.1
edited by Lachlan Deck
on 2008/07/03 00:05
Change comment: Adding basic info and links for further info on project inheritance
To version 18.1
edited by Henrique Prange
on 2008/06/15 19:35
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ldeck
1 +XWiki.hprange
Content
... ... @@ -10,12 +10,6 @@
10 10  
11 11  {{/info}}
12 12  
13 -{{tip title="Hang in there"}}
14 -
15 -This particular guide might look long but some of the xml is duplicated a few times to show differing examples.
16 -
17 -{{/tip}}
18 -
19 19  === What's the aim ===
20 20  
21 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.
... ... @@ -53,6 +53,7 @@
53 53   <groupId>com.mywostuff.frameworks</groupId>
54 54   <version>0.0.1-SNAPSHOT</version>
55 55  
50 +
56 56  {{/noformat}}
57 57  
58 58  1. pom packaging (i.e., what are we building?)
... ... @@ -62,6 +62,7 @@
62 62  
63 63   <packaging>woapplication</artifactId>
64 64  
60 +
65 65  {{/noformat}}
66 66  
67 67  1. pom parent identification (who do I belong to?)
... ... @@ -73,6 +73,7 @@
73 73   <groupId>com.mywostuff</groupId>
74 74   </parent>
75 75  
72 +
76 76  {{/noformat}}
77 77  
78 78  1. modules (a.k.a kids; who belongs to me?)
... ... @@ -84,6 +84,7 @@
84 84   <module>CustomBusinessLogic</module>
85 85   </modules>
86 86  
84 +
87 87  {{/noformat}}
88 88  
89 89  1. dependencies (what do I need?)
... ... @@ -105,6 +105,7 @@
105 105   </dependency>
106 106   </dependencies>
107 107  
106 +
108 108  {{/noformat}}
109 109  
110 110  1. build sources/resources (what do I have?)
... ... @@ -172,526 +172,30 @@
172 172  
173 173  === Project Dependencies Concepts ===
174 174  
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]].
174 +Most projects, of course, have dependencies on other libraries or frameworks.
176 176  
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.
176 +=== Project Dependencies Prerequisites ===
178 178  
179 -{{noformat}}
178 +details to come...
180 180  
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 -=== Project Inheritance ===
205 -
206 -It naturally gets a bit boring having to define the same things over and over again. So, you can utilise a parent pom file specifying its packaging as 'pom'. Dependencies, plugins and executions, resources specifications and so forth can be defined once and shared by any sub-modules. See [[http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Inheritance]] and [[Java World's The Maven 2 POM demystified>>http://www.javaworld.com/javaworld/jw-05-2006/jw-0529-maven.html]] for further information and examples.
207 -
208 -For our example we'll have trunk/pom.xml which will define everything common to any and all modules in the hierarchy. Likewise, trunk/frameworks/pom.xml and trunk/apps/pom.xml will define everything common to frameworks and applications respecively.
209 -
210 -=== Repositories ===
211 -
212 -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]].
213 -
214 -{{noformat}}
215 -
216 -<repositories>
217 - <repository>
218 - <id>system-repo</id>
219 - <name>internal repository</name>
220 - <!-- TODO switch over to your intranet.domain -->
221 - <url>file://${user.home}/.myarchiva</url>
222 - <snapshots>
223 - <enabled>true</enabled>
224 - <updatePolicy>always</updatePolicy>
225 - <checksumPolicy>ignore</checksumPolicy>
226 - </snapshots>
227 - <releases>
228 - <enabled>true</enabled>
229 - <updatePolicy>always</updatePolicy>
230 - <checksumPolicy>ignore</checksumPolicy>
231 - </releases>
232 - </repository>
233 - <repository>
234 - <id>maven2-repository.dev.java.net</id>
235 - <name>Java.net Repository for Maven</name>
236 - <url>http://download.java.net/maven/2</url>
237 - <snapshots>
238 - <enabled>true</enabled>
239 - <updatePolicy>daily</updatePolicy>
240 - </snapshots>
241 - <releases>
242 - <enabled>true</enabled>
243 - <updatePolicy>daily</updatePolicy>
244 - </releases>
245 - </repository>
246 - <repository>
247 - <id>webobjects.mdimension.com/releases</id>
248 - <name>mdimension maven 2 releases repo</name>
249 - <url>http://webobjects.mdimension.com/maven2/releases</url>
250 - <snapshots>
251 - <enabled>false</enabled>
252 - </snapshots>
253 - <releases>
254 - <enabled>true</enabled>
255 - </releases>
256 - </repository>
257 - <repository>
258 - <id>webobjects.mdimension.com/snapshots</id>
259 - <name>mdimension maven 2 snapshots repo</name>
260 - <url>http://webobjects.mdimension.com/maven2/snapshots</url>
261 - <snapshots>
262 - <enabled>true</enabled>
263 - </snapshots>
264 - <releases>
265 - <enabled>false</enabled>
266 - </releases>
267 - </repository>
268 - <repository>
269 - <id>objectstyle-maven2</id>
270 - <name>objectstyle maven2 repo</name>
271 - <url>http://objectstyle.org/maven2</url>
272 - <snapshots>
273 - <enabled>false</enabled>
274 - </snapshots>
275 - <releases>
276 - <enabled>true</enabled>
277 - </releases>
278 - </repository>
279 -</repositories>
280 -
281 -{{/noformat}}
282 -
283 -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]].
284 -
285 285  === Packaging Frameworks as Jars ===
286 286  
287 -Here's the definition for /frameworks/pom.xml. Note that it depends on the following Info.plist file being located under trunk/frameworks/src/main/resources:
182 +details to come...
288 288  
289 -{{attachments patterns="Info.plist" upload="false"}}{{/attachments}}
290 -
291 -{{code title="/frameworks/pom.xml"}}
292 -
293 -<?xml version="1.0" encoding="UTF-8"?>
294 -<project xmlns="http://maven.apache.org/POM/4.0.0"
295 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
296 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
297 - http://maven.apache.org/xsd/maven-4.0.0.xsd">
298 -
299 - <modelVersion>4.0.0</modelVersion>
300 -
301 - <!-- parent artifact -->
302 - <parent>
303 - <artifactId>mywostuff</artifactId>
304 - <groupId>com</groupId>
305 - <version>1.0-SNAPSHOT</version>
306 - </parent>
307 -
308 - <!-- artifact identity -->
309 - <artifactId>frameworks</artifactId>
310 - <groupId>com.mywostuff</groupId>
311 - <packaging>pom</packaging>
312 -
313 - <!-- framework relevant properties -->
314 - <properties>
315 - <!-- NS related properties fills in Info.plist etc-->
316 - <CFBundleDevelopmentRegion>English</CFBundleDevelopmentRegion>
317 - <CFBundleGetInfoString></CFBundleGetInfoString>
318 - <CFBundlePackageType>FMWK</CFBundlePackageType>
319 - <CFBundleIconFile>WOAfile.icns</CFBundleIconFile>
320 - <CFBundleInfoDictionaryVersion>6.0</CFBundleInfoDictionaryVersion>
321 - <CFBundleVersion>5.3.1</CFBundleVersion>
322 - <Has_WOComponents>true</Has_WOComponents>
323 - <NSPrincipalClass>${mainclass}</NSPrincipalClass>
324 - <NSResourcesBundlePath></NSResourcesBundlePath>
325 - </properties>
326 -
327 - <!-- modules -->
328 - <modules>
329 - <module>CustomExtensions</module>
330 - <module>CustomBusinessLogic</module>
331 - </modules>
332 -
333 - <!-- specific dependencies (for modules) -->
334 - <dependencies>
335 - <dependency>
336 - <artifactId>ERExtensions</artifactId>
337 - <groupId>${wonder.common.groupId}</groupId>
338 - </dependency>
339 - <dependency>
340 - <artifactId>JavaWOExtensions</artifactId>
341 - <groupId>${wonder.common.groupId}</groupId>
342 - </dependency>
343 - <dependency>
344 - <artifactId>JavaFoundation</artifactId>
345 - <groupId>${webobjects.groupId}</groupId>
346 - </dependency>
347 - <dependency>
348 - <artifactId>JavaJDBCAdaptor</artifactId>
349 - <groupId>${webobjects.groupId}</groupId>
350 - </dependency>
351 - <dependency>
352 - <artifactId>JavaWebObjects</artifactId>
353 - <groupId>${webobjects.groupId}</groupId>
354 - </dependency>
355 - <dependency>
356 - <artifactId>JavaEOControl</artifactId>
357 - <groupId>${webobjects.groupId}</groupId>
358 - </dependency>
359 - <dependency>
360 - <artifactId>JavaEOAccess</artifactId>
361 - <groupId>${webobjects.groupId}</groupId>
362 - </dependency>
363 - <dependency>
364 - <artifactId>JavaWebObjects</artifactId>
365 - <groupId>${webobjects.groupId}</groupId>
366 - </dependency>
367 - <dependency>
368 - <artifactId>JavaXML</artifactId>
369 - <groupId>${webobjects.groupId}</groupId>
370 - </dependency>
371 - </dependencies>
372 -
373 -
374 - <!-- build config (for modules) -->
375 - <build>
376 - <sourceDirectory>src</sourceDirectory>
377 - <testSourceDirectory>tests</testSourceDirectory>
378 - <resources>
379 - <!-- relative dir for Info.plist -->
380 - <resource>
381 - <targetPath>Resources</targetPath>
382 - <filtering>true</filtering>
383 - <directory>../src/main/resources</directory>
384 - </resource>
385 - <resource>
386 - <targetPath>Resources</targetPath>
387 - <filtering>false</filtering>
388 - <directory>Components</directory>
389 - </resource>
390 - <resource>
391 - <targetPath>Resources</targetPath>
392 - <filtering>false</filtering>
393 - <directory>Resources</directory>
394 - </resource>
395 - <resource>
396 - <targetPath>WebServerResources</targetPath>
397 - <filtering>false</filtering>
398 - <directory>WebServerResources</directory>
399 - </resource>
400 - </resources>
401 - <plugins>
402 - <plugin>
403 - <groupId>org.apache.maven.plugins</groupId>
404 - <artifactId>maven-compiler-plugin</artifactId>
405 - <configuration>
406 - <source>${java.target}</source>
407 - <target>${java.target}</target>
408 - </configuration>
409 - </plugin>
410 - </plugins>
411 - </build>
412 -</project>
413 -
414 -{{/code}}
415 -
416 -and CustomExtensions which has no further dependencies
417 -
418 -{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
419 -
420 -<?xml version="1.0"?>
421 -<project>
422 - <!-- parent artifact -->
423 - <parent>
424 - <artifactId>frameworks</artifactId>
425 - <groupId>com.mywostuff</groupId>
426 - <version>1.0-SNAPSHOT</version>
427 - </parent>
428 -
429 - <!-- artifact identity -->
430 - <artifactId>CustomBusinessLogic</artifactId>
431 - <groupId>com.mywostuff.frameworks</groupId>
432 -</project>
433 -
434 -{{/code}}
435 -
436 -and CustomBusinessLogic (which has a further dependency on CustomExtensions)
437 -
438 -{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
439 -
440 -<?xml version="1.0"?>
441 -<project>
442 - <!-- parent artifact -->
443 - <parent>
444 - <artifactId>frameworks</artifactId>
445 - <groupId>com.mywostuff</groupId>
446 - <version>1.0-SNAPSHOT</version>
447 - </parent>
448 -
449 - <!-- artifact identity -->
450 - <artifactId>CustomBusinessLogic</artifactId>
451 - <groupId>com.mywostuff.frameworks</groupId>
452 -
453 - <!-- specific dependencies -->
454 - <dependencies>
455 - <dependency>
456 - <artifactId>CustomExtensions</artifactId>
457 - <groupId>${pom.groupId}</groupId>
458 - </dependency>
459 - </dependencies>
460 -</project>
461 -
462 -{{/code}}
463 -
464 464  === Packaging Applications ===
465 465  
466 -Here's the definition for /apps/pom.xml which is shared by any sub-modules (i.e., ApplicationA and ApplicationB).
186 +details to come...
467 467  
468 -{{code title="/apps/pom.xml"}}
188 +=== Packaging Applications as True WAR ===
469 469  
470 -<?xml version="1.0" encoding="UTF-8"?>
471 -<project xmlns="http://maven.apache.org/POM/4.0.0"
472 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
473 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
474 - http://maven.apache.org/xsd/maven-4.0.0.xsd">
190 +You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]].
475 475  
476 - <modelVersion>4.0.0</modelVersion>
192 +more details to come...
477 477  
478 - <!-- parent artifact -->
479 - <parent>
480 - <groupId>com</groupId>
481 - <artifactId>mywostuff</artifactId>
482 - <version>1.0-SNAPSHOT</version>
483 - </parent>
194 +=== Project Inheritance ===
484 484  
485 - <!-- artifact identity -->
486 - <artifactId>apps</artifactId>
487 - <groupId>com.mywostuff</groupId>
488 - <packaging>pom</packaging>
196 +details to come...
489 489  
490 - <!-- modules -->
491 - <modules>
492 - <module>ApplicationA</module>
493 - <module>ApplicationB</module>
494 - </modules>
495 -
496 - <!-- specific dependencies (for modules) -->
497 - <dependencies>
498 - <!-- wonder frameworks -->
499 - <dependency>
500 - <artifactId>ERExtensions</artifactId>
501 - <groupId>${wonder.common.groupId}</groupId>
502 - </dependency>
503 - <dependency>
504 - <artifactId>JavaWOExtensions</artifactId>
505 - <groupId>${wonder.common.groupId}</groupId>
506 - </dependency>
507 -
508 - <!-- project libs -->
509 - <dependency>
510 - <artifactId>CustomExtensions</artifactId>
511 - <groupId>${my.frameworks.groupId}</groupId>
512 - </dependency>
513 - <dependency>
514 - <artifactId>CustomBusinessLogic</artifactId>
515 - <groupId>${my.frameworks.groupId}</groupId>
516 - </dependency>
517 -
518 - <!-- webobjects dependencies -->
519 - <dependency>
520 - <artifactId>JavaFoundation</artifactId>
521 - <groupId>${webobjects.groupId}</groupId>
522 - </dependency>
523 - <dependency>
524 - <artifactId>JavaJDBCAdaptor</artifactId>
525 - <groupId>${webobjects.groupId}</groupId>
526 - </dependency>
527 - <dependency>
528 - <artifactId>JavaWebObjects</artifactId>
529 - <groupId>${webobjects.groupId}</groupId>
530 - </dependency>
531 - <dependency>
532 - <artifactId>JavaEOControl</artifactId>
533 - <groupId>${webobjects.groupId}</groupId>
534 - </dependency>
535 - <dependency>
536 - <artifactId>JavaEOAccess</artifactId>
537 - <groupId>${webobjects.groupId}</groupId>
538 - </dependency>
539 - <dependency>
540 - <artifactId>JavaWebObjects</artifactId>
541 - <groupId>${webobjects.groupId}</groupId>
542 - </dependency>
543 - <dependency>
544 - <artifactId>JavaXML</artifactId>
545 - <groupId>${webobjects.groupId}</groupId>
546 - </dependency>
547 - </dependencies>
548 -
549 - <!-- build config (for modules) -->
550 - <build>
551 - <sourceDirectory>src</sourceDirectory>
552 - <testSourceDirectory>tests</testSourceDirectory>
553 - <resources>
554 - <resource>
555 - <targetPath>Resources</targetPath>
556 - <filtering>false</filtering>
557 - <directory>Components</directory>
558 - </resource>
559 - <resource>
560 - <targetPath>Resources</targetPath>
561 - <filtering>false</filtering>
562 - <directory>Resources</directory>
563 - </resource>
564 - <resource>
565 - <targetPath>WebServerResources</targetPath>
566 - <filtering>false</filtering>
567 - <directory>WebServerResources</directory>
568 - </resource>
569 - </resources>
570 - <plugins>
571 - <plugin>
572 - <artifactId>maven-wolifecycle-plugin</artifactId>
573 - <groupId>org.objectstyle.woproject.maven2</groupId>
574 - <version>2.0.15</version>
575 - <extensions>true</extensions>
576 - <configuration>
577 - <source>${java.target}</source>
578 - <target>${java.target}</target>
579 - </configuration>
580 - </plugin>
581 - <plugin>
582 - <groupId>org.apache.maven.plugins</groupId>
583 - <artifactId>maven-javadoc-plugin</artifactId>
584 - <configuration>
585 - <javadocVersion>${java.target}</javadocVersion>
586 - <locale>en-AU</locale>
587 - <minmemory>128m</minmemory>
588 - <maxmemory>512m</maxmemory>
589 - </configuration>
590 - </plugin>
591 - <!--
592 - TODO build numbering
593 - <plugin>
594 - <groupId>org.codehaus.mojo</groupId>
595 - <artifactId>maven-buildnumber-plugin</artifactId>
596 - <version>0.9.6</version>
597 - <executions>
598 - <execution>
599 - <phase>validate</phase>
600 - <goals>
601 - <goal>create</goal>
602 - </goals>
603 - </execution>
604 - </executions>
605 - <configuration>
606 - <doCheck>true</doCheck>
607 - <doUpdate>true</doUpdate>
608 - </configuration>
609 - </plugin>
610 - -->
611 - </plugins>
612 - <pluginManagement>
613 - <plugins>
614 - <plugin>
615 - <groupId>org.apache.maven.plugins</groupId>
616 - <artifactId>maven-compiler-plugin</artifactId>
617 - <configuration>
618 - <source>${java.target}</source>
619 - <target>${java.target}</target>
620 - </configuration>
621 - </plugin>
622 - </plugins>
623 - </pluginManagement>
624 - </build>
625 -</project>
626 -
627 -{{/code}}
628 -
629 -and ApplicationA - which has a couple of extra specific dependencies to add to those inherited from its parent.
630 -
631 -{{code title="/apps/ApplicationA/pom.xml"}}
632 -
633 -<?xml version="1.0"?>
634 -<project>
635 - <modelVersion>4.0.0</modelVersion>
636 -
637 - <!-- parent artifact -->
638 - <parent>
639 - <artifactId>apps</artifactId>
640 - <groupId>com.mywostuff</groupId>
641 - <version>1.0-SNAPSHOT</version>
642 - <relativePath>../apps</relativePath> <!-- e.g., (optional) if your app is under /trunk -->
643 - </parent>
644 -
645 - <!-- artifact identity -->
646 - <artifactId>ApplicationA</artifactId>
647 - <groupId>com.mywostuff.apps</groupId>
648 - <packaging>woapplication</packaging> <!-- woproject specific packaging -->
649 -
650 - <!-- specific properties -->
651 - <properties>
652 - <!-- general properties -->
653 - <mainclass>your.app.Application</mainclass>
654 - </properties>
655 -
656 - <!-- specific dependencies -->
657 - <dependencies>
658 - <!-- wonder frameworks -->
659 - <dependency>
660 - <artifactId>Ajax</artifactId>
661 - <groupId>${wonder.ajax.groupId}</groupId>
662 - </dependency>
663 - <dependency>
664 - <artifactId>ERCaptcha</artifactId>
665 - <groupId>${wonder.common.groupId}</groupId>
666 - <!-- requires jcaptcha-all below -->
667 - </dependency>
668 - <dependency>
669 - <artifactId>WOOgnl</artifactId>
670 - <groupId>${wonder.common.groupId}</groupId>
671 - </dependency>
672 -
673 - <!-- general libs -->
674 - <dependency>
675 - <artifactId>jcaptcha-all</artifactId>
676 - <groupId>com.octo.captcha</groupId>
677 - </dependency>
678 - <dependency>
679 - <artifactId>commons-collections</artifactId>
680 - <groupId>commons-collections</groupId>
681 - </dependency>
682 - <dependency>
683 - <groupId>ognl</groupId>
684 - <artifactId>ognl</artifactId>
685 - </dependency>
686 - </dependencies>
687 -</project>
688 -
689 -{{/code}}
690 -
691 -=== Packaging Applications as True WAR ===
692 -
693 -You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]].
694 -
695 695  === Eclipse Integration ===
696 696  
697 697  details to come...