What you want to do is move the css out of src/main/webapp to e.g.
src/processed/webapp

Then you bind the groovy step for processing to the prepare-package phase
(or any earlier one either) putting the processed files in
target/generated-webapp/groovy/... and use
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#webResourcesto
add the target/generated-webapp/groovy directory that you've put the
processed CSS files into back into the list of files that should be
packaged into the war file.

Warning: side-effect is that jetty:run will no longer have the CSS files.
jetty:run-exploded will work, but you cannot live-edit the source files

An alternative is to use a second webapp module to do the CSS processing
between the exploding and repacking steps. Has the advantage of letting
jetty:run continue to work.

An alternative is to use resource filtering rather than Groovy to filter
the CSS file.

http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

you'd have in your CSS file something like
url(/images/myimage${image-revision}.png) and have the war plugin filter
CSS files so that the image-revision property gets substituted directly.

Jetty:run may still have issues, but you've used standard maven tech to get
to your end-game


On 12 February 2013 09:43, Cagecurrent <p...@cagecurrent.com> wrote:

> Yes, I want to be able to use Groovy to modify the image references in the
> CSS, but *not* in the /src directory as that is in subversion.
>
> The change I'm doing is to be able to increase the caching times for the
> images. So for example I would replace the image reference
> url(/images/myimage.png) with url(/images/myimage~r2323.png). This way I
> can
> have really long caching times for the images without having to manually
> change the name of the image.
>
> The ~r2323 will be removed in a rewrite in the proxy, so the image
> myimage.png will still be served from the server.
>
> But as I said, I don't want to modify the CSS in the /src folder as it will
> make subversion so it as edited. So the plan is to modify the version of
> the
> CSS file once it's been copied over the /target folder, but it needs to be
> done before the WAR is created.
>
> Thanks a lot for your help!
> /Per
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728p5746755.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>

Reply via email to