By default, the compress goal of the YUI maven plugin is bound to the
process-resources phase.
So, you need to bind it to another phase after the war plugin has produced
the war directory structure the Tomcat plugin will use.
I recommand you also customize the outputDirectory parameter of the YUI
maven plugin because the default value does not comply with the standard
Maven War directory layout.

Regards
Jeff MAURY

---------- Forwarded message ----------
From: fe.character.guide <fe.character.gu...@gmail.com>
Date: Fri, Dec 2, 2011 at 7:17 AM
Subject: YUI Compressor Maven plugin executed at wrong time and tomcat
plugin not using yui-compressor output
To: users@maven.apache.org


Hello everyone!

I'm trying to get some basic maven build processes configured correctly
with my Java project, and beyond Stackoverflow, I'm not sure
where else to turn.

I'd like to compress all of my javascript files and aggregate them using
YUICompressor, and I saw that there was a maven plugin to allow me to do
this. I got it working for the most part.

I am also using the Mojo tomcat plugin as well. When i go to run the
tomcat:run goal, tomcat does not read from the target's output
directory (this is where the YUI compressor put my javascript files) - but
rather, it reads from the actual source files in my "src/main/
webapp/scripts" directory. Of course, the aggregated javascript file
(all.js) is not there. This makes sense, but is a big problem for me.

I have a few questions.

1. How can I get the tomcat plugin to read the target's output folder that
the yui compressor plugin created?

2. Do I have to run the yui compressor maven goal every time I want to
update my javascript files during development while my tomcat instance is
running?

3. How can tell Maven that I want to run the YUI compressor AFTER Maven
copies over the `src/main/webapp` directory? Currently, Maven runs the YUI
compressor, but then overwrites all of the compressed css and javascript
files with the original source files, defeating the purposes of compressing
them ;)

4. Is there a better way to achieve my objective rather than using the YUI
compressor? Essentially, my end goal is to be able to develop JavaScript
code in separate files and test my source files in development mode without
having to aggregate them... but I want to compress and aggregate the files
and use the `all.js` script when the application is running in production
mode.

While the Rails people have certainly figured this out, this seems to be a
non-trivial thing to do with Maven and Spring.
I would appreciate any and all assistance on how I can get this running
correctly. Thanks!



-- 
"Legacy code" often differs from its suggested alternative by actually
working and scaling.
 - Bjarne Stroustrup

http://www.jeffmaury.com
http://riadiscuss.jeffmaury.com
http://www.twitter.com/jeffmaury

Reply via email to