I have a jsp that contains a css link that looks like
<link type="text/css" href="/css/login-min.css" rel="stylesheet" />
In order to keep browsers from caching the css file we replace login-min.css with the name of the css and a timestamp or version number
login-min.css?t=432432423423...
In ant I would do something like
<tstamp>
<format property="current.time" pattern="MMddyyyyhhmmssaa" offset="-5" unit="hour" />
</tstamp>
<replace dir="${deploy.path}/${name}/WEB-INF/jsp" value="login-min.css?t=${current.time}">
<include name="includes/login_css_include.jsp" />
<replacetoken>login-min.css</replacetoken>
</replace>
For gradle I’ve updated the jsp page to look like
<link type="text/css" href="/css/@loginCSS@" rel="stylesheet" />
and in the build.gradle am doing
import org.apache.tools.ant.filters.ReplaceTokens
war {
webInf {
from ("${webAppDir}/WEB-INF/jsp") {
include: "/includes/login_css_include.jsp"
filter(ReplaceTokens, tokens: [loginCSS: 'login-min.css?v=1'])
}
}
}
but this isn’t working.
This one works but it changes the source… I just want the files in the war to be modified.
import org.apache.tools.ant.filters.ReplaceTokens
war {
webInf {
from ("${webAppDir}/WEB-INF/jsp/includes/login_css_include.jsp") {
it.eachFile {
ant.replace(file: it.file, token: "@loginCSS@", value: "login-min.css?v=1")
}
}
}
}
I’m brand new to gradle am I going about this totally incorrectly? Anyone needed to do something like this before? Using gradle 1.0-milestone-1.
Thanks
Ok, this seems to work:
jsp page:
build.gradle: