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

From version 25.1
edited by Lachlan Deck
on 2008/07/03 00:07
Change comment: Fixing list numbering
To version 27.1
edited by pierce
on 2008/07/03 14:25
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ldeck
1 +XWiki.pierce
Content
... ... @@ -1,25 +1,33 @@
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, 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 +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>>url:http://maven.apache.org||shape="rect"]]. Various guides are also found at [[http:~~/~~/maven.apache.org/guides/>>url:http://maven.apache.org/guides/||shape="rect"]].
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/].
6 +At the very least you want to have read through, and understood, the [[Getting Started Tutorial>>url:http://maven.apache.org/guides/getting-started/index.html||shape="rect"]].
6 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 -
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 -
8 +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>>url:http://maven.apache.org/users/getting-help.html||shape="rect"]].
11 11  {{/info}}
12 12  
13 13  {{tip title="Hang in there"}}
14 -
15 15  This particular guide might look long but some of the xml is duplicated a few times to show differing examples.
16 -
17 17  {{/tip}}
18 18  
19 -=== What's the aim ===
15 +=== Why Maven ===
20 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.
17 +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. In addition, those frameworks or libraries will themselves often depend on third party frameworks like apache commons, log4j, or WebObjects.
22 22  
19 +It can be extraordinarily tedious to manage downloading, installing, compiling, and packaging these dependencies. Just finding a particular version of commons-logging-1.1.jar can take 20 minutes. Then everyone in your workgroup has to agree where to put it, and copy it over. If you decide to update to 1.1.1, you have to talk to everyone in your workgroup again, remember to put it into production when you deploy, etc.
20 +
21 +This is not a new problem in computer science. There are other tools that attempt to solve this problem, maven just takes it beyond just the build stage into nightly builds, running tests, packaging, deploying, etc.
22 +
23 +So in essence, the goal of maven is to automate even more of the whole build/test/install process then is currently done, even to the point of downloading software needed as part of the build. In addition, maven emphasizes //standards// over //configuration//. In WebObjects terms, that's a fancy way of saying that if you put your .wo files in Components, maven will know they need to go into the Resources folder in the .woa.
24 +
25 +So while you still have to provide maven with information on the dependencies, if you use the standard locations for things, you won't have to specify much else.
26 +
27 +=== A sample build ===
28 +
29 +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.
30 +
23 23  The layout of the frameworks and applications might look like this:
24 24  
25 25  {{noformat}}
... ... @@ -35,9 +35,9 @@
35 35  
36 36  {{/noformat}}
37 37  
38 -Our aim is twofold:
46 +This is a pretty standard way for many WO developers to group their projects. Framework projects go into frameworks, apps into apps. We can leverage that standard layout to accomplish two things:
39 39  
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.
48 +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. This makes the child pom.xml files simpler.
41 41  1. Be able to issue a single command that will package each and every framework and application.
42 42  
43 43  === Key Concepts ===
... ... @@ -45,51 +45,29 @@
45 45  Typical things that make up a pom are as follows. (Note: only pom identification is mandatory. All the others have defaults.)
46 46  
47 47  1. pom identification (who am I?)
48 -The base triplet used to identify an artifact (i.e., product)
49 -
50 -{{noformat}}
51 -
56 + The base triplet used to identify an artifact (i.e., something you need to build/package/install)
57 +1. {{noformat}}
52 52   <artifactId>CustomExtensions</artifactId>
53 53   <groupId>com.mywostuff.frameworks</groupId>
54 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 -
61 +{{/noformat}}pom packaging (i.e., what are we building?)
62 + 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)
63 +1. {{noformat}}
63 63   <packaging>woapplication</artifactId>
64 -
65 -{{/noformat}}
66 -
67 -1. pom parent identification (who do I belong to?)
68 -
69 -{{noformat}}
70 -
65 +{{/noformat}}pom parent identification (who do I belong to?)
66 +1. {{noformat}}
71 71   <parent>
72 72   <artifactId>frameworks</artifactId>
73 73   <groupId>com.mywostuff</groupId>
74 74   </parent>
75 -
76 -{{/noformat}}
77 -
78 -1. modules (a.k.a kids; who belongs to me?)
79 -
80 -{{noformat}}
81 -
71 +{{/noformat}}modules (a.k.a kids; who belongs to me?)
72 +1. {{noformat}}
82 82   <modules>
83 83   <module>CustomExtensions</module>
84 84   <module>CustomBusinessLogic</module>
85 85   </modules>
86 -
87 -{{/noformat}}
88 -
89 -1. dependencies (what do I need?)
90 -
91 -{{noformat}}
92 -
77 +{{/noformat}}dependencies (what do I need?)
78 +1. {{noformat}}
93 93   <dependencies>
94 94   <dependency>
95 95   <groupId>log4j</groupId>
... ... @@ -104,10 +104,7 @@
104 104   <scope>test</scope>
105 105   </dependency>
106 106   </dependencies>
107 -
108 -{{/noformat}}
109 -
110 -1. build sources/resources (what do I have?)
93 +{{/noformat}}build sources/resources (what do I have?)
111 111  1. properties and filtering resources (variable definitions)
112 112  1. dependency/plugin management (shared configuration and versioning)
113 113  1. repositories (where to find dependencies and plugins)
... ... @@ -116,15 +116,13 @@
116 116  
117 117  === Alternate File System Layout Concepts ===
118 118  
119 -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.
102 +As you would (i.e., should) have read by now, Maven has what it calls //standards//. One such standard is the [[standard directory layout>>url:http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html_standard||shape="rect"]]. 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.
120 120  
121 121  {{tip title="Mavan Model Reference Doco"}}
122 -
123 -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].
124 -
105 +To see what built-in options are available for maven see [[Maven Model>>url:http://maven.apache.org/ref/2.0.9/maven-model/maven.html||shape="rect"]].
125 125  {{/tip}}
126 126  
127 -The following roughly resembles the current WebObjects WOLips produced project layout (a.k.a Fluffy Bunny layout).
108 +In this case though, we're just trying to "kick the tyres", so we don't want to have to move our files around. The following roughly resembles the current WebObjects WOLips produced project layout (a.k.a Fluffy Bunny layout).
128 128  
129 129  {{noformat}}
130 130  
... ... @@ -137,9 +137,9 @@
137 137  
138 138  {{/noformat}}
139 139  
140 -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)
121 +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, we can put this in /trunk/pom.xml and then all the child pom.xml files will know we're using Fluffy Bunny Layout. Notice we've also defined the target path for each resource. (See the [[WOL:Maven Model#class_resource>>url:http://maven.apache.org/ref/2.0.9/maven-model/maven.html#class_resource||shape="rect"]] for a definition of targetPath)
141 141  
142 -{{code title="pom.xml"}}
123 +{{code title="pom.xml" 0="xml"}}
143 143  
144 144  <...>
145 145   <build>
... ... @@ -172,9 +172,9 @@
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]].
156 +Most projects, of course, have dependencies on other libraries or frameworks. See the [[WOL:Maven Getting Started#How_do_I_use_external_dependencies>>url:http://maven.apache.org/guides/getting-started/index.html#How_do_I_use_external_dependencies||shape="rect"]].
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.
158 +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 [[WOL:Maven Model#class_dependency>>url:http://maven.apache.org/ref/2.0.9/maven-model/maven.html#class_dependency||shape="rect"]] for specific definitions.
178 178  
179 179  {{noformat}}
180 180  
... ... @@ -203,13 +203,13 @@
203 203  
204 204  === Project Inheritance ===
205 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.
187 +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>>url:http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Inheritance||shape="rect"]] and [[Java World's The Maven 2 POM demystified>>url:http://www.javaworld.com/javaworld/jw-05-2006/jw-0529-maven.html||shape="rect"]] for further information and examples.
207 207  
208 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 209  
210 210  === Repositories ===
211 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]].
193 +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>>url:http://maven.apache.org/guides/introduction/introduction-to-repositories.html||shape="rect"]]. Repositories are what lets you specify, "my app needs commons-logging-1.1.1" and maven can then pull it into the build as needed. Here we're adding some additional repositories to the defaults. You might want to setup one for your workgroup, and then there are some useful WO-related ones as well. We can include this in the master trunk/pom.xml file, then all the children can use it.
213 213  
214 214  {{noformat}}
215 215  
... ... @@ -280,15 +280,15 @@
280 280  
281 281  {{/noformat}}
282 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]].
264 +Note: A remote repository is not guaranteed to keep older versions of libraries, for example, indefinitely. This is why 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>>url:http://www.theserverside.com/tt/articles/article.tss?l=SettingUpMavenRepository||shape="rect"]].
284 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:
268 +Here's the definition for /frameworks/pom.xml, definitions here will be shared by all of the individual framework pom.xml files. Note that it depends on the following Info.plist file being located under trunk/frameworks/src/main/resources (maven builds can use files stored in common off of a shared structure):
288 288  
289 -{{attachments patterns="Info.plist" upload="false"}}{{/attachments}}
270 +{{attachments patterns="Info.plist" upload="false"/}}
290 290  
291 -{{code title="/frameworks/pom.xml"}}
272 +{{code title="/frameworks/pom.xml" 0="xml"}}
292 292  
293 293  <?xml version="1.0" encoding="UTF-8"?>
294 294  <project xmlns="http://maven.apache.org/POM/4.0.0"
... ... @@ -413,9 +413,9 @@
413 413  
414 414  {{/code}}
415 415  
416 -and CustomExtensions which has no further dependencies
397 +Since our CustomExtensions has no further dependencies, its pom.xml merely specifies its parent and its identity.
417 417  
418 -{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
399 +{{code title="/frameworks/CustomBusinessLogic/pom.xml" 0="xml"}}
419 419  
420 420  <?xml version="1.0"?>
421 421  <project>
... ... @@ -433,9 +433,9 @@
433 433  
434 434  {{/code}}
435 435  
436 -and CustomBusinessLogic (which has a further dependency on CustomExtensions)
417 +CustomBusinessLogic has a further dependency on CustomExtensions, so it specifies its parent, its identity, and the dependency.
437 437  
438 -{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
419 +{{code title="/frameworks/CustomBusinessLogic/pom.xml" 0="xml"}}
439 439  
440 440  <?xml version="1.0"?>
441 441  <project>
... ... @@ -463,9 +463,9 @@
463 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).
447 +Here's the definition for /apps/pom.xml which is shared by any sub-modules (i.e., ApplicationA and ApplicationB). Both apps need certain WebObjects frameworks, so we specify those only once for both, here in the parent pom. We also specify Fluffy Bunny Layout, and some maven plugins we want to use. Again, this is for both applications.
467 467  
468 -{{code title="/apps/pom.xml"}}
449 +{{code title="/apps/pom.xml" 0="xml"}}
469 469  
470 470  <?xml version="1.0" encoding="UTF-8"?>
471 471  <project xmlns="http://maven.apache.org/POM/4.0.0"
... ... @@ -626,9 +626,9 @@
626 626  
627 627  {{/code}}
628 628  
629 -and ApplicationA - which has a couple of extra specific dependencies to add to those inherited from its parent.
610 +With most stuff specified in the parent pom, ApplicationA needs only to specify its parent, its idenity, and add a couple of extra specific dependencies to those inherited from its parent.
630 630  
631 -{{code title="/apps/ApplicationA/pom.xml"}}
612 +{{code title="/apps/ApplicationA/pom.xml" 0="xml"}}
632 632  
633 633  <?xml version="1.0"?>
634 634  <project>
... ... @@ -690,7 +690,7 @@
690 690  
691 691  === Packaging Applications as True WAR ===
692 692  
693 -You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]].
674 +You can find steps to package WO Applications as True WAR [[here>>doc:WOL.Packaging WO Applications as true WAR with Maven]].
694 694  
695 695  === Eclipse Integration ===
696 696