Is there any reason why deployment and server specific configurations
are mixed in with your code?
This is not a good thing and usually not needed.
When you configure a server, you should be able to include this
information in the server configuration not in the application code.
1) The application should run on whatever server it finds itself loaded on.
If it needs to know something about the server, it should ask the
server. This includes stuff like webservice endpoints if they change
between test and production - and the had better or someday you may find
a test calling production services and really making a big mess.
If you leave this kind of stuff in the hands of a developer, you are
bound to have something bad happen eventually.
2) When you build a release of something you should not be rebuilding it
after you have tested it unless you are going to test it again.
There is no way to do this with the structure that you are proposing.
3) You are making your builds too complicated and error prone.
See JNDI. http://download.oracle.com/javase/jndi/tutorial/TOC.html
From my blog http://blog.artifact-software.com/tech/?p=58
BTW. You are not the only one who has to run software on development
machines, test machines and often hundreds or thousands of production
machines.
You do not need to go down this route and the usual destination is not a
good one.
Fix it as soon as you can and your whole development to production cycle
will get much easier.
Ron
On 20/01/2011 1:09 PM, Jeff wrote:
Thanks all for the comments. If there is a better way to do what I need,
then I welcome help to understand how to do it right.
We have configurations we need to load for the various development and
testing environments (unit and integration).
I've been working to put the specific configuation information for each
environment (URL's, IP's, debug levels, etc.) into property files. Each
property file will have a name like "test.properties" or
"staging.properties". There is a 1 to 1 mapping between a maven profile
and each properties file. (e.g., profile.id = "staging" loads
"staging.properties")
As I understand it, the *profile mechanism is the way to affect behavior at
run-time*. So I'm setting a system property in the profile that will
trigger a specific file to be loaded.
If there is a better way for my code to know what profile was selected, I've
not been able to find it.
Since each profile is identical except for the id and the value of the
system property being set and maven encourages universal reuse, I was hoping
to just reference the profile id when setting the system property. Then
when I copy the profile to add new ones all I would need to change is the
profile id.
Thoughts?
On Thu, Jan 20, 2011 at 8:39 AM, Wayne Fay<[email protected]> wrote:
I'm new to Maven and am building a POM with profiles. I want to be able
to
Then you are most likely doing things "wrong." Is there no other way
to build/test your app without using profiles?
Currently the value of the "config" system property is equivalent to the
value of the profile id. Is there a syntax in the POM for referencing
the
id of the profile that is in the parent chain of the property being set?
Not that I'm aware of. The simplest fix is to just put the word
"staging" in that plugin configuration, since your plugin is inside
the profile anyway. The next simplest "fix" is to have another
property, say profile-name, that you copy your profile id to and then
reference that property where you need to use the name.
Wayne
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]