08/02/2006

development environment (one)

i've been quite busy lately developing a web application for a friend's small business. in doing so, i've discovered (re-discovered) a good set of tools, and i think i now have the best dev-env that i can manage for free. so, this blog is a discussion and description of what my setup is like and what tools i'm using and why...

i use Apple Macintosh computers almost exclusively now (a G4 15" powerbook, from my friend gav, who died last year and left it to me. thanks. you're still remembered...) and the only thing that bugs me is the single-button mouse, and the fact that one has to control-click to access context menus etc. anyway, i recently invested in a microsoft notebook mouse, a small two button plus scroll-wheel optical USB mouse (about 33% the size of a standard mouse). this simply works just like you'd hope it would, ie. the right mouse button is the equivalent of control-clicking, and pops up the context menu for the item you click on, in the finder, java applications, eclipse, whatever. the scroll-wheel also works exactly like windows, and both of these features have raised my productivity no end. the trackpad on a laptop is inherently tricky as it is, and i'm glad to be rid of it.

eclipse ide



in terms of software, i had always used vi on Unix systems, which i learned in university, and graduated on to vim eventually, since it's also available for XP. however I recently tried the Sun NetBeans 4.1 IDE and really liked it. i then got Eclipse 3.1 (originally from IBM) for OS X and installed it to try with my current project, since there seemed to be more plug-ins available for it. i really like both of them, having used Microsoft Visual Studio on XP, and find they are quite similar. (as an aside, although VS2005 is quite expensive, and the free .NET command-line tools provided with the SDK are OK, Microsoft have now made available Express Edition of VS for C#, VB and even C++ for free, as in beer, for at least the next year.) anyway, of the two open source IDEs, i think i prefer the way Eclipse works, with its views and perspectives and enormous collection of editor and environment plug-ins.

in my development setup, i use Eclipse with the standard set of web and enterprise plug-ins. these are all packaged together as the Web Tools Platform or WTP. this gives me XML, HTML, CSS, JSP, and many more editors and views. because of this, i can now edit all the files in my web application with an Eclipse native editor and integrated debugging, error reporting/detection and validation (except for JSPs, since the editor doesn't handle taglibs that are imported with a

<%@ taglib ... %>


directive in a sub-fragment included in the main page using a

<%@ include file= ... %>


directive. this is perfectly legal in the JSP spec, since the include directive is processed before compilation (like #include pre-processor directives in C), unlike the

<jsp:include ... >


tag and similar, which are processed at runtime. this means that my struts JSPs which use the html, bean and logic taglibs all show up with warnings, since the editor can't see the included taglib declaration. all quite annoying, and i had to turn off JSP validation, although that still doesn't always work. i tried a bunch of other plug-ins, but the better ones were all 30-day trials of commercial software (MyEclipse, EnterpriseWorkbence, ExpressWorkshop etc.) or poorly integrated and incomplete. the WST project is the official Eclipse set of J2EE/Web editing tools, originally the IBM Web Tools for Eclipse product, and is currently at version 1.5 and works fine for my purposes.

other Eclipse features i like are the ant integration and incremental compilation. i use Apache ant as my build mechanism because it allows me to do command-line builds and also deployment and other tasks in a repeatable way. i have tasks set up for compilation, war creation, database creation, code generation, revision control, backups and app-server deployment. Eclipse has an ant view that shows all available targets and an editor for your build.xml file that interprets file inclusions and external task definitions correctly, as well as parsing the EL syntax in properties and auto-completion of tags as you write. the auto-complete works in a similar way to Microsoft VS IntelliSense and gives you a pop-up list of possible methods, fields and so on whenever appropriate, as well as adding closing braces, parentheses and so on. good if you're forgetful, since you have less of the oh-damn-i-forgot-a-close-curly-brace-there-that's-why-it-won't-compile moments, after ten minutes of staring at the code...

subclipse



the next plug-in i use, and the main reason for switching from NetBeans to Eclipse, is subclipse, which is a subversion revision control tool. it integrates into the package/file navigator view, showing me which of my project files is under revision control (currently the src/, conf/ and web/ directories) and whether they are out of sync with the repository. i can also do diffs against the repository, tag and branch revisions easily and commit changes, all using the Team context menu. (see above re: the new mouse... ;) Subversion is a great RCS, but it took me a while to decide to use it. the first version control system i ever used was sccs, and i then moved to RCS because it was free. CVS is the next obvious step, it being a descendant of RCS, but i never got around to using it. i was looking for something to use with my current project, and had heard lots of good things about subversion, but the lack of integration with my IDE stopped me trying until my decision to switch. now, however, i'm finding it very simple and easy to use, and the setup for OS X was very simple. i have the server running from xinetd, rather than WEBDAV, with svn://localhost/ URLs for the repositories. i also use a tool called SvnX to browse svn repositories and manipulate the with an OS X GUI. i also tried using a Finder plug-in that gives a subversion context menu for each file under revision control, and integrates subversion with the Finder icons, but so far i've not found it that useful. i manipulate the working copy of my project just like i would normal files, and only commit and update using the UI inside Eclipse, since that's where the editing is going on. also, the command-line client gives me a much more powerful set of tools when i really need them.
(update the finder integration plugin is called SCPlugin)

one thing i haven't been using the Eclipse UI for is managing the application server or the database. i tend to view these components as infrastructure rather than part of my development environment, and usually control them using their native interfaces. i do have ant targets that allow me to deploy database schemas and upload web-app war files, but that's only as part of the deployment/build cycle. the app-server i'm using is Jakarta Tomcat 5.5.12. this version is usually built with the J2SE 5.0 runtime, but the version of OS X i have (10.3.9) doesn't have that available (although 10.4 does) so i'm stuck running 1.4.2 instead. fortunately, there's a compatibility package available that drops in on top of the Tomcat install to allow it to run on 1.4.2 Java environments. interestingly, the latest Tomcats all use the Eclipse Java incremental compiler, so only need a runtime not a full JDK deployment, although you can use javac or jikes if you want. to manage the Tomcat instance i just use the provided scripts, although i had to provide a SystemStarter directory and an option in the /etc/hostconfig file to get it to run on startup. i just copied the Apache scripts written by Apple.

database



the database i use is MySQL 5.0 with the InnoDB tables, since they provide better transaction and relational support. my persistence engine manages most of the actual data and schema definitions and updates (more later ...) but i also downloaded MySQL Administrator from the MySQL site to configure and monitor the database server itself. they provide a .dmg disk image for the OS X version of the 5.0 server, which installs in /usr/local/mysql and also adds a preference pane for automatic startup options. the actual OS X installer is a .pkg file and the whole experience is painless. i find a lot of companies don't give much thought to the OS X versions of their products, thinking "it's just BSD, isn't it?" so this is a welcome change.

well, that's all for today. later this week i'll talk a bit about the libraries and other packages i'm using to actually write the application...

No comments: