PDA

View Full Version : JSP, Ant, & JavaScript Build Best Practices



evankstone
11 Sep 2007, 2:14 PM
Sorry if this isn't the right forum for this question, but it seemed like a good place for it. Let me know if I should post this elsewhere.


I'm looking for advice (or personal experiences, web/print resources) on best practices surrounding doing builds and deployment with JavaScript and Java-based web technologies (specifically JSP/JSF in my case), since I'm getting to the point where it's going to be important to be able to automate the minification and deployment of our JavaScript libraries and also the pages that include them.

It seems to me that I'd like to be able to use my current toolset locally (eclipse, with exploded deployments under JBoss) for JavaScript development work and be able to work on the separate, smaller .js files that get minified and merged by the build script to make up a bigger, single library file for deployment (kind of like how Ext seems to be architected).

But then it seems there needs to be some kind of conditionality in the JSP files that have the includes for the .js files. When working locally, I'll need to point to the handful of separate files, then during the build process the page would have to be changed so that it points to the single, minified aggregate version of the library...

So how do developers who are using this mix of technologies typically manage this scenario?

Thanks!

:D

Animal
17 Sep 2007, 7:43 AM
What I do is I have one, overall tag which produces the page which knows that it's an Ext application, needs the Ext javascript files first, and then our owb javascript files.

Usually, it uses the large, concateneted and minified file containing everything that is built using Ant.

But if the request contains the parameter "debug", it outputs a whole load of <script> tags for each of our uncompressed javascript files, and ext-all-debug.js.

I've discussed elsewhere, the code production engine needs to be aware of the browser environment. Our JSP tags have extensive knowledge about Ext, and our in-house javascript widgets.

So in the Ant script, I concatenate up ext-all.js, plus all our other files, and minify them into "aspicio.js".

As I say, tha page generation tag either uses that, or it loops through all our javascript including them all.

Ours is a single page app. We load all our javascript once, and only page fragments are loaded from then on.

The page tag knows when it is being asked for a fragment, and when it is being asked for a full page, so it either creates "<DOCTYPE><html><head><script>" etc etc around the actual HTML, or it doesn't depending on the context.

bhaidaya
19 Dec 2008, 7:38 AM
poor mans build toy.... Check this out

http://extjs.com/forum/showthread.php?t=55711