• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Programmatically select web.xml to be "built" depending on profile

 
Ranch Hand
Posts: 42
Oracle Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am developing a web application that uses a web.xml file.
During the development phase on my PC I need to use some Servlet that I don't want to use on my testing environment at work.
Is it possible to tell Maven to built using a different web.xml file when building using a different profile?

Or is it possible to setup a script used by maven that removes the parts I don't need within my web.xml file?
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can do this.

One way: Add a <build> section to you profile and add a <plugin> section fort he WAR plugin, then for each profile specify a different web.xml

Another way: have one web.xml which contains property references (e.g. ${production.stuff}). Then have two profiles, one that sets production.stuff to an empty string and the other that sets production.stuff to the web.xml content you want to include in your dev environment.

I make extensive use of the second option above for a number of things, including log4j settings and various tweaks that I use while testing. Also, I usually have only one profile which I use for setting development options, and it is in my settings.xml file - in the POM I set the production property values. This way the build machine picks up only the production values without having to set and specific profile, and my development build picks up my settings.
 
Francesco Bellini
Ranch Hand
Posts: 42
Oracle Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Peter,

I will try this as soon as possibile. For me, solution 1 seems to be more confortable. ;) I will do some test.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic