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 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
To version 18.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
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. ldeck1 +XWiki.hprange - Content
-
... ... @@ -10,12 +10,6 @@ 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 - 19 19 === What's the aim === 20 20 21 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. ... ... @@ -53,6 +53,7 @@ 53 53 <groupId>com.mywostuff.frameworks</groupId> 54 54 <version>0.0.1-SNAPSHOT</version> 55 55 50 + 56 56 {{/noformat}} 57 57 58 58 1. pom packaging (i.e., what are we building?) ... ... @@ -62,6 +62,7 @@ 62 62 63 63 <packaging>woapplication</artifactId> 64 64 60 + 65 65 {{/noformat}} 66 66 67 67 1. pom parent identification (who do I belong to?) ... ... @@ -73,6 +73,7 @@ 73 73 <groupId>com.mywostuff</groupId> 74 74 </parent> 75 75 72 + 76 76 {{/noformat}} 77 77 78 78 1. modules (a.k.a kids; who belongs to me?) ... ... @@ -84,6 +84,7 @@ 84 84 <module>CustomBusinessLogic</module> 85 85 </modules> 86 86 84 + 87 87 {{/noformat}} 88 88 89 89 1. dependencies (what do I need?) ... ... @@ -105,6 +105,7 @@ 105 105 </dependency> 106 106 </dependencies> 107 107 106 + 108 108 {{/noformat}} 109 109 110 110 1. build sources/resources (what do I have?) ... ... @@ -172,516 +172,20 @@ 172 172 173 173 === Project Dependencies Concepts === 174 174 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]].174 +Most projects, of course, have dependencies on other libraries or frameworks. 176 176 177 - Thefollowing shows the mixtureof third party dependencies and customframework dependencies.Noticethat the scope element determines the life cycle phase each dependencyis relevantfor. See [[Maven Model#class//dependency//>>http://maven.apache.org/ref/2.0.9/maven-model/maven.html#class_dependency]]for specific definitions.176 +=== Project Dependencies Prerequisites === 178 178 179 - {{noformat}}178 +details to come... 180 180 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 - 279 279 === Packaging Frameworks as Jars === 280 280 281 - Here's thedefinition for /frameworks/pom.xml. Note thatit dependsonthe followingInfo.plist file being located under trunk/frameworks/src/main/resources:182 +details to come... 282 282 283 -{{attachments patterns="Info.plist" upload="false"}}{{/attachments}} 284 - 285 -{{code title="/frameworks/pom.xml"}} 286 - 287 -<?xml version="1.0" encoding="UTF-8"?> 288 -<project xmlns="http://maven.apache.org/POM/4.0.0" 289 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 290 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 291 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> 292 - 293 - <modelVersion>4.0.0</modelVersion> 294 - 295 - <!-- parent artifact --> 296 - <parent> 297 - <artifactId>mywostuff</artifactId> 298 - <groupId>com</groupId> 299 - <version>1.0-SNAPSHOT</version> 300 - </parent> 301 - 302 - <!-- artifact identity --> 303 - <artifactId>frameworks</artifactId> 304 - <groupId>com.mywostuff</groupId> 305 - <packaging>pom</packaging> 306 - 307 - <!-- framework relevant properties --> 308 - <properties> 309 - <!-- NS related properties fills in Info.plist etc--> 310 - <CFBundleDevelopmentRegion>English</CFBundleDevelopmentRegion> 311 - <CFBundleGetInfoString></CFBundleGetInfoString> 312 - <CFBundlePackageType>FMWK</CFBundlePackageType> 313 - <CFBundleIconFile>WOAfile.icns</CFBundleIconFile> 314 - <CFBundleInfoDictionaryVersion>6.0</CFBundleInfoDictionaryVersion> 315 - <CFBundleVersion>5.3.1</CFBundleVersion> 316 - <Has_WOComponents>true</Has_WOComponents> 317 - <NSPrincipalClass>${mainclass}</NSPrincipalClass> 318 - <NSResourcesBundlePath></NSResourcesBundlePath> 319 - </properties> 320 - 321 - <!-- modules --> 322 - <modules> 323 - <module>CustomExtensions</module> 324 - <module>CustomBusinessLogic</module> 325 - </modules> 326 - 327 - <!-- specific dependencies (for modules) --> 328 - <dependencies> 329 - <dependency> 330 - <artifactId>ERExtensions</artifactId> 331 - <groupId>${wonder.common.groupId}</groupId> 332 - </dependency> 333 - <dependency> 334 - <artifactId>JavaWOExtensions</artifactId> 335 - <groupId>${wonder.common.groupId}</groupId> 336 - </dependency> 337 - <dependency> 338 - <artifactId>JavaFoundation</artifactId> 339 - <groupId>${webobjects.groupId}</groupId> 340 - </dependency> 341 - <dependency> 342 - <artifactId>JavaJDBCAdaptor</artifactId> 343 - <groupId>${webobjects.groupId}</groupId> 344 - </dependency> 345 - <dependency> 346 - <artifactId>JavaWebObjects</artifactId> 347 - <groupId>${webobjects.groupId}</groupId> 348 - </dependency> 349 - <dependency> 350 - <artifactId>JavaEOControl</artifactId> 351 - <groupId>${webobjects.groupId}</groupId> 352 - </dependency> 353 - <dependency> 354 - <artifactId>JavaEOAccess</artifactId> 355 - <groupId>${webobjects.groupId}</groupId> 356 - </dependency> 357 - <dependency> 358 - <artifactId>JavaWebObjects</artifactId> 359 - <groupId>${webobjects.groupId}</groupId> 360 - </dependency> 361 - <dependency> 362 - <artifactId>JavaXML</artifactId> 363 - <groupId>${webobjects.groupId}</groupId> 364 - </dependency> 365 - </dependencies> 366 - 367 - 368 - <!-- build config (for modules) --> 369 - <build> 370 - <sourceDirectory>src</sourceDirectory> 371 - <testSourceDirectory>tests</testSourceDirectory> 372 - <resources> 373 - <!-- relative dir for Info.plist --> 374 - <resource> 375 - <targetPath>Resources</targetPath> 376 - <filtering>true</filtering> 377 - <directory>../src/main/resources</directory> 378 - </resource> 379 - <resource> 380 - <targetPath>Resources</targetPath> 381 - <filtering>false</filtering> 382 - <directory>Components</directory> 383 - </resource> 384 - <resource> 385 - <targetPath>Resources</targetPath> 386 - <filtering>false</filtering> 387 - <directory>Resources</directory> 388 - </resource> 389 - <resource> 390 - <targetPath>WebServerResources</targetPath> 391 - <filtering>false</filtering> 392 - <directory>WebServerResources</directory> 393 - </resource> 394 - </resources> 395 - <plugins> 396 - <plugin> 397 - <groupId>org.apache.maven.plugins</groupId> 398 - <artifactId>maven-compiler-plugin</artifactId> 399 - <configuration> 400 - <source>${java.target}</source> 401 - <target>${java.target}</target> 402 - </configuration> 403 - </plugin> 404 - </plugins> 405 - </build> 406 -</project> 407 - 408 -{{/code}} 409 - 410 -and CustomExtensions which has no further dependencies 411 - 412 -{{code title="/frameworks/CustomBusinessLogic/pom.xml"}} 413 - 414 -<?xml version="1.0"?> 415 -<project> 416 - <!-- parent artifact --> 417 - <parent> 418 - <artifactId>frameworks</artifactId> 419 - <groupId>com.mywostuff</groupId> 420 - <version>1.0-SNAPSHOT</version> 421 - </parent> 422 - 423 - <!-- artifact identity --> 424 - <artifactId>CustomBusinessLogic</artifactId> 425 - <groupId>com.mywostuff.frameworks</groupId> 426 -</project> 427 - 428 -{{/code}} 429 - 430 -and CustomBusinessLogic (which has a further dependency on CustomExtensions) 431 - 432 -{{code title="/frameworks/CustomBusinessLogic/pom.xml"}} 433 - 434 -<?xml version="1.0"?> 435 -<project> 436 - <!-- parent artifact --> 437 - <parent> 438 - <artifactId>frameworks</artifactId> 439 - <groupId>com.mywostuff</groupId> 440 - <version>1.0-SNAPSHOT</version> 441 - </parent> 442 - 443 - <!-- artifact identity --> 444 - <artifactId>CustomBusinessLogic</artifactId> 445 - <groupId>com.mywostuff.frameworks</groupId> 446 - 447 - <!-- specific dependencies --> 448 - <dependencies> 449 - <dependency> 450 - <artifactId>CustomExtensions</artifactId> 451 - <groupId>${pom.groupId}</groupId> 452 - </dependency> 453 - </dependencies> 454 -</project> 455 - 456 -{{/code}} 457 - 458 458 === Packaging Applications === 459 459 460 - Here's thedefinition for /apps/pom.xml which is shared by any sub-modules(i.e., ApplicationAand ApplicationB).186 +details to come... 461 461 462 -{{code title="/apps/pom.xml"}} 463 - 464 -<?xml version="1.0" encoding="UTF-8"?> 465 -<project xmlns="http://maven.apache.org/POM/4.0.0" 466 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 467 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 468 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> 469 - 470 - <modelVersion>4.0.0</modelVersion> 471 - 472 - <!-- parent artifact --> 473 - <parent> 474 - <groupId>com</groupId> 475 - <artifactId>mywostuff</artifactId> 476 - <version>1.0-SNAPSHOT</version> 477 - </parent> 478 - 479 - <!-- artifact identity --> 480 - <artifactId>apps</artifactId> 481 - <groupId>com.mywostuff</groupId> 482 - <packaging>pom</packaging> 483 - 484 - <!-- modules --> 485 - <modules> 486 - <module>ApplicationA</module> 487 - <module>ApplicationB</module> 488 - </modules> 489 - 490 - <!-- specific dependencies (for modules) --> 491 - <dependencies> 492 - <!-- wonder frameworks --> 493 - <dependency> 494 - <artifactId>ERExtensions</artifactId> 495 - <groupId>${wonder.common.groupId}</groupId> 496 - </dependency> 497 - <dependency> 498 - <artifactId>JavaWOExtensions</artifactId> 499 - <groupId>${wonder.common.groupId}</groupId> 500 - </dependency> 501 - 502 - <!-- project libs --> 503 - <dependency> 504 - <artifactId>CustomExtensions</artifactId> 505 - <groupId>${my.frameworks.groupId}</groupId> 506 - </dependency> 507 - <dependency> 508 - <artifactId>CustomBusinessLogic</artifactId> 509 - <groupId>${my.frameworks.groupId}</groupId> 510 - </dependency> 511 - 512 - <!-- webobjects dependencies --> 513 - <dependency> 514 - <artifactId>JavaFoundation</artifactId> 515 - <groupId>${webobjects.groupId}</groupId> 516 - </dependency> 517 - <dependency> 518 - <artifactId>JavaJDBCAdaptor</artifactId> 519 - <groupId>${webobjects.groupId}</groupId> 520 - </dependency> 521 - <dependency> 522 - <artifactId>JavaWebObjects</artifactId> 523 - <groupId>${webobjects.groupId}</groupId> 524 - </dependency> 525 - <dependency> 526 - <artifactId>JavaEOControl</artifactId> 527 - <groupId>${webobjects.groupId}</groupId> 528 - </dependency> 529 - <dependency> 530 - <artifactId>JavaEOAccess</artifactId> 531 - <groupId>${webobjects.groupId}</groupId> 532 - </dependency> 533 - <dependency> 534 - <artifactId>JavaWebObjects</artifactId> 535 - <groupId>${webobjects.groupId}</groupId> 536 - </dependency> 537 - <dependency> 538 - <artifactId>JavaXML</artifactId> 539 - <groupId>${webobjects.groupId}</groupId> 540 - </dependency> 541 - </dependencies> 542 - 543 - <!-- build config (for modules) --> 544 - <build> 545 - <sourceDirectory>src</sourceDirectory> 546 - <testSourceDirectory>tests</testSourceDirectory> 547 - <resources> 548 - <resource> 549 - <targetPath>Resources</targetPath> 550 - <filtering>false</filtering> 551 - <directory>Components</directory> 552 - </resource> 553 - <resource> 554 - <targetPath>Resources</targetPath> 555 - <filtering>false</filtering> 556 - <directory>Resources</directory> 557 - </resource> 558 - <resource> 559 - <targetPath>WebServerResources</targetPath> 560 - <filtering>false</filtering> 561 - <directory>WebServerResources</directory> 562 - </resource> 563 - </resources> 564 - <plugins> 565 - <plugin> 566 - <artifactId>maven-wolifecycle-plugin</artifactId> 567 - <groupId>org.objectstyle.woproject.maven2</groupId> 568 - <version>2.0.15</version> 569 - <extensions>true</extensions> 570 - <configuration> 571 - <source>${java.target}</source> 572 - <target>${java.target}</target> 573 - </configuration> 574 - </plugin> 575 - <plugin> 576 - <groupId>org.apache.maven.plugins</groupId> 577 - <artifactId>maven-javadoc-plugin</artifactId> 578 - <configuration> 579 - <javadocVersion>${java.target}</javadocVersion> 580 - <locale>en-AU</locale> 581 - <minmemory>128m</minmemory> 582 - <maxmemory>512m</maxmemory> 583 - </configuration> 584 - </plugin> 585 - <!-- 586 - TODO build numbering 587 - <plugin> 588 - <groupId>org.codehaus.mojo</groupId> 589 - <artifactId>maven-buildnumber-plugin</artifactId> 590 - <version>0.9.6</version> 591 - <executions> 592 - <execution> 593 - <phase>validate</phase> 594 - <goals> 595 - <goal>create</goal> 596 - </goals> 597 - </execution> 598 - </executions> 599 - <configuration> 600 - <doCheck>true</doCheck> 601 - <doUpdate>true</doUpdate> 602 - </configuration> 603 - </plugin> 604 - --> 605 - </plugins> 606 - <pluginManagement> 607 - <plugins> 608 - <plugin> 609 - <groupId>org.apache.maven.plugins</groupId> 610 - <artifactId>maven-compiler-plugin</artifactId> 611 - <configuration> 612 - <source>${java.target}</source> 613 - <target>${java.target}</target> 614 - </configuration> 615 - </plugin> 616 - </plugins> 617 - </pluginManagement> 618 - </build> 619 -</project> 620 - 621 -{{/code}} 622 - 623 -and ApplicationA - which has a couple of extra specific dependencies to add to those inherited from its parent. 624 - 625 -{{code title="/apps/ApplicationA/pom.xml"}} 626 - 627 -<?xml version="1.0"?> 628 -<project> 629 - <modelVersion>4.0.0</modelVersion> 630 - 631 - <!-- parent artifact --> 632 - <parent> 633 - <artifactId>apps</artifactId> 634 - <groupId>com.mywostuff</groupId> 635 - <version>1.0-SNAPSHOT</version> 636 - <relativePath>../apps</relativePath> <!-- e.g., (optional) if your app is under /trunk --> 637 - </parent> 638 - 639 - <!-- artifact identity --> 640 - <artifactId>ApplicationA</artifactId> 641 - <groupId>com.mywostuff.apps</groupId> 642 - <packaging>woapplication</packaging> <!-- woproject specific packaging --> 643 - 644 - <!-- specific properties --> 645 - <properties> 646 - <!-- general properties --> 647 - <mainclass>your.app.Application</mainclass> 648 - </properties> 649 - 650 - <!-- specific dependencies --> 651 - <dependencies> 652 - <!-- wonder frameworks --> 653 - <dependency> 654 - <artifactId>Ajax</artifactId> 655 - <groupId>${wonder.ajax.groupId}</groupId> 656 - </dependency> 657 - <dependency> 658 - <artifactId>ERCaptcha</artifactId> 659 - <groupId>${wonder.common.groupId}</groupId> 660 - <!-- requires jcaptcha-all below --> 661 - </dependency> 662 - <dependency> 663 - <artifactId>WOOgnl</artifactId> 664 - <groupId>${wonder.common.groupId}</groupId> 665 - </dependency> 666 - 667 - <!-- general libs --> 668 - <dependency> 669 - <artifactId>jcaptcha-all</artifactId> 670 - <groupId>com.octo.captcha</groupId> 671 - </dependency> 672 - <dependency> 673 - <artifactId>commons-collections</artifactId> 674 - <groupId>commons-collections</groupId> 675 - </dependency> 676 - <dependency> 677 - <groupId>ognl</groupId> 678 - <artifactId>ognl</artifactId> 679 - </dependency> 680 - </dependencies> 681 -</project> 682 - 683 -{{/code}} 684 - 685 685 === Packaging Applications as True WAR === 686 686 687 687 You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]].