Maven String Replace of Text Web Resources

后端 未结 5 1120
萌比男神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:31

    Another solution from me, sorry for being late to the party but still might be useful for some people. Solution above simply didn't work for me because I had overlays in place and therefore using the replacer plugin was hard in the main source. Hence, I used maven-war-plugin to generate the temporary directory for me in the prepare-package phase and have replacer plugin to manipulate it and release the war from that directory so that nothing else overrides with it.

          
        maven-war-plugin
        
          
            prepare
            prepare-package
            
              exploded
            
            
              ${project.build.directory}/${project.build.finalName}-patched/
            
          
          
            default-war
            package
            
              war
            
            
              true
              ${project.build.directory}/${project.build.finalName}-patched/
            
          
        
      
      
        com.google.code.maven-replacer-plugin
        replacer
        
          
            prepare-package
            
              replace
            
          
        
        
          ${project.build.directory}/${project.build.finalName}-patched/fileToBeChanged.txt
          ValueToChange
          ValueToReplace
        
      
    

提交回复
热议问题