- This topic has 3 replies, 2 voices, and was last updated 12 years, 1 month ago by pierre.henry.
-
AuthorPosts
-
pierre.henryMemberI have set up a WAR Maven project in MyEclipse 10.6 using profiles to replace some configuration files such as log4j.xml and struts.properties based on the active profile.
You can find some details and a discussion of the configuration here : http://stackoverflow.com/questions/12729513/how-to-overwrite-files-in-the-war-file-during-maven-build/
As explained there, I have excluded the files that I need copied from some profile-specific folder from the resources in the pom.xml :
<resources> <resource> <directory>src/main/resources</directory> <excludes> <!-- Eclude those since they are copied from the profile folder for the build --> <exclude>log4j.xml</exclude> <exclude>struts.properties</exclude> </excludes> <filtering>false</filtering> </resource> </resources>
Those files are copied from active profile folder or default in the WAR packaging phase :
<warSourceExcludes>**/context.xml</warSourceExcludes> <webResources> <!-- Resources from the activated profile folder --> <resource> <directory>/src/main/config/${environment}</directory> <targetPath>META-INF/</targetPath> <includes> <include>context.xml</include> </includes> </resource> <resource> <directory>src/main/config/${environment}</directory> <targetPath>WEB-INF/classes/</targetPath> <includes> <include> struts.properties </include> <include> log4j.xml </include> </includes> </resource> <!-- Default resources in case some file was not defined in the profile folder --> <!-- Files are not overwritten so default files will be copied only if it does not exist already --> <resource> <directory>/src/main/config/default</directory> <targetPath>META-INF/</targetPath> <includes> <include>context.xml</include> </includes> </resource> <resource> <directory>src/main/config/default</directory> <targetPath>WEB-INF/classes/</targetPath> <includes> <include> struts.properties </include> <include> log4j.xml </include> </includes> </resource> </webResources>
Now, Maven4MyEclipse is smart enough not to copy these files when I deploy to Tomcat using the tomcat connector (which I hoped it would not) BUT is not smart enough to copy the files from the profile.
In other words, the maven builder seems to do some of the things defined in the Maven build but not all, so the result that gets deployed to Tomcat is NOT the one intended by the pom.xml, NOR the one that would bew deployed if the pom was just inexistent or ignored, and misses some files and does not work.
Is there a documentation that specifies exaactly which parts of the pom it applies and which not ? And is there a way to disable it (but not the dependency management) ?
What do you suggest I should do ?
Best regards.
pierre.henryMemberUpdate :
For now, I achieved the desired behaviour by copying the files from the profile’s folder in the resources section instead of the WAR-specific webResources :
<resources> <resource> <directory>src/main/resources</directory> <excludes> <!-- Eclude those since they are copied from the profile folder for the build --> <exclude>log4j.xml</exclude> <exclude>struts.properties</exclude> </excludes> <filtering>false</filtering> </resource> <resource> <directory>src/main/config/${environment}</directory> <excludes> <exclude>context.xml</exclude> </excludes> </resource> <resource> <directory>src/main/config/default</directory> <excludes> <exclude>context.xml</exclude> </excludes> </resource> </resources>
So now, when deploying to Tomcat, MyEclipse takes the log4j.xml and the struts.properties files from src/main/config/default which is fine. The ones in src/main/resources are not used any more and I deleted them.
However I would still appreciate some insight into the MyEclispe build process for Maven project. What is done and in what order…
Regards,
Brian FernandesModeratorPierre,
Our deployment is a two step process:
1) The directory level includes and excludes are converted into Deployment Assembly settings that you can find on the Project properties > MyEclipse > Deployment Assembly page. We currently do not have the ability to filter resources at the file level.
2) If Deployment Assembly is enabled (on the above page), our deployer will use these settings to perform the actual deployment. The Maven builder or Maven itself are not involved in the actual deployment process when resources are copied over to the server.
a) We are constantly working on improving our Maven deployment process and control – in MyEclipse 11 we are moving to infrastructure that will allow us to control exactly what should be deployed at a very fine grained level – this should appear in MyEclipse 11.1.
b) As far as the issues you raised in this and other posts about filtering, I’m looking to whether any variables are correctly being expanded and respected. We’ll also look to see if any of your filtering requirements can be incorporated into 10.7.
Hope this helps, thank you for asking.
pierre.henryMemberThank you for these explanations.
I understand that you are working on the filtering capabilities, but that it is not currently supported. I would really appreciate it if it was included in 10.7.
Best regards and thanks again for the support on the various maven-related issues I raised.
-
AuthorPosts