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 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.
To version 24.1
edited by Lachlan Deck
on 2008/07/03 00:05
on 2008/07/03 00:05
Change comment:
Adding basic info and links for further info on project inheritance
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -201,9 +201,15 @@ 201 201 202 202 {{/noformat}} 203 203 204 +=== Project Inheritance === 205 + 206 +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. 207 + 208 +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. 209 + 204 204 === Repositories === 205 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]].,,212 +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 207 208 208 {{noformat}} 209 209 ... ... @@ -278,8 +278,10 @@ 278 278 279 279 === Packaging Frameworks as Jars === 280 280 281 -Here's the definition for /frameworks/pom.xml. 287 +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: 282 282 289 +{{attachments patterns="Info.plist" upload="false"}}{{/attachments}} 290 + 283 283 {{code title="/frameworks/pom.xml"}} 284 284 285 285 <?xml version="1.0" encoding="UTF-8"?> ... ... @@ -289,7 +289,7 @@ 289 289 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 290 290 291 291 <modelVersion>4.0.0</modelVersion> 292 - 300 + 293 293 <!-- parent artifact --> 294 294 <parent> 295 295 <artifactId>mywostuff</artifactId> ... ... @@ -301,7 +301,7 @@ 301 301 <artifactId>frameworks</artifactId> 302 302 <groupId>com.mywostuff</groupId> 303 303 <packaging>pom</packaging> 304 - 312 + 305 305 <!-- framework relevant properties --> 306 306 <properties> 307 307 <!-- NS related properties fills in Info.plist etc--> ... ... @@ -441,7 +441,7 @@ 441 441 <!-- artifact identity --> 442 442 <artifactId>CustomBusinessLogic</artifactId> 443 443 <groupId>com.mywostuff.frameworks</groupId> 444 - 452 + 445 445 <!-- specific dependencies --> 446 446 <dependencies> 447 447 <dependency> ... ... @@ -455,18 +455,235 @@ 455 455 456 456 === Packaging Applications === 457 457 458 -details to co me...466 +Here's the definition for /apps/pom.xml which is shared by any sub-modules (i.e., ApplicationA and ApplicationB). 459 459 460 - === PackagingApplications as TrueWAR===468 +{{code title="/apps/pom.xml"}} 461 461 462 -You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]]. 470 +<?xml version="1.0" encoding="UTF-8"?> 471 +<project xmlns="http://maven.apache.org/POM/4.0.0" 472 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 473 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 474 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> 463 463 464 -mo redetailstocome...476 + <modelVersion>4.0.0</modelVersion> 465 465 466 -=== Project Inheritance === 478 + <!-- parent artifact --> 479 + <parent> 480 + <groupId>com</groupId> 481 + <artifactId>mywostuff</artifactId> 482 + <version>1.0-SNAPSHOT</version> 483 + </parent> 467 467 468 -details to come... 485 + <!-- artifact identity --> 486 + <artifactId>apps</artifactId> 487 + <groupId>com.mywostuff</groupId> 488 + <packaging>pom</packaging> 469 469 490 + <!-- modules --> 491 + <modules> 492 + <module>ApplicationA</module> 493 + <module>ApplicationB</module> 494 + </modules> 495 + 496 + <!-- specific dependencies (for modules) --> 497 + <dependencies> 498 + <!-- wonder frameworks --> 499 + <dependency> 500 + <artifactId>ERExtensions</artifactId> 501 + <groupId>${wonder.common.groupId}</groupId> 502 + </dependency> 503 + <dependency> 504 + <artifactId>JavaWOExtensions</artifactId> 505 + <groupId>${wonder.common.groupId}</groupId> 506 + </dependency> 507 + 508 + <!-- project libs --> 509 + <dependency> 510 + <artifactId>CustomExtensions</artifactId> 511 + <groupId>${my.frameworks.groupId}</groupId> 512 + </dependency> 513 + <dependency> 514 + <artifactId>CustomBusinessLogic</artifactId> 515 + <groupId>${my.frameworks.groupId}</groupId> 516 + </dependency> 517 + 518 + <!-- webobjects dependencies --> 519 + <dependency> 520 + <artifactId>JavaFoundation</artifactId> 521 + <groupId>${webobjects.groupId}</groupId> 522 + </dependency> 523 + <dependency> 524 + <artifactId>JavaJDBCAdaptor</artifactId> 525 + <groupId>${webobjects.groupId}</groupId> 526 + </dependency> 527 + <dependency> 528 + <artifactId>JavaWebObjects</artifactId> 529 + <groupId>${webobjects.groupId}</groupId> 530 + </dependency> 531 + <dependency> 532 + <artifactId>JavaEOControl</artifactId> 533 + <groupId>${webobjects.groupId}</groupId> 534 + </dependency> 535 + <dependency> 536 + <artifactId>JavaEOAccess</artifactId> 537 + <groupId>${webobjects.groupId}</groupId> 538 + </dependency> 539 + <dependency> 540 + <artifactId>JavaWebObjects</artifactId> 541 + <groupId>${webobjects.groupId}</groupId> 542 + </dependency> 543 + <dependency> 544 + <artifactId>JavaXML</artifactId> 545 + <groupId>${webobjects.groupId}</groupId> 546 + </dependency> 547 + </dependencies> 548 + 549 + <!-- build config (for modules) --> 550 + <build> 551 + <sourceDirectory>src</sourceDirectory> 552 + <testSourceDirectory>tests</testSourceDirectory> 553 + <resources> 554 + <resource> 555 + <targetPath>Resources</targetPath> 556 + <filtering>false</filtering> 557 + <directory>Components</directory> 558 + </resource> 559 + <resource> 560 + <targetPath>Resources</targetPath> 561 + <filtering>false</filtering> 562 + <directory>Resources</directory> 563 + </resource> 564 + <resource> 565 + <targetPath>WebServerResources</targetPath> 566 + <filtering>false</filtering> 567 + <directory>WebServerResources</directory> 568 + </resource> 569 + </resources> 570 + <plugins> 571 + <plugin> 572 + <artifactId>maven-wolifecycle-plugin</artifactId> 573 + <groupId>org.objectstyle.woproject.maven2</groupId> 574 + <version>2.0.15</version> 575 + <extensions>true</extensions> 576 + <configuration> 577 + <source>${java.target}</source> 578 + <target>${java.target}</target> 579 + </configuration> 580 + </plugin> 581 + <plugin> 582 + <groupId>org.apache.maven.plugins</groupId> 583 + <artifactId>maven-javadoc-plugin</artifactId> 584 + <configuration> 585 + <javadocVersion>${java.target}</javadocVersion> 586 + <locale>en-AU</locale> 587 + <minmemory>128m</minmemory> 588 + <maxmemory>512m</maxmemory> 589 + </configuration> 590 + </plugin> 591 + <!-- 592 + TODO build numbering 593 + <plugin> 594 + <groupId>org.codehaus.mojo</groupId> 595 + <artifactId>maven-buildnumber-plugin</artifactId> 596 + <version>0.9.6</version> 597 + <executions> 598 + <execution> 599 + <phase>validate</phase> 600 + <goals> 601 + <goal>create</goal> 602 + </goals> 603 + </execution> 604 + </executions> 605 + <configuration> 606 + <doCheck>true</doCheck> 607 + <doUpdate>true</doUpdate> 608 + </configuration> 609 + </plugin> 610 + --> 611 + </plugins> 612 + <pluginManagement> 613 + <plugins> 614 + <plugin> 615 + <groupId>org.apache.maven.plugins</groupId> 616 + <artifactId>maven-compiler-plugin</artifactId> 617 + <configuration> 618 + <source>${java.target}</source> 619 + <target>${java.target}</target> 620 + </configuration> 621 + </plugin> 622 + </plugins> 623 + </pluginManagement> 624 + </build> 625 +</project> 626 + 627 +{{/code}} 628 + 629 +and ApplicationA - which has a couple of extra specific dependencies to add to those inherited from its parent. 630 + 631 +{{code title="/apps/ApplicationA/pom.xml"}} 632 + 633 +<?xml version="1.0"?> 634 +<project> 635 + <modelVersion>4.0.0</modelVersion> 636 + 637 + <!-- parent artifact --> 638 + <parent> 639 + <artifactId>apps</artifactId> 640 + <groupId>com.mywostuff</groupId> 641 + <version>1.0-SNAPSHOT</version> 642 + <relativePath>../apps</relativePath> <!-- e.g., (optional) if your app is under /trunk --> 643 + </parent> 644 + 645 + <!-- artifact identity --> 646 + <artifactId>ApplicationA</artifactId> 647 + <groupId>com.mywostuff.apps</groupId> 648 + <packaging>woapplication</packaging> <!-- woproject specific packaging --> 649 + 650 + <!-- specific properties --> 651 + <properties> 652 + <!-- general properties --> 653 + <mainclass>your.app.Application</mainclass> 654 + </properties> 655 + 656 + <!-- specific dependencies --> 657 + <dependencies> 658 + <!-- wonder frameworks --> 659 + <dependency> 660 + <artifactId>Ajax</artifactId> 661 + <groupId>${wonder.ajax.groupId}</groupId> 662 + </dependency> 663 + <dependency> 664 + <artifactId>ERCaptcha</artifactId> 665 + <groupId>${wonder.common.groupId}</groupId> 666 + <!-- requires jcaptcha-all below --> 667 + </dependency> 668 + <dependency> 669 + <artifactId>WOOgnl</artifactId> 670 + <groupId>${wonder.common.groupId}</groupId> 671 + </dependency> 672 + 673 + <!-- general libs --> 674 + <dependency> 675 + <artifactId>jcaptcha-all</artifactId> 676 + <groupId>com.octo.captcha</groupId> 677 + </dependency> 678 + <dependency> 679 + <artifactId>commons-collections</artifactId> 680 + <groupId>commons-collections</groupId> 681 + </dependency> 682 + <dependency> 683 + <groupId>ognl</groupId> 684 + <artifactId>ognl</artifactId> 685 + </dependency> 686 + </dependencies> 687 +</project> 688 + 689 +{{/code}} 690 + 691 +=== Packaging Applications as True WAR === 692 + 693 +You can find steps to package WO Applications as True WAR [[here>>Packaging WO Applications as true WAR with Maven]]. 694 + 470 470 === Eclipse Integration === 471 471 472 472 details to come...