You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by sg...@gmx.net on 2010/08/30 09:34:19 UTC

Creating and deploying two classified WAR files at once

Hi folks,

I am facing a config problem with deploying two classified WAR files at once. My setup is this, I have a WAR project which is developed and tested locally with Tomcat and Eclipse. Deploying this WAR file to host1 and host2 requires a different context.xml. So I tried to solve this with a profile with copies a different context.xml with filtering for the hostname. Invoke would be like this:
mvn package -Pdeployment -Dhostname=host1

Package is created. I rerun the same process a second time for host2. Now the real problem arises when I do a release:perform to Nexus. I cannot produce two files at the same time during this process. Of course only one file is deployed. A second deployment does not work because Nexus blocks. I have to manually upload the second war file.

Is there any remedy to this? I want to avoid tampering with the assembly plugin since this would be just tedious work which the WAR plugin already does perfectly.

Thanks,

Mike
-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating and deploying two classified WAR files at once

Posted by Ron Wheeler <rw...@artifact-software.com>.
  This looks like "Best Practice" that most people who are building 
production systems need to have.
Can you elaborate a bit more.
Is this documented anywhere?

Ron

On 30/08/2010 7:32 AM, Stephen Connolly wrote:
> What I'm saying is that you (ultimately) should refactor your project so
> that one war works on all deployment targets.  That way you don't need to
> create multiple wars each tuned for the specific deployment environment.
>
> Solutions can include (but are not limited to):
>
> 1. Using JNDI or an external .properties file to hold the deployment
> specific config
> 2. Adding a deployment specific provider jar to the deployment target lib
> folder (e.g. abstract the deployment specific code behind an API and then
> deploy the tomcat-impl to tomcat's lib folder, the jetty-impl to jetty's lib
> folder the websphere-impl to websphere's lib folder)  Your war then picks up
> the required impl when deployed to any container
> 3. Coding to the spec (not always as hard as you might think)
>
> -Stephen
>
>
> On 30 August 2010 12:22,<sg...@gmx.net>  wrote:
>
>>> I think you'll find overlays as a smaller solution than adding in
>> multiple
>>> profiles to support multiple hosts.
>>>
>>> The reality is you should be abstracting out these things so that you
>>> don't
>>> need them any more and one universal war is all that is required.
>> Stephen,
>>
>> this comment [1] describes my issue.
>>
>> [1]
>> http://www.sonatype.com/people/2010/01/how-to-create-two-jars-from-one-project-and-why-you-shouldnt/#comment-44713627
>> --
>> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
>> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating and deploying two classified WAR files at once

Posted by Stephen Connolly <st...@gmail.com>.
What I'm saying is that you (ultimately) should refactor your project so
that one war works on all deployment targets.  That way you don't need to
create multiple wars each tuned for the specific deployment environment.

Solutions can include (but are not limited to):

1. Using JNDI or an external .properties file to hold the deployment
specific config
2. Adding a deployment specific provider jar to the deployment target lib
folder (e.g. abstract the deployment specific code behind an API and then
deploy the tomcat-impl to tomcat's lib folder, the jetty-impl to jetty's lib
folder the websphere-impl to websphere's lib folder)  Your war then picks up
the required impl when deployed to any container
3. Coding to the spec (not always as hard as you might think)

-Stephen


On 30 August 2010 12:22, <sg...@gmx.net> wrote:

> > I think you'll find overlays as a smaller solution than adding in
> multiple
> > profiles to support multiple hosts.
> >
> > The reality is you should be abstracting out these things so that you
> > don't
> > need them any more and one universal war is all that is required.
>
> Stephen,
>
> this comment [1] describes my issue.
>
> [1]
> http://www.sonatype.com/people/2010/01/how-to-create-two-jars-from-one-project-and-why-you-shouldnt/#comment-44713627
> --
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Creating and deploying two classified WAR files at once

Posted by sg...@gmx.net.
> I think you'll find overlays as a smaller solution than adding in multiple
> profiles to support multiple hosts.
> 
> The reality is you should be abstracting out these things so that you
> don't
> need them any more and one universal war is all that is required.

Stephen,

this comment [1] describes my issue.

[1] http://www.sonatype.com/people/2010/01/how-to-create-two-jars-from-one-project-and-why-you-shouldnt/#comment-44713627
-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating and deploying two classified WAR files at once

Posted by sg...@gmx.net.
Ok, thanks. I will give it a shot in the next couple of days. Let's see for other opinions.


> Yes, and each module would only have the files that are extra to that
> module
> 
> On 30 August 2010 12:18, <sg...@gmx.net> wrote:
> 
> > > I think you'll find overlays as a smaller solution than adding in
> > multiple
> > > profiles to support multiple hosts.
> > >
> > > The reality is you should be abstracting out these things so that you
> > > don't
> > > need them any more and one universal war is all that is required.
> >
> > Stephen,
> >
> > thanks for your input. How would approach look like?
> >
> > I deduce from your both input:
> >
> > project-parent
> > |
> > |-project-webapp-common
> > |
> > |-project-webapp-local (depends on common)
> > |
> > |-project-webapp-host1 (depends on common)
> > |
> > |-project-webapp-host2 (depends on common)
> >
> >
> > Mike
> > --
> > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating and deploying two classified WAR files at once

Posted by Stephen Connolly <st...@gmail.com>.
Yes, and each module would only have the files that are extra to that module

On 30 August 2010 12:18, <sg...@gmx.net> wrote:

> > I think you'll find overlays as a smaller solution than adding in
> multiple
> > profiles to support multiple hosts.
> >
> > The reality is you should be abstracting out these things so that you
> > don't
> > need them any more and one universal war is all that is required.
>
> Stephen,
>
> thanks for your input. How would approach look like?
>
> I deduce from your both input:
>
> project-parent
> |
> |-project-webapp-common
> |
> |-project-webapp-local (depends on common)
> |
> |-project-webapp-host1 (depends on common)
> |
> |-project-webapp-host2 (depends on common)
>
>
> Mike
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Creating and deploying two classified WAR files at once

Posted by sg...@gmx.net.
> I think you'll find overlays as a smaller solution than adding in multiple
> profiles to support multiple hosts.
> 
> The reality is you should be abstracting out these things so that you
> don't
> need them any more and one universal war is all that is required.

Stephen,

thanks for your input. How would approach look like?

I deduce from your both input:

project-parent
|
|-project-webapp-common
|
|-project-webapp-local (depends on common)
|
|-project-webapp-host1 (depends on common)
|
|-project-webapp-host2 (depends on common)


Mike
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating and deploying two classified WAR files at once

Posted by Stephen Connolly <st...@gmail.com>.
I think you'll find overlays as a smaller solution than adding in multiple
profiles to support multiple hosts.

The reality is you should be abstracting out these things so that you don't
need them any more and one universal war is all that is required.

-Stephen

On 30 August 2010 09:27, <sg...@gmx.net> wrote:

> > Hey Mike,
> >
> > I would create a module for each war (and probably one for the war
> > with no context.xml) and then make use of the "overlays" as described
> > here: http://maven.apache.org/plugins/maven-war-plugin/overlays.html
> >
> > With this a war can depend on another war and you can overwrite / add
> > / remove things at will. Adding the context.xml should be really easy.
>
> Samuel,
>
> I already thought about overlays but this seems to be a bit oversized for
> just replacing one file. Additionally, what happens if I would have four
> instead of two hosts in the future?
>
> Overlays would be my last resort.
>
> Thanks, I will take this into my consideration.
>
> Mike
> --
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Creating and deploying two classified WAR files at once

Posted by sg...@gmx.net.
> Hey Mike,
> 
> I would create a module for each war (and probably one for the war
> with no context.xml) and then make use of the "overlays" as described
> here: http://maven.apache.org/plugins/maven-war-plugin/overlays.html
> 
> With this a war can depend on another war and you can overwrite / add
> / remove things at will. Adding the context.xml should be really easy.

Samuel,

I already thought about overlays but this seems to be a bit oversized for just replacing one file. Additionally, what happens if I would have four instead of two hosts in the future?

Overlays would be my last resort.

Thanks, I will take this into my consideration.

Mike
-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Creating and deploying two classified WAR files at once

Posted by Samuel Le Berrigaud <sa...@gmail.com>.
Hey Mike,

I would create a module for each war (and probably one for the war
with no context.xml) and then make use of the "overlays" as described
here: http://maven.apache.org/plugins/maven-war-plugin/overlays.html

With this a war can depend on another war and you can overwrite / add
/ remove things at will. Adding the context.xml should be really easy.

HTH,
SaM

On Mon, Aug 30, 2010 at 09:34,  <sg...@gmx.net> wrote:
> Hi folks,
>
> I am facing a config problem with deploying two classified WAR files at once. My setup is this, I have a WAR project which is developed and tested locally with Tomcat and Eclipse. Deploying this WAR file to host1 and host2 requires a different context.xml. So I tried to solve this with a profile with copies a different context.xml with filtering for the hostname. Invoke would be like this:
> mvn package -Pdeployment -Dhostname=host1
>
> Package is created. I rerun the same process a second time for host2. Now the real problem arises when I do a release:perform to Nexus. I cannot produce two files at the same time during this process. Of course only one file is deployed. A second deployment does not work because Nexus blocks. I have to manually upload the second war file.
>
> Is there any remedy to this? I want to avoid tampering with the assembly plugin since this would be just tedious work which the WAR plugin already does perfectly.
>
> Thanks,
>
> Mike
> --
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org