Maven String Replace of Text Web Resources

后端 未结 5 1113
萌比男神i
萌比男神i 2021-02-07 07:38

I have a Maven web application with text files in

src/main/webapp/textfilesdir

As I understand it, during the package phase this te

5条回答
  •  臣服心动
    2021-02-07 08:37

    Option 1 is not doable, prepare-package is too early, package is too late so I don't see where you could plug any custom work. Option 2 is doable but a painful IMO. So here are some more propositions (all based on AntRun and the ReplaceRegExp and/or Replace tasks).

    Solution 1:

    1. Create a new folder where you put the text files that need to be processed.
    2. Bind the antrun plugin to prepare-package and configure it to process the files and put the processed files in some directory under target (e.g. target/textfilesdir).
    3. Configure the war plugin to include target/textfilesdir as a webResource. Refer to Adding and Filtering External Web Resources for the details.

    Solution 2:

    1. Bind the antrun plugin to prepare-package and configure it to process the text files from src/main/webapp/textfilesdir and put the processed files in the target/project-1.0-SNAPSHOT.
    2. Configure the war plugin to exclude the previously processed files. Again, refer to Adding and Filtering External Web Resources for the details.

    I think I'd go for the second solution.

提交回复
热议问题