Karl,

Thank you for responding.  Yes I can go into more detail.  

Lets go back to my example of the mysql DB credentials.  Lets say I have five 
environments.  So that means I have 3 variables times 5 environments and that 
comes out to 15 various values.  From what I understand about the 
maven-resources-plugin that would mean I would have to do one of the following: 

1)  Stick those 15 values in the pom and then maybe use 5 different profiles, 
one for each env.  This can get quite cumbersome and our deployment scripts 
would have to call mvn with the correct profile.

2)   Use system variables.  Have some code called at some point before the 
maven build that would know which environment it is in and retrieve all the 
values for each known property and make system variables out of them.  From 
what I understand this might still require I have them in the POM; I'm not sure 
if maven-resources-plugin would automatically replace each ${propertyName} with 
the proertyName system variable without having to have the propertyName in the 
POM?

3) Is there another way that I am missing that this can be done using 
maven-resources-plugin?  I can see that it is very powerful tool, as everything 
in Maven has proven to me to be so I'm probably missing another approach.

A few things to consider that I would like to have...
1) Centralized view into all our properties that can be queried and have tools 
built on top of (e.g. a maven resource filter).

2) Minimal entries of propertyName.  Essentially the ${propertyName} should 
only be entered into the property file and after that just the entries that go 
into the central data store.  The pom is left alone.

3) Environments can be easily added and removed and altered by only touching 
the centralized datastore.

I guess those three things have one thing in common, benefits of having our 
properties in a centralized datastore.  At my current employer they built just 
such a system that works off of web services (managed global properties on a 
per environment basis).  It is not in production yet so from my point of view I 
will interface out the Dao and just swap implementations when its ready... 
using a simple relational DB at first. 

thanks
jose


On Monday, August 18, 2014 2:06 PM, Karl Heinz Marbaise <[email protected]> 
wrote:
 


Hi Jose,


can you elaborate a little bit more why you are not using the default 
filtering capabilities of maven-resources-plugin etc. ?

Can you explain what exactly you like to achieve?



> Hello,
>
> We have projects with many property and xml files that need resource 
> filtering per environment.
>
> For example in a property file one might see ${mysqlDbHost}, ${mysqlDbPw}, 
> and ${mysqlDbUser}.  There would also be a system variable called 
> ENVIRONMENT.  Based on the ${propertyName} and ENVIRONMENT value, the 
> resource filter would replace with the correct value.  This can be done with 
> a DB (SELECT value FROM properties WHERE env="env" and name="propertyName") 
> or via a web service (getPropertyValue?env=env&name=propertyName).
>
> On the Maven side the solution seem to be to create a custom 
> MavenResourcesFiltering.  The custom MavenResourcesFiltering implementation 
> would do the lookups I mentioned above for each ${propertyName} encountered 
> in the resource files.
>
> 1)  Is my assessment that creating a custom MavenResourcesFiltering is the 
> way to go?  Maybe this problem is already solved already, since it does not 
> seem unique?
>
> 2)  I have visited multiple Maven articles on this but still have no idea how 
> to implement it, the sites I visited are listed below.  Does anyone know of 
> any document or can provide feedback on how to implement a custom 
> MavenResourcesFiltering?
>
> It seems to me that at some point I would need a method that has either gets 
> a list of all the ${propertyName}'s found in a file and the ability to 
> provide the value for that property name.  Following the links I found I 
> cannot tell where that method should be implemented and how to get it called 
> from MyMojo.execute().
>
> 1:  http://maven.apache.org/shared/maven-filtering/
> 2:  http://maven.apache.org/shared/maven-filtering/usage.html
> 3:  http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>
> Thank you!
> jose
>

Kind regards
Karl-Heinz Marbaise

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to