Changes for page Maven Kicking the tyres without changing your project structure
Last modified by Henrique Prange on 2015/09/11 17:57
From version 11.1
edited by pierce
on 2008/07/03 14:25
on 2008/07/03 14:25
Change comment:
There is no comment for this version
To version 21.1
edited by Lachlan Deck
on 2008/07/02 23:41
on 2008/07/02 23:41
Change comment:
Adding example for building WOApplications
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. pierce1 +XWiki.ldeck - Content
-
... ... @@ -16,22 +16,10 @@ 16 16 17 17 {{/tip}} 18 18 19 -=== Wh y Maven===19 +=== What's the aim === 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. In addition,those frameworksorlibrarieswillthemselves often depend on thirdpartyframeworkslike apache commons,log4j,or WebObjects.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 22 23 -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. 24 - 25 -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. 26 - 27 -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. 28 - 29 -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. 30 - 31 -=== A sample build === 32 - 33 -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. 34 - 35 35 The layout of the frameworks and applications might look like this: 36 36 37 37 {{noformat}} ... ... @@ -47,9 +47,9 @@ 47 47 48 48 {{/noformat}} 49 49 50 - This is a pretty standard way for many WOdevelopers to group theirprojects. Framework projects gointo frameworks,appsinto apps.We can leveragethat standard layout toaccomplish two things:38 +Our aim is twofold: 51 51 52 -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.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. 53 53 1. Be able to issue a single command that will package each and every framework and application. 54 54 55 55 === Key Concepts === ... ... @@ -57,7 +57,7 @@ 57 57 Typical things that make up a pom are as follows. (Note: only pom identification is mandatory. All the others have defaults.) 58 58 59 59 1. pom identification (who am I?) 60 -The base triplet used to identify an artifact (i.e., something you needto build/package/install)48 +The base triplet used to identify an artifact (i.e., product) 61 61 62 62 {{noformat}} 63 63 ... ... @@ -136,7 +136,7 @@ 136 136 137 137 {{/tip}} 138 138 139 - 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).127 +The following roughly resembles the current WebObjects WOLips produced project layout (a.k.a Fluffy Bunny layout). 140 140 141 141 {{noformat}} 142 142 ... ... @@ -149,7 +149,7 @@ 149 149 150 150 {{/noformat}} 151 151 152 -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.xmland 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//>>http://maven.apache.org/ref/2.0.9/maven-model/maven.html#class_resource]] for a definition of targetPath)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) 153 153 154 154 {{code title="pom.xml"}} 155 155 ... ... @@ -184,9 +184,9 @@ 184 184 185 185 === Project Dependencies Concepts === 186 186 187 -Most projects, of course, have dependencies on other libraries or frameworks. See the [[ WOL:Maven Getting Started#How//do//I//use//external//dependencies//>>http://maven.apache.org/guides/getting-started/index.html#How_do_I_use_external_dependencies]].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]]. 188 188 189 -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//>>http://maven.apache.org/ref/2.0.9/maven-model/maven.html#class_dependency]] for specific definitions.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. 190 190 191 191 {{noformat}} 192 192 ... ... @@ -213,15 +213,9 @@ 213 213 214 214 {{/noformat}} 215 215 216 -=== Project Inheritance === 217 - 218 -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. 219 - 220 -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. 221 - 222 222 === Repositories === 223 223 224 -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]]. 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.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]]. 225 225 226 226 {{noformat}} 227 227 ... ... @@ -292,11 +292,11 @@ 292 292 293 293 {{/noformat}} 294 294 295 -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]].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]]. 296 296 297 297 === Packaging Frameworks as Jars === 298 298 299 -Here's the definition for /frameworks/pom.xml , definitions here will be shared by all of the individual framework pom.xmlfiles.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):281 +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: 300 300 301 301 {{attachments patterns="Info.plist" upload="false"}}{{/attachments}} 302 302 ... ... @@ -425,7 +425,7 @@ 425 425 426 426 {{/code}} 427 427 428 - SinceourCustomExtensions has no further dependencies, its pom.xml merely specifies its parent and its identity.410 +and CustomExtensions which has no further dependencies 429 429 430 430 {{code title="/frameworks/CustomBusinessLogic/pom.xml"}} 431 431 ... ... @@ -445,7 +445,7 @@ 445 445 446 446 {{/code}} 447 447 448 -CustomBusinessLogic has a further dependency on CustomExtensions , so it specifies its parent, its identity, and the dependency.430 +and CustomBusinessLogic (which has a further dependency on CustomExtensions) 449 449 450 450 {{code title="/frameworks/CustomBusinessLogic/pom.xml"}} 451 451 ... ... @@ -475,7 +475,7 @@ 475 475 476 476 === Packaging Applications === 477 477 478 -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.460 +Here's the definition for /apps/pom.xml which is shared by any sub-modules (i.e., ApplicationA and ApplicationB). 479 479 480 480 {{code title="/apps/pom.xml"}} 481 481 ... ... @@ -484,7 +484,7 @@ 484 484 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 485 485 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 486 486 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 487 - 469 + 488 488 <modelVersion>4.0.0</modelVersion> 489 489 490 490 <!-- parent artifact --> ... ... @@ -516,7 +516,7 @@ 516 516 <artifactId>JavaWOExtensions</artifactId> 517 517 <groupId>${wonder.common.groupId}</groupId> 518 518 </dependency> 519 - 501 + 520 520 <!-- project libs --> 521 521 <dependency> 522 522 <artifactId>CustomExtensions</artifactId> ... ... @@ -526,7 +526,7 @@ 526 526 <artifactId>CustomBusinessLogic</artifactId> 527 527 <groupId>${my.frameworks.groupId}</groupId> 528 528 </dependency> 529 - 511 + 530 530 <!-- webobjects dependencies --> 531 531 <dependency> 532 532 <artifactId>JavaFoundation</artifactId> ... ... @@ -557,7 +557,7 @@ 557 557 <groupId>${webobjects.groupId}</groupId> 558 558 </dependency> 559 559 </dependencies> 560 - 542 + 561 561 <!-- build config (for modules) --> 562 562 <build> 563 563 <sourceDirectory>src</sourceDirectory> ... ... @@ -638,7 +638,7 @@ 638 638 639 639 {{/code}} 640 640 641 - With most stuff specified in the parentpom,ApplicationAneedsonly to specifyits parent, itsidenity,andadd acouple of extra specific dependencies to those inherited from its parent.623 +and ApplicationA - which has a couple of extra specific dependencies to add to those inherited from its parent. 642 642 643 643 {{code title="/apps/ApplicationA/pom.xml"}} 644 644 ... ... @@ -681,7 +681,7 @@ 681 681 <artifactId>WOOgnl</artifactId> 682 682 <groupId>${wonder.common.groupId}</groupId> 683 683 </dependency> 684 - 666 + 685 685 <!-- general libs --> 686 686 <dependency> 687 687 <artifactId>jcaptcha-all</artifactId> ... ... @@ -702,8 +702,14 @@ 702 702 703 703 === Packaging Applications as True WAR === 704 704 705 -You can find steps to package WO Applications as True WAR [[here>> WOL:Packaging WO Applications as true WAR with Maven]].687 +You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]]. 706 706 689 +more details to come... 690 + 691 +=== Project Inheritance === 692 + 693 +details to come... 694 + 707 707 === Eclipse Integration === 708 708 709 709 details to come...