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

From version 12.1
edited by Lachlan Deck
on 2008/06/15 18:39
Change comment: Continuing to flesh it out...
To version 6.1
edited by Lachlan Deck
on 2008/06/23 18:51
Change comment: Adding example for frameworks as Jars.

Summary

Details

Page properties
Content
... ... @@ -2,7 +2,7 @@
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  
... ... @@ -39,33 +39,51 @@
39 39  Typical things that make up a pom are as follows. (Note: only pom identification is mandatory. All the others have defaults.)
40 40  
41 41  1. pom identification (who am I?)
42 - The base triplet used to identify an artifact (i.e., product)
43 - {{noformat}}
42 +The base triplet used to identify an artifact (i.e., product)
43 +
44 +{{noformat}}
45 +
44 44   <artifactId>CustomExtensions</artifactId>
45 45   <groupId>com.mywostuff.frameworks</groupId>
46 46   <version>0.0.1-SNAPSHOT</version>
47 - {{/noformat}}
49 +
50 +{{/noformat}}
51 +
48 48  1. pom packaging (i.e., what are we building?)
49 - 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)
50 - {{noformat}}
53 +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)
54 +
55 +{{noformat}}
56 +
51 51   <packaging>woapplication</artifactId>
52 - {{/noformat}}
58 +
59 +{{/noformat}}
60 +
53 53  1. pom parent identification (who do I belong to?)
54 - {{noformat}}
62 +
63 +{{noformat}}
64 +
55 55   <parent>
56 56   <artifactId>frameworks</artifactId>
57 57   <groupId>com.mywostuff</groupId>
58 58   </parent>
59 - {{/noformat}}
69 +
70 +{{/noformat}}
71 +
60 60  1. modules (a.k.a kids; who belongs to me?)
61 - {{noformat}}
73 +
74 +{{noformat}}
75 +
62 62   <modules>
63 63   <module>CustomExtensions</module>
64 64   <module>CustomBusinessLogic</module>
65 65   </modules>
66 - {{/noformat}}
80 +
81 +{{/noformat}}
82 +
67 67  1. dependencies (what do I need?)
68 - {{noformat}}
84 +
85 +{{noformat}}
86 +
69 69   <dependencies>
70 70   <dependency>
71 71   <groupId>log4j</groupId>
... ... @@ -80,13 +80,15 @@
80 80   <scope>test</scope>
81 81   </dependency>
82 82   </dependencies>
83 - {{/noformat}}
101 +
102 +{{/noformat}}
103 +
84 84  1. build sources/resources (what do I have?)
85 85  1. properties and filtering resources (variable definitions)
86 86  1. dependency/plugin management (shared configuration and versioning)
87 87  1. repositories (where to find dependencies and plugins)
88 88  
89 -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.
109 +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.
90 90  
91 91  === Alternate File System Layout Concepts ===
92 92  
... ... @@ -146,20 +146,297 @@
146 146  
147 147  === Project Dependencies Concepts ===
148 148  
149 -Most projects, of course, have dependencies on other libraries or frameworks.
169 +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]].
150 150  
151 -=== Project Dependencies Prerequisites ===
171 +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.
152 152  
153 -details to come...
173 +{{noformat}}
154 154  
175 + <dependencies>
176 + <dependency>
177 + <artifactId>CustomExtensions</artifactId>
178 + <groupId>com.mywostuff.frameworks</groupId>
179 + <version>0.0.1-SNAPSHOT</version>
180 + <scope>compile</scope>
181 + </dependency>
182 + <dependency>
183 + <groupId>log4j</groupId>
184 + <artifactId>log4j</artifactId>
185 + <version>1.2.12</version>
186 + <scope>compile</scope>
187 + </dependency>
188 + <dependency>
189 + <groupId>junit</groupId>
190 + <artifactId>junit</artifactId>
191 + <version>4.4</version>
192 + <scope>test</scope>
193 + </dependency>
194 + </dependencies>
195 +
196 +{{/noformat}}
197 +
198 +=== Repositories ===
199 +
200 +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]].,,
201 +
202 +{{noformat}}
203 +
204 +<repositories>
205 + <repository>
206 + <id>system-repo</id>
207 + <name>internal repository</name>
208 + <!-- TODO switch over to your intranet.domain -->
209 + <url>file://${user.home}/.myarchiva</url>
210 + <snapshots>
211 + <enabled>true</enabled>
212 + <updatePolicy>always</updatePolicy>
213 + <checksumPolicy>ignore</checksumPolicy>
214 + </snapshots>
215 + <releases>
216 + <enabled>true</enabled>
217 + <updatePolicy>always</updatePolicy>
218 + <checksumPolicy>ignore</checksumPolicy>
219 + </releases>
220 + </repository>
221 + <repository>
222 + <id>maven2-repository.dev.java.net</id>
223 + <name>Java.net Repository for Maven</name>
224 + <url>http://download.java.net/maven/2</url>
225 + <snapshots>
226 + <enabled>true</enabled>
227 + <updatePolicy>daily</updatePolicy>
228 + </snapshots>
229 + <releases>
230 + <enabled>true</enabled>
231 + <updatePolicy>daily</updatePolicy>
232 + </releases>
233 + </repository>
234 + <repository>
235 + <id>webobjects.mdimension.com/releases</id>
236 + <name>mdimension maven 2 releases repo</name>
237 + <url>http://webobjects.mdimension.com/maven2/releases</url>
238 + <snapshots>
239 + <enabled>false</enabled>
240 + </snapshots>
241 + <releases>
242 + <enabled>true</enabled>
243 + </releases>
244 + </repository>
245 + <repository>
246 + <id>webobjects.mdimension.com/snapshots</id>
247 + <name>mdimension maven 2 snapshots repo</name>
248 + <url>http://webobjects.mdimension.com/maven2/snapshots</url>
249 + <snapshots>
250 + <enabled>true</enabled>
251 + </snapshots>
252 + <releases>
253 + <enabled>false</enabled>
254 + </releases>
255 + </repository>
256 + <repository>
257 + <id>objectstyle-maven2</id>
258 + <name>objectstyle maven2 repo</name>
259 + <url>http://objectstyle.org/maven2</url>
260 + <snapshots>
261 + <enabled>false</enabled>
262 + </snapshots>
263 + <releases>
264 + <enabled>true</enabled>
265 + </releases>
266 + </repository>
267 +</repositories>
268 +
269 +{{/noformat}}
270 +
271 +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]].
272 +
155 155  === Packaging Frameworks as Jars ===
156 156  
157 -details to come...
275 +Here's the definition for /frameworks/pom.xml.
158 158  
277 +{{code title="/frameworks/pom.xml"}}
278 +
279 +<?xml version="1.0" encoding="UTF-8"?>
280 +<project xmlns="http://maven.apache.org/POM/4.0.0"
281 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
282 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
283 + http://maven.apache.org/xsd/maven-4.0.0.xsd">
284 +
285 + <modelVersion>4.0.0</modelVersion>
286 +
287 + <!-- parent artifact -->
288 + <parent>
289 + <artifactId>mywostuff</artifactId>
290 + <groupId>com</groupId>
291 + <version>1.0-SNAPSHOT</version>
292 + </parent>
293 +
294 + <!-- artifact identity -->
295 + <artifactId>frameworks</artifactId>
296 + <groupId>com.mywostuff</groupId>
297 + <packaging>pom</packaging>
298 +
299 + <!-- framework relevant properties -->
300 + <properties>
301 + <!-- NS related properties fills in Info.plist etc-->
302 + <CFBundleDevelopmentRegion>English</CFBundleDevelopmentRegion>
303 + <CFBundleGetInfoString></CFBundleGetInfoString>
304 + <CFBundlePackageType>FMWK</CFBundlePackageType>
305 + <CFBundleIconFile>WOAfile.icns</CFBundleIconFile>
306 + <CFBundleInfoDictionaryVersion>6.0</CFBundleInfoDictionaryVersion>
307 + <CFBundleVersion>5.3.1</CFBundleVersion>
308 + <Has_WOComponents>true</Has_WOComponents>
309 + <NSPrincipalClass>${mainclass}</NSPrincipalClass>
310 + <NSResourcesBundlePath></NSResourcesBundlePath>
311 + </properties>
312 +
313 + <!-- modules -->
314 + <modules>
315 + <module>CustomExtensions</module>
316 + <module>CustomBusinessLogic</module>
317 + </modules>
318 +
319 + <!-- specific dependencies (for modules) -->
320 + <dependencies>
321 + <dependency>
322 + <artifactId>ERExtensions</artifactId>
323 + <groupId>${wonder.common.groupId}</groupId>
324 + </dependency>
325 + <dependency>
326 + <artifactId>JavaWOExtensions</artifactId>
327 + <groupId>${wonder.common.groupId}</groupId>
328 + </dependency>
329 + <dependency>
330 + <artifactId>JavaFoundation</artifactId>
331 + <groupId>${webobjects.groupId}</groupId>
332 + </dependency>
333 + <dependency>
334 + <artifactId>JavaJDBCAdaptor</artifactId>
335 + <groupId>${webobjects.groupId}</groupId>
336 + </dependency>
337 + <dependency>
338 + <artifactId>JavaWebObjects</artifactId>
339 + <groupId>${webobjects.groupId}</groupId>
340 + </dependency>
341 + <dependency>
342 + <artifactId>JavaEOControl</artifactId>
343 + <groupId>${webobjects.groupId}</groupId>
344 + </dependency>
345 + <dependency>
346 + <artifactId>JavaEOAccess</artifactId>
347 + <groupId>${webobjects.groupId}</groupId>
348 + </dependency>
349 + <dependency>
350 + <artifactId>JavaWebObjects</artifactId>
351 + <groupId>${webobjects.groupId}</groupId>
352 + </dependency>
353 + <dependency>
354 + <artifactId>JavaXML</artifactId>
355 + <groupId>${webobjects.groupId}</groupId>
356 + </dependency>
357 + </dependencies>
358 +
359 +
360 + <!-- build config (for modules) -->
361 + <build>
362 + <sourceDirectory>src</sourceDirectory>
363 + <testSourceDirectory>tests</testSourceDirectory>
364 + <resources>
365 + <!-- relative dir for Info.plist -->
366 + <resource>
367 + <targetPath>Resources</targetPath>
368 + <filtering>true</filtering>
369 + <directory>../src/main/resources</directory>
370 + </resource>
371 + <resource>
372 + <targetPath>Resources</targetPath>
373 + <filtering>false</filtering>
374 + <directory>Components</directory>
375 + </resource>
376 + <resource>
377 + <targetPath>Resources</targetPath>
378 + <filtering>false</filtering>
379 + <directory>Resources</directory>
380 + </resource>
381 + <resource>
382 + <targetPath>WebServerResources</targetPath>
383 + <filtering>false</filtering>
384 + <directory>WebServerResources</directory>
385 + </resource>
386 + </resources>
387 + <plugins>
388 + <plugin>
389 + <groupId>org.apache.maven.plugins</groupId>
390 + <artifactId>maven-compiler-plugin</artifactId>
391 + <configuration>
392 + <source>${java.target}</source>
393 + <target>${java.target}</target>
394 + </configuration>
395 + </plugin>
396 + </plugins>
397 + </build>
398 +</project>
399 +
400 +{{/code}}
401 +
402 +and CustomExtensions which has no further dependencies
403 +
404 +{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
405 +
406 +<?xml version="1.0"?>
407 +<project>
408 + <!-- parent artifact -->
409 + <parent>
410 + <artifactId>frameworks</artifactId>
411 + <groupId>com.mywostuff</groupId>
412 + <version>1.0-SNAPSHOT</version>
413 + </parent>
414 +
415 + <!-- artifact identity -->
416 + <artifactId>CustomBusinessLogic</artifactId>
417 + <groupId>com.mywostuff.frameworks</groupId>
418 +</project>
419 +
420 +{{/code}}
421 +
422 +and CustomBusinessLogic (which has a further dependency on CustomExtensions)
423 +
424 +{{code title="/frameworks/CustomBusinessLogic/pom.xml"}}
425 +
426 +<?xml version="1.0"?>
427 +<project>
428 + <!-- parent artifact -->
429 + <parent>
430 + <artifactId>frameworks</artifactId>
431 + <groupId>com.mywostuff</groupId>
432 + <version>1.0-SNAPSHOT</version>
433 + </parent>
434 +
435 + <!-- artifact identity -->
436 + <artifactId>CustomBusinessLogic</artifactId>
437 + <groupId>com.mywostuff.frameworks</groupId>
438 +
439 + <!-- specific dependencies -->
440 + <dependencies>
441 + <dependency>
442 + <artifactId>CustomExtensions</artifactId>
443 + <groupId>${pom.groupId}</groupId>
444 + </dependency>
445 + </dependencies>
446 +</project>
447 +
448 +{{/code}}
449 +
159 159  === Packaging Applications ===
160 160  
161 161  details to come...
162 162  
454 +=== Packaging Applications as True WAR ===
455 +
456 +You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]].
457 +
458 +more details to come...
459 +
163 163  === Project Inheritance ===
164 164  
165 165  details to come...