Would it make sense to move the common code into the Common module? If not, maybe a new MyApp/Web-Common module is needed to produce a jar for web shared code.
-----Original Message----- From: Milo Mo [mailto:[EMAIL PROTECTED] Sent: November 6, 2008 7:11 PM To: [email protected] Subject: Best practice - multi project Hi! I have come up with a solution to a dependency problem I have had in my multi-maven-project, but I wonder if maybe there's a better solution. I have the following multi project scenario, which is probably not that uncommon: - MyApp - parent pom - MyApp/Common - common code - MyApp/App1 - Web app - MyApp/App2 - Web app - MyApp/Admin - Webapp admin interface for App1/App2 Dependencies: - Common: none - App1: Common - App2: Common - Admin: App1 + App2 + Common All sub projects include the parent pom. Projects App1, App2 and Admin have Common declared as a dependency in the maven configuration. I run the following commands: cd MyApp mvn clean install The parent pom and the Common jar will be installed in my local maven repository (along with the App1 and App2 war files). The problem is the Admin project, which has dependencies to App1 and App2. I want the java classes from App1/App2 bundled in jar files and the jars installed in my local maven repository, but the App1 and App2 projects produce war packages... I have three environments: local, stage, production My solution is this: I have configured App1 and App2 as maven projects with packaging "jar", so the command "mvn package" will produce a jar, and "mvn install" will install the jar files in the local maven repository. I use an Eclipse-embedded Jetty to run the applications on my local machine, so no war file is needed for local use (if I really need a local war i can use the command "mvn package war:war"). So no profile specified means a local build. To build war files for stage and production I have created two maven profiles, "stage" and "production". To make sure war files are built for stage and production, I have specified that the goal war:war (from the plugin maven-war-plugin) will be executed in the "package" phase in the profiles' builds. This means that for App1: - "mvn clean install" will install App1.jar in the maven repository - "mvn -Pstage clean package cargo:deploy" builds a war file and deploys it in my stage environment - "mvn -Pproduction clean package" builds a war file for my production environment Now I can install the App1 and App2 jar files in my local maven repository ("mvn install") and add App1 and App2 as dependencies in Admin. The Admin project now builds fine. I can't help thinking that declaring "jar" packaging in App1 and App2 is a bit of a hack. Is there a better way of doing this? Web apps depending on java classes in other web apps must be a standard issue when building multi projects. Another solution is breaking out the classes from App1 and App2 that Admin needs, but that means two more projects (e.g. "App1-common" and "App2-common"), and I think 6 maven projects for two web applications + admin is a bit much. Any help is appreciated! Kind regards, Milo __________ Information from ESET Smart Security, version of virus signature database 3594 (20081107) __________ The message was checked by ESET Smart Security. http://www.eset.com __________ Information from ESET Smart Security, version of virus signature database 3594 (20081107) __________ The message was checked by ESET Smart Security. http://www.eset.com
