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 19.1
edited by Henrique Prange
on 2008/06/15 19:35
on 2008/06/15 19:35
Change comment:
There is no comment for this version
To version 22.1
edited by Lachlan Deck
on 2008/06/24 00:39
on 2008/06/24 00:39
Change comment:
Add tip to hang in there with longish guide.
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. hprange1 +XWiki.ldeck - Content
-
... ... @@ -10,6 +10,12 @@ 10 10 11 11 {{/info}} 12 12 13 +{{tip title="Hang in there"}} 14 + 15 +This particular guide might look long but some of the xml is duplicated a few times to show differing examples. 16 + 17 +{{/tip}} 18 + 13 13 === What's the aim === 14 14 15 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. ... ... @@ -47,7 +47,6 @@ 47 47 <groupId>com.mywostuff.frameworks</groupId> 48 48 <version>0.0.1-SNAPSHOT</version> 49 49 50 - 51 51 {{/noformat}} 52 52 53 53 1. pom packaging (i.e., what are we building?) ... ... @@ -57,7 +57,6 @@ 57 57 58 58 <packaging>woapplication</artifactId> 59 59 60 - 61 61 {{/noformat}} 62 62 63 63 1. pom parent identification (who do I belong to?) ... ... @@ -69,7 +69,6 @@ 69 69 <groupId>com.mywostuff</groupId> 70 70 </parent> 71 71 72 - 73 73 {{/noformat}} 74 74 75 75 1. modules (a.k.a kids; who belongs to me?) ... ... @@ -81,7 +81,6 @@ 81 81 <module>CustomBusinessLogic</module> 82 82 </modules> 83 83 84 - 85 85 {{/noformat}} 86 86 87 87 1. dependencies (what do I need?) ... ... @@ -103,7 +103,6 @@ 103 103 </dependency> 104 104 </dependencies> 105 105 106 - 107 107 {{/noformat}} 108 108 109 109 1. build sources/resources (what do I have?) ... ... @@ -171,16 +171,287 @@ 171 171 172 172 === Project Dependencies Concepts === 173 173 174 -Most projects, of course, have dependencies on other libraries or frameworks. 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]]. 175 175 176 - ===ProjectDependenciesPrerequisites===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. 177 177 178 - details tocome...179 +{{noformat}} 179 179 181 + <dependencies> 182 + <dependency> 183 + <artifactId>CustomExtensions</artifactId> 184 + <groupId>com.mywostuff.frameworks</groupId> 185 + <version>0.0.1-SNAPSHOT</version> 186 + <scope>compile</scope> 187 + </dependency> 188 + <dependency> 189 + <groupId>log4j</groupId> 190 + <artifactId>log4j</artifactId> 191 + <version>1.2.12</version> 192 + <scope>compile</scope> 193 + </dependency> 194 + <dependency> 195 + <groupId>junit</groupId> 196 + <artifactId>junit</artifactId> 197 + <version>4.4</version> 198 + <scope>test</scope> 199 + </dependency> 200 + </dependencies> 201 + 202 +{{/noformat}} 203 + 204 +=== Repositories === 205 + 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]].,, 207 + 208 +{{noformat}} 209 + 210 +<repositories> 211 + <repository> 212 + <id>system-repo</id> 213 + <name>internal repository</name> 214 + <!-- TODO switch over to your intranet.domain --> 215 + <url>file://${user.home}/.myarchiva</url> 216 + <snapshots> 217 + <enabled>true</enabled> 218 + <updatePolicy>always</updatePolicy> 219 + <checksumPolicy>ignore</checksumPolicy> 220 + </snapshots> 221 + <releases> 222 + <enabled>true</enabled> 223 + <updatePolicy>always</updatePolicy> 224 + <checksumPolicy>ignore</checksumPolicy> 225 + </releases> 226 + </repository> 227 + <repository> 228 + <id>maven2-repository.dev.java.net</id> 229 + <name>Java.net Repository for Maven</name> 230 + <url>http://download.java.net/maven/2</url> 231 + <snapshots> 232 + <enabled>true</enabled> 233 + <updatePolicy>daily</updatePolicy> 234 + </snapshots> 235 + <releases> 236 + <enabled>true</enabled> 237 + <updatePolicy>daily</updatePolicy> 238 + </releases> 239 + </repository> 240 + <repository> 241 + <id>webobjects.mdimension.com/releases</id> 242 + <name>mdimension maven 2 releases repo</name> 243 + <url>http://webobjects.mdimension.com/maven2/releases</url> 244 + <snapshots> 245 + <enabled>false</enabled> 246 + </snapshots> 247 + <releases> 248 + <enabled>true</enabled> 249 + </releases> 250 + </repository> 251 + <repository> 252 + <id>webobjects.mdimension.com/snapshots</id> 253 + <name>mdimension maven 2 snapshots repo</name> 254 + <url>http://webobjects.mdimension.com/maven2/snapshots</url> 255 + <snapshots> 256 + <enabled>true</enabled> 257 + </snapshots> 258 + <releases> 259 + <enabled>false</enabled> 260 + </releases> 261 + </repository> 262 + <repository> 263 + <id>objectstyle-maven2</id> 264 + <name>objectstyle maven2 repo</name> 265 + <url>http://objectstyle.org/maven2</url> 266 + <snapshots> 267 + <enabled>false</enabled> 268 + </snapshots> 269 + <releases> 270 + <enabled>true</enabled> 271 + </releases> 272 + </repository> 273 +</repositories> 274 + 275 +{{/noformat}} 276 + 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]]. 278 + 180 180 === Packaging Frameworks as Jars === 181 181 182 - details tocome...281 +Here's the definition for /frameworks/pom.xml. 183 183 283 +{{code title="/frameworks/pom.xml"}} 284 + 285 +<?xml version="1.0" encoding="UTF-8"?> 286 +<project xmlns="http://maven.apache.org/POM/4.0.0" 287 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 288 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 289 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> 290 + 291 + <modelVersion>4.0.0</modelVersion> 292 + 293 + <!-- parent artifact --> 294 + <parent> 295 + <artifactId>mywostuff</artifactId> 296 + <groupId>com</groupId> 297 + <version>1.0-SNAPSHOT</version> 298 + </parent> 299 + 300 + <!-- artifact identity --> 301 + <artifactId>frameworks</artifactId> 302 + <groupId>com.mywostuff</groupId> 303 + <packaging>pom</packaging> 304 + 305 + <!-- framework relevant properties --> 306 + <properties> 307 + <!-- NS related properties fills in Info.plist etc--> 308 + <CFBundleDevelopmentRegion>English</CFBundleDevelopmentRegion> 309 + <CFBundleGetInfoString></CFBundleGetInfoString> 310 + <CFBundlePackageType>FMWK</CFBundlePackageType> 311 + <CFBundleIconFile>WOAfile.icns</CFBundleIconFile> 312 + <CFBundleInfoDictionaryVersion>6.0</CFBundleInfoDictionaryVersion> 313 + <CFBundleVersion>5.3.1</CFBundleVersion> 314 + <Has_WOComponents>true</Has_WOComponents> 315 + <NSPrincipalClass>${mainclass}</NSPrincipalClass> 316 + <NSResourcesBundlePath></NSResourcesBundlePath> 317 + </properties> 318 + 319 + <!-- modules --> 320 + <modules> 321 + <module>CustomExtensions</module> 322 + <module>CustomBusinessLogic</module> 323 + </modules> 324 + 325 + <!-- specific dependencies (for modules) --> 326 + <dependencies> 327 + <dependency> 328 + <artifactId>ERExtensions</artifactId> 329 + <groupId>${wonder.common.groupId}</groupId> 330 + </dependency> 331 + <dependency> 332 + <artifactId>JavaWOExtensions</artifactId> 333 + <groupId>${wonder.common.groupId}</groupId> 334 + </dependency> 335 + <dependency> 336 + <artifactId>JavaFoundation</artifactId> 337 + <groupId>${webobjects.groupId}</groupId> 338 + </dependency> 339 + <dependency> 340 + <artifactId>JavaJDBCAdaptor</artifactId> 341 + <groupId>${webobjects.groupId}</groupId> 342 + </dependency> 343 + <dependency> 344 + <artifactId>JavaWebObjects</artifactId> 345 + <groupId>${webobjects.groupId}</groupId> 346 + </dependency> 347 + <dependency> 348 + <artifactId>JavaEOControl</artifactId> 349 + <groupId>${webobjects.groupId}</groupId> 350 + </dependency> 351 + <dependency> 352 + <artifactId>JavaEOAccess</artifactId> 353 + <groupId>${webobjects.groupId}</groupId> 354 + </dependency> 355 + <dependency> 356 + <artifactId>JavaWebObjects</artifactId> 357 + <groupId>${webobjects.groupId}</groupId> 358 + </dependency> 359 + <dependency> 360 + <artifactId>JavaXML</artifactId> 361 + <groupId>${webobjects.groupId}</groupId> 362 + </dependency> 363 + </dependencies> 364 + 365 + 366 + <!-- build config (for modules) --> 367 + <build> 368 + <sourceDirectory>src</sourceDirectory> 369 + <testSourceDirectory>tests</testSourceDirectory> 370 + <resources> 371 + <!-- relative dir for Info.plist --> 372 + <resource> 373 + <targetPath>Resources</targetPath> 374 + <filtering>true</filtering> 375 + <directory>../src/main/resources</directory> 376 + </resource> 377 + <resource> 378 + <targetPath>Resources</targetPath> 379 + <filtering>false</filtering> 380 + <directory>Components</directory> 381 + </resource> 382 + <resource> 383 + <targetPath>Resources</targetPath> 384 + <filtering>false</filtering> 385 + <directory>Resources</directory> 386 + </resource> 387 + <resource> 388 + <targetPath>WebServerResources</targetPath> 389 + <filtering>false</filtering> 390 + <directory>WebServerResources</directory> 391 + </resource> 392 + </resources> 393 + <plugins> 394 + <plugin> 395 + <groupId>org.apache.maven.plugins</groupId> 396 + <artifactId>maven-compiler-plugin</artifactId> 397 + <configuration> 398 + <source>${java.target}</source> 399 + <target>${java.target}</target> 400 + </configuration> 401 + </plugin> 402 + </plugins> 403 + </build> 404 +</project> 405 + 406 +{{/code}} 407 + 408 +and CustomExtensions which has no further dependencies 409 + 410 +{{code title="/frameworks/CustomBusinessLogic/pom.xml"}} 411 + 412 +<?xml version="1.0"?> 413 +<project> 414 + <!-- parent artifact --> 415 + <parent> 416 + <artifactId>frameworks</artifactId> 417 + <groupId>com.mywostuff</groupId> 418 + <version>1.0-SNAPSHOT</version> 419 + </parent> 420 + 421 + <!-- artifact identity --> 422 + <artifactId>CustomBusinessLogic</artifactId> 423 + <groupId>com.mywostuff.frameworks</groupId> 424 +</project> 425 + 426 +{{/code}} 427 + 428 +and CustomBusinessLogic (which has a further dependency on CustomExtensions) 429 + 430 +{{code title="/frameworks/CustomBusinessLogic/pom.xml"}} 431 + 432 +<?xml version="1.0"?> 433 +<project> 434 + <!-- parent artifact --> 435 + <parent> 436 + <artifactId>frameworks</artifactId> 437 + <groupId>com.mywostuff</groupId> 438 + <version>1.0-SNAPSHOT</version> 439 + </parent> 440 + 441 + <!-- artifact identity --> 442 + <artifactId>CustomBusinessLogic</artifactId> 443 + <groupId>com.mywostuff.frameworks</groupId> 444 + 445 + <!-- specific dependencies --> 446 + <dependencies> 447 + <dependency> 448 + <artifactId>CustomExtensions</artifactId> 449 + <groupId>${pom.groupId}</groupId> 450 + </dependency> 451 + </dependencies> 452 +</project> 453 + 454 +{{/code}} 455 + 184 184 === Packaging Applications === 185 185 186 186 details to come...