aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Filtering problem using maven-read-properties plugin in pom.xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Filtering problem using maven-read-properties plugin in pom.xml file" Watch "Filtering problem using maven-read-properties plugin in pom.xml file" New topic
Author

Filtering problem using maven-read-properties plugin in pom.xml file

Marcelo Tataje
Ranch Hand

Joined: Jan 31, 2011
Posts: 64

Hello everybody, in an older post I ask for some help to create a pom.xml in which I could set properties in some project's files using the pom.xml based on an external properties files. I finally achieved my purpose, well I thought so because when I run the mvn install, not all the files variables are being replaced. My project is a Web Service Client (METRO based), the structure of my project is like this:

webserviceClient(root)
---------SRC
----------------MAIN_DIRECTORY
------------------------JAVA_DIRECTORY
--------------------------------config.properties
--------------------------------log4j.xml
------------------------RESOURCES_DIRECTORY
----------------TEST_DIRECTORY
----------------WSDL_DIRECTORY
------------------------samplewsdl.wsdl
------------------------
----------------wsit-client.xml
----------------samplewsdl.xml
----------------jax-ws-catalog.xml

Kind of complex, the point is that the files I want to set the variables are located in different parts, some of them in the root of SRC, some of them inside JAVA directory and not inside resources, another resource is located inside WSDL directory. When I execute my pom.xml is like it builds the application and put the files inside classes directory inside target, but when I look for a META-INF autogenerated folder the files are still with the ${variable} reference. That's why I'm having problems with the deploy. I know the problem is in resource filtering tag, but I've tried everything and sometimes the filtering copies the source code but without any change of the ${variable} reference. Is there any way to replace all the resources in the SRC (which contains all the files) and generate the build with the variables replaced by the values specified in properties. I'll be really grateful if you could help me, my pom is as follows:




Thanks for your help, any advice will be really appreciated.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

According to lines 24-27, you are not filtering anything that is being copied into the META-INF directory.

I recommend a slightly different directory structure:



This gets the three "orphan" config files out of the ssrc directory and into their own subdirectory. Then when you specify the resources directory for filtering (I assume that is lines 28-31), you don't have to be concerned with a lot of other junk being copied with it. Nor do you have to ask yourself questions such as "if I set the <directory> for two <resource> entries to the same location (lines 26 and 30), does this define two different instances of the resources being copied, or does one override the other?"


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filtering problem using maven-read-properties plugin in pom.xml file