Hi Milo,
>From what I understood, the best solution would be to further break up the
>app1 und app2 wars in a app1-jar and a app1-war. I know that this increases
>the project complexity but from my point of view, it is the clearer approach
>for achieving your goal. I would also think, that having a war only contain
>webapp resources and no java files is a good thing. But that is only my point
>of view and has arguably some drawbacks, because some java code is only needed
>for the webapp alone.
So what I would do, is create the following setup:
/myapp + /common
|
+ /app1-jar : depends on common
|
+ /app1-war : depends on app1-jar
|
+ /app2-jar : depends on common
|
+ /app2-war : depends on app2-jar
|
+ /admin-war: depends on app1-jar and app2-jar
Whereas I would break up the app1 and app2 java code in code, that is needed by
admin and app1 and thus goes to app1-jar and code that is only needed by
app1-war and stays inside this project. Same for app2. By this layout you get a
clear approach to reasonsibility and dependencies of your projects.
Greetings,
Christian.
--
christian domsch
[software developer]
innoWake gmbh
innovative.software.development();
ACHTUNG! WIR SIND UMGEZOGEN:
IT-Tower
Robert-Bosch-Str. 1 | 89250 Senden
Fon: +49.7307.92190.0
Fax: +49.7307.92190.20
[EMAIL PROTECTED]
www.innowake.de
innoWake gmbh HRB Ulm 4584
Geschäftsführer: Thorsten Bernecker
This e-mail may contain confidential information. If you are not the intended
recipient please notify the sender immediately and destroy this e-mail.
-----Ursprüngliche Nachricht-----
Von: Milo Mo [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 7. November 2008 01:10
An: [email protected]
Betreff: 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]