I want to update content inside all script tags in jsp files present under src/main/webapp/jsp. How to do this during maven build phase?
I am using java+spring+maven stack.
Ok here is example of what I want to achieve:
Source code:
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="js/core/validator.js"></script>
<script type="text/javascript" src="js/app/util/core-util.js"></script>
<div id="dataContainer">
</div>
After maven build, this should be present in target folder
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="js/core/validator.js?version='<MD5SUM-of-js/core/validator.js>'"></script>
<script type="text/javascript" src="js/app/util/core-util.js?version='<MD5SUM-of-js/app/util/core-util.js>'"></script>
<div id="dataContainer">
</div>
Please note the version parameter at the end of src="".
Update: Finally, I was able to make it work following way. Feel free to suggest alternative if any.
Prepared shell script to generate properties file something like this
js/core/validator.js=js/core/validator.js?version\=MD5SUM-of-js/core/validator.js
js/app/util/core-util.js=js/app/util/core-util.js?version\=MD5SUM-of-js/app/util/core-util.jsConfigured maven-replacer-plugin to use this properties file as token value map and filter all the jsp files present under target/app/jsp folder.