You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Cagecurrent <pe...@cagecurrent.com> on 2013/02/12 09:30:04 UTC

Modifying a CSS file with Groovy in target before packaged into WAR

Hi,
I'm trying to figure out how to get my Groovy code to execute after my CSS
files has been copied from /src to /target, but *before* the content is
packaged from /target into the WAR file. Any hint on where to add this into
the pom.xml?!?

Thanks in advance!
/Per



--
View this message in context: http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Stephen Connolly <st...@gmail.com>.
That is the "An alternative is to use a second webapp module to do the CSS
processing between the exploding and repacking steps." route I suggested


On 12 February 2013 10:31, Cagecurrent <pe...@cagecurrent.com> wrote:

> Thanks for your help! :)
>
> I guess another solution would be to modify the CSS files in the WAR after
> that it has been created, do you see any problems with that?
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728p5746761.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Cagecurrent <pe...@cagecurrent.com>.
Thanks for your help! :)

I guess another solution would be to modify the CSS files in the WAR after
that it has been created, do you see any problems with that?



--
View this message in context: http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728p5746761.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Stephen Connolly <st...@gmail.com>.
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 <pe...@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-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Cagecurrent <pe...@cagecurrent.com>.
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-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Anders Hammar <an...@hammar.net>.
You can't. Those files are copied and package in one go.

If you explain what you want to do, without including a solution you think
is right, we can probably help you. I think you're trying to modifying the
css files through executing a groovy script, is that right?

/Anders


On Tue, Feb 12, 2013 at 10:20 AM, Cagecurrent <pe...@cagecurrent.com> wrote:

> Stephen, so you mean that I *can't* add anything in the middle of that? Or
> can I override the normal process?
>
> Sorry if I ask stupid questions, but I'm not that fluid in speaking Maven.
> :)
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728p5746743.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Cagecurrent <pe...@cagecurrent.com>.
Stephen, so you mean that I *can't* add anything in the middle of that? Or
can I override the normal process?

Sorry if I ask stupid questions, but I'm not that fluid in speaking Maven.
:)



--
View this message in context: http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728p5746743.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Stephen Connolly <st...@gmail.com>.
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Built-in_Lifecycle_Bindings

Have a look at the "war" lifecycle, you'll see that there is only one goal
that does the copying from src/main/webapp to target/${finalName} and that
is the war:war goal which does the copy and zip in one step.


On 12 February 2013 08:30, Cagecurrent <pe...@cagecurrent.com> wrote:

> Hi,
> I'm trying to figure out how to get my Groovy code to execute after my CSS
> files has been copied from /src to /target, but *before* the content is
> packaged from /target into the WAR file. Any hint on where to add this into
> the pom.xml?!?
>
> Thanks in advance!
> /Per
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Cagecurrent <pe...@cagecurrent.com>.
I forgot to mention we are using Maven 2.2.1.



--
View this message in context: http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728p5746729.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Cagecurrent <pe...@cagecurrent.com>.
Anders: My files are in src/main/webapp/shared/eipa/css/elayout.css, and the
target is folder is 
target/ROOT/shared/eipa/css/elayout.css





--
View this message in context: http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728p5746742.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Modifying a CSS file with Groovy in target before packaged into WAR

Posted by Anders Hammar <an...@hammar.net>.
Exactly what folder do you have your css files in?

/Anders


On Tue, Feb 12, 2013 at 9:30 AM, Cagecurrent <pe...@cagecurrent.com> wrote:

> Hi,
> I'm trying to figure out how to get my Groovy code to execute after my CSS
> files has been copied from /src to /target, but *before* the content is
> packaged from /target into the WAR file. Any hint on where to add this into
> the pom.xml?!?
>
> Thanks in advance!
> /Per
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Modifying-a-CSS-file-with-Groovy-in-target-before-packaged-into-WAR-tp5746728.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>