I am trying to use the Pre-processing setting tab in the Artifact configuration Project setting but it is not working as I would expect.
I have two artifacts set up in my Project Settings. One is an exploded WAR, the other is a WAR which includes the exploded WAR artifact. Everything builds fine, I get a WAR and I get an exploded WAR directory when I build.
So with that building my goal became to edit a properties file which is in a src directory, src/main/java/com/foo/view/message.properties and dynamically set a property (build number in this case) in it, but I could not find a way to do this directly in the project settings.
What I decided to try was to use an ANT task to modify the properties file and call the task from the Pre-processing step of my exploded WAR artifact.
After creating this ANT task and configuring the Pre-processing step of my exploded WAR artifact to call it I am seeing that the file is properly edited and is in the correct location in the WEB-INF\classes\com\foo\view directory of the exploded WAR folder, however, the WAR file built by the WAR artifact which uses the output of the exploded WAR artifact does not included the modified file, it includes the unmodified one instead.
I assumed, based on reading the online help, that the Pre-processing step occurs prior to artifact generation. In this case it should call the ANT task to modify my properties file before generating the exploded WAR artifact. Then, because my WAR artifact is dependent on the exploded artifact it should pick up the modified file and include it in its artifact WAR.
Any thoughts on why this isn't behaving as expected? Is there a better way to accomplish what I am trying to do without using ANT or other external tool? I would like to be able to modify this properties file simply using IDEA and pure IPR settings if possible.
This seems to have something to do with how the project is including the exploded WAR artifact in the WAR artifact. I did the following:
0. Disabled all Pre-processing settings
1. Deleted my build\artifacts directory
2. Built the exploded WAR artifact
3. Went into the build/artifacts/exploded_artifact_folder and modified the properties file by hand
4. Built the WAR artifact
5. Opened the WAR and inspected the properties file and found it did not contain my edits
Clearly based on what I am seeing, even though my project settings say to include the exploded WAR artifact it is not including the files from the exploded WAR artifacts output directory.
Based on this I decided to try changing my ANT target to update the message.properties file that had been copied into MODULE.OUTPUT.DIR tree. Sure enough that worked. Both the exploded artifact and the WAR artifact picked up the modified file.
I was surprised to see this behavior because when you tell IDEA to auto generate the ANT files it generates an ANT file with a target for the WAR artifact that ZIPs up the contents of ARTIFACT.OUTPUT.MODULE_EXPLODED. This points to build/artifacts/MODULE_NAME_EXPLODED not MODULE.OUTPUT.DIR, so either the ANT generation is broken or the IDEA artifact generation is broken.
It looks like the Pre-processing settings are not reflected in the artifact target as a dependency when you tell IDEA to generate the ANT build file. I think this is a bug as well.