• 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

Maven: activating a default profile, with a twist

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using Maven 3.0.3. I have defined a number of profiles with id's dev, qa, prod, jetty, and tomcat. If neither of dev, qa, or prod is entered, I would like the "dev" profile to be active. How do I configure this?

Thanks, - Dave
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what's the twist? You can specify the default profile in the POM. I've done it myself for projects where the production machine was significantly different from the development machine that different dependencies were required.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The twist is if someone specifies either the "jetty" or "tomcat" profiles, without specifying "dev", "qa", or "prod", I want the "dev" profile to also be activated. So, running



should also force the "dev" profile to be active. How do I make that happen? This won't work with the above example ...


 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. I should mention that my webapps are normally designed to use the same build for dev, test and production; I do the environment-specific stuff in the deployment, not in the app itself. Not only does this make my deployables one-size-fits-all, it also ensures that the code being tested is the same code that broke in production. I only use profiles when the differences are too radical for that, such as development on Tomcat for deployment on JBoss (which, unlike Tomcat has JSF built in and doesn't need the extra jars).

There are 3 possibilities that I know of.

1. Activate the tomcat profile as a default too. Since you can have more than one profile applied to a build.

2. Duplicate the desired profile elements in the default profile

3. Put it all under a super-POM that recurses on Maven with the desired profiles.

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried your second suggestion by adding



but it seems I have bigger problems. I thought the above means that "env" is now a variable I can use in my script. But when I run



it dies with the error ...



Here is the maven code I'm using to copy environment specific properties ...

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic