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 28.1
edited by Ramsey Gurley
on 2015/09/11 17:57
on 2015/09/11 17:57
Change comment:
There is no comment for this version
To version 27.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
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.r amsey1 +XWiki.pierce - Content
-
... ... @@ -31,6 +31,7 @@ 31 31 The layout of the frameworks and applications might look like this: 32 32 33 33 {{noformat}} 34 + 34 34 /trunk/ 35 35 /trunk/apps/ 36 36 /trunk/apps/ApplicationA/ ... ... @@ -51,52 +51,30 @@ 51 51 52 52 Typical things that make up a pom are as follows. (Note: only pom identification is mandatory. All the others have defaults.) 53 53 54 -1. ((( 55 -pom identification (who am I?) 56 - The base triplet used to identify an artifact (i.e., something you need to build/package/install) 57 - 58 -{{noformat}} 55 +1. pom identification (who am I?) 56 + The base triplet used to identify an artifact (i.e., something you need to build/package/install) 57 +1. {{noformat}} 59 59 <artifactId>CustomExtensions</artifactId> 60 60 <groupId>com.mywostuff.frameworks</groupId> 61 61 <version>0.0.1-SNAPSHOT</version> 62 - 63 -{{/noformat}} 64 -))) 65 -1. ((( 66 -pom packaging (i.e., what are we building?) 67 - 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) 68 - 69 -{{noformat}} 70 - <packaging>woapplication</packaging> 71 - 72 -{{/noformat}} 73 -))) 74 -1. ((( 75 -pom parent identification (who do I belong to?) 76 - 77 -{{noformat}} 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}} 64 + <packaging>woapplication</artifactId> 65 +{{/noformat}}pom parent identification (who do I belong to?) 66 +1. {{noformat}} 78 78 <parent> 79 79 <artifactId>frameworks</artifactId> 80 80 <groupId>com.mywostuff</groupId> 81 81 </parent> 82 - 83 -{{/noformat}} 84 -))) 85 -1. ((( 86 -modules (a.k.a kids; who belongs to me?) 87 - 88 -{{noformat}} 71 +{{/noformat}}modules (a.k.a kids; who belongs to me?) 72 +1. {{noformat}} 89 89 <modules> 90 90 <module>CustomExtensions</module> 91 91 <module>CustomBusinessLogic</module> 92 92 </modules> 93 - 94 -{{/noformat}} 95 -))) 96 -1. ((( 97 -dependencies (what do I need?) 98 - 99 -{{noformat}} 77 +{{/noformat}}dependencies (what do I need?) 78 +1. {{noformat}} 100 100 <dependencies> 101 101 <dependency> 102 102 <groupId>log4j</groupId> ... ... @@ -111,10 +111,7 @@ 111 111 <scope>test</scope> 112 112 </dependency> 113 113 </dependencies> 114 - 115 -{{/noformat}} 116 -))) 117 -1. build sources/resources (what do I have?) 93 +{{/noformat}}build sources/resources (what do I have?) 118 118 1. properties and filtering resources (variable definitions) 119 119 1. dependency/plugin management (shared configuration and versioning) 120 120 1. repositories (where to find dependencies and plugins) ... ... @@ -132,6 +132,7 @@ 132 132 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). 133 133 134 134 {{noformat}} 111 + 135 135 /MyProject 136 136 /MyProject/Components 137 137 /MyProject/Resources ... ... @@ -144,6 +144,7 @@ 144 144 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) 145 145 146 146 {{code title="pom.xml" 0="xml"}} 124 + 147 147 <...> 148 148 <build> 149 149 <sourceDirectory>Sources</sourceDirectory> ... ... @@ -180,6 +180,7 @@ 180 180 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. 181 181 182 182 {{noformat}} 161 + 183 183 <dependencies> 184 184 <dependency> 185 185 <artifactId>CustomExtensions</artifactId> ... ... @@ -214,6 +214,7 @@ 214 214 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. 215 215 216 216 {{noformat}} 196 + 217 217 <repositories> 218 218 <repository> 219 219 <id>system-repo</id> ... ... @@ -287,11 +287,10 @@ 287 287 288 288 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): 289 289 270 +{{attachments patterns="Info.plist" upload="false"/}} 290 290 291 - 292 -{{attachments patterns="Info.plist" upload="false"/}} 293 - 294 294 {{code title="/frameworks/pom.xml" 0="xml"}} 273 + 295 295 <?xml version="1.0" encoding="UTF-8"?> 296 296 <project xmlns="http://maven.apache.org/POM/4.0.0" 297 297 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ... ... @@ -418,6 +418,7 @@ 418 418 Since our CustomExtensions has no further dependencies, its pom.xml merely specifies its parent and its identity. 419 419 420 420 {{code title="/frameworks/CustomBusinessLogic/pom.xml" 0="xml"}} 400 + 421 421 <?xml version="1.0"?> 422 422 <project> 423 423 <!-- parent artifact --> ... ... @@ -437,6 +437,7 @@ 437 437 CustomBusinessLogic has a further dependency on CustomExtensions, so it specifies its parent, its identity, and the dependency. 438 438 439 439 {{code title="/frameworks/CustomBusinessLogic/pom.xml" 0="xml"}} 420 + 440 440 <?xml version="1.0"?> 441 441 <project> 442 442 <!-- parent artifact --> ... ... @@ -466,6 +466,7 @@ 466 466 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 468 {{code title="/apps/pom.xml" 0="xml"}} 450 + 469 469 <?xml version="1.0" encoding="UTF-8"?> 470 470 <project xmlns="http://maven.apache.org/POM/4.0.0" 471 471 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ... ... @@ -628,6 +628,7 @@ 628 628 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. 629 629 630 630 {{code title="/apps/ApplicationA/pom.xml" 0="xml"}} 613 + 631 631 <?xml version="1.0"?> 632 632 <project> 633 633 <modelVersion>4.0.0</modelVersion>