Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

creating custom Maven resource filter

$
0
0
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

Viewing all articles
Browse latest Browse all 5648

Trending Articles