Sharing Ant Targets Across NetBeans IDE Projects

Some targets are not project-specific, but IDE-generic. For example, the target created in the previous entry gives one-click access to the tomcat-users.xml file from the IDE. This file shouldn't only be available from a specific project. I shouldn't have to cut and paste the target into each project's build script (neither should I have to run the target in one build script while working in another). So I've created a separate build script where I'll store all targets that are useful for all projects. Now, all I need to do is add the following line to one or more project's build scripts:
<import file="path-to-build-file/ide-generic-targets.xml"/>
Then, when I build the project, the targets from the IDE-generic build script are imported into the project's project-specific build script. It also means that when I delete a project, I won't be deleting a target that other projects (now or in the future) might find useful. I guess this solution is pretty obvious, but it took me a while to think of it...

NB: Maybe an even better solution is to create a web free-form project with a build script containing all the IDE-generic targets. That project could then have all these targets mapped to project commands, with shortcuts like buttons and menu items for actions such as opening external applications that are useful for all projects. Yup. That works. And is a much better solution:


Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« May 2015