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

From version 16.1
edited by Lachlan Deck
on 2008/06/11 19:46
Change comment: There is no comment for this version
To version 19.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
... ... @@ -1,35 +1,204 @@
1 -So you're interested in //kicking the maven tyres//, so to speak. It's worth doing some 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/.
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 -But let's assume you want to try it without having to change your current project structure. Maven has what it calls //standards//, such as the [[standard directory layout>>http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html_standard]] but there are numerous options for subverting or extending those standards in order to suit other needs.
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/].
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 +
11 +{{/info}}
12 +
13 +=== What's the aim ===
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, or the file layout, and of course they each may have something distinctive about them.
16 +
17 +The layout of the frameworks and applications might look like this:
18 +
19 +{{noformat}}
20 +
21 +/trunk/
22 +/trunk/apps/
23 +/trunk/apps/ApplicationA/
24 +/trunk/apps/ApplicationB/
25 +/trunk/frameworks/
26 +/trunk/frameworks/CustomExtensions/
27 +/trunk/frameworks/CustomBusinessLogic/
28 +/trunk/frameworks/etc/
29 +
30 +{{/noformat}}
31 +
32 +Our aim is twofold:
33 +
34 +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.
35 +1. Be able to issue a single command that will package each and every framework and application.
36 +
37 +=== Key Concepts ===
38 +
39 +Typical things that make up a pom are as follows. (Note: only pom identification is mandatory. All the others have defaults.)
40 +
41 +1. pom identification (who am I?)
42 +The base triplet used to identify an artifact (i.e., product)
43 +
44 +{{noformat}}
45 +
46 + <artifactId>CustomExtensions</artifactId>
47 + <groupId>com.mywostuff.frameworks</groupId>
48 + <version>0.0.1-SNAPSHOT</version>
49 +
50 +
51 +{{/noformat}}
52 +
53 +1. pom packaging (i.e., what are we building?)
54 +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)
55 +
56 +{{noformat}}
57 +
58 + <packaging>woapplication</artifactId>
59 +
60 +
61 +{{/noformat}}
62 +
63 +1. pom parent identification (who do I belong to?)
64 +
65 +{{noformat}}
66 +
67 + <parent>
68 + <artifactId>frameworks</artifactId>
69 + <groupId>com.mywostuff</groupId>
70 + </parent>
71 +
72 +
73 +{{/noformat}}
74 +
75 +1. modules (a.k.a kids; who belongs to me?)
76 +
77 +{{noformat}}
78 +
79 + <modules>
80 + <module>CustomExtensions</module>
81 + <module>CustomBusinessLogic</module>
82 + </modules>
83 +
84 +
85 +{{/noformat}}
86 +
87 +1. dependencies (what do I need?)
88 +
89 +{{noformat}}
90 +
91 + <dependencies>
92 + <dependency>
93 + <groupId>log4j</groupId>
94 + <artifactId>log4j</artifactId>
95 + <version>1.2.12</version>
96 + <scope>compile</scope>
97 + </dependency>
98 + <dependency>
99 + <groupId>junit</groupId>
100 + <artifactId>junit</artifactId>
101 + <version>4.4</version>
102 + <scope>test</scope>
103 + </dependency>
104 + </dependencies>
105 +
106 +
107 +{{/noformat}}
108 +
109 +1. build sources/resources (what do I have?)
110 +1. properties and filtering resources (variable definitions)
111 +1. dependency/plugin management (shared configuration and versioning)
112 +1. repositories (where to find dependencies and plugins)
113 +
114 +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.
115 +
116 +=== Alternate File System Layout Concepts ===
117 +
118 +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.
119 +
120 +{{tip title="Mavan Model Reference Doco"}}
121 +
122 +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].
123 +
124 +{{/tip}}
125 +
126 +The following roughly resembles the current WebObjects WOLips produced project layout (a.k.a Fluffy Bunny layout).
127 +
128 +{{noformat}}
129 +
130 +/MyProject
131 +/MyProject/Components
132 +/MyProject/Resources
133 +/MyProject/Sources
134 +/MyProject/Tests
135 +/MyProject/WebServerResources
136 +
137 +{{/noformat}}
138 +
139 +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)
140 +
5 5  {{code title="pom.xml"}}
6 6  
7 7  <...>
8 8   <build>
9 - <sourceDirectory>src</sourceDirectory>
10 - <testSourceDirectory>tests</testSourceDirectory>
145 + <sourceDirectory>Sources</sourceDirectory>
146 + <testSourceDirectory>Tests</testSourceDirectory>
11 11   <resources>
12 12   <resource>
13 - <resource>
14 - <targetPath>Resources</targetPath>
15 - <filtering>false</filtering>
16 - <directory>Components</directory>
17 - </resource>
18 - <resource>
19 - <targetPath>Resources</targetPath>
20 - <filtering>false</filtering>
21 - <directory>Resources</directory>
22 - </resource>
23 - <resource>
24 - <targetPath>WebServerResources</targetPath>
25 - <filtering>false</filtering>
26 - <directory>WebServerResources</directory>
27 - </resource>
149 + <targetPath>Resources</targetPath>
150 + <filtering>false</filtering>
151 + <directory>Components</directory>
28 28   </resource>
153 + <resource>
154 + <targetPath>Resources</targetPath>
155 + <filtering>false</filtering>
156 + <directory>Resources</directory>
157 + </resource>
158 + <resource>
159 + <targetPath>WebServerResources</targetPath>
160 + <filtering>false</filtering>
161 + <directory>WebServerResources</directory>
162 + </resource>
29 29   </resources>
164 + <...>
30 30   </build>
31 31  <...>
32 32  
33 33  {{/code}}
34 34  
170 +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).
171 +
172 +=== Project Dependencies Concepts ===
173 +
174 +Most projects, of course, have dependencies on other libraries or frameworks.
175 +
176 +=== Project Dependencies Prerequisites ===
177 +
178 +details to come...
179 +
180 +=== Packaging Frameworks as Jars ===
181 +
182 +details to come...
183 +
184 +=== Packaging Applications ===
185 +
186 +details to come...
187 +
188 +=== Packaging Applications as True WAR ===
189 +
190 +You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]].
191 +
35 35  more details to come...
193 +
194 +=== Project Inheritance ===
195 +
196 +details to come...
197 +
198 +=== Eclipse Integration ===
199 +
200 +details to come...
201 +
202 +=== Putting It All Together ===
203 +
204 +details to come...