Netbeans, Ant and XDoclet
Today, I played around with getting NetBeans 4.0 Beta 2, Ant 1.6.2 and XDoclet 1.2.2 to talk together and play nice. (NB 4.2b2 comes w/Ant 1.6.2 built in; XDoclet is separate.) The goal was to get JBoss into the mix as well, but that'll probably have to wait until tomorrow.
I created a simple project (Hello, from the Mastering EJB 2.0 book). NB shows the build.xml file under the Files tab (and not on the Project tab, where I was first looking for it). build.xml expands to show all targets; most of the targets live under nbproject/build-impl.xml, and several are empty and can be overridden in build.xml. (The overridables are listed in a comment.)
For background, Ant build files set up chains of dependent targets. NB's default is
So I added various tags to my simple bean file. At the class level, I added an
In build.xml, I added an
I'm pretty sure there's a better way to list my source files. I tried
Then I troubleshot it. First off, it couldn't find the
I was also getting empty bean interfaces. Seems I forgot to put the @ejb.interface-method on the method, but adding the tag fixed that.
One thing made it slightly harder than it should have been. I had intended to start out with a very simple stateless session bean, and mimic xdoclet's sample. It turns out that xdoclet's sample stateless session bean was a sample of how *NOT* to let xdoclet generate the interfaces for you. Bad choice on my part. Ah well.
I created a simple project (Hello, from the Mastering EJB 2.0 book). NB shows the build.xml file under the Files tab (and not on the Project tab, where I was first looking for it). build.xml expands to show all targets; most of the targets live under nbproject/build-impl.xml, and several are empty and can be overridden in build.xml. (The overridables are listed in a comment.)
For background, Ant build files set up chains of dependent targets. NB's default is
default
, which depends on dist
and javadoc
. dist
in turn depends on init
, compile
, pre-dist
, do-dist
and post-dist
, which it most likely runs in that order; each of these depend on others, and so on.
So I added various tags to my simple bean file. At the class level, I added an
@ejb.bean
tag, with name and type attrs. jndi-name and local-jndi-name attrs also look useful. I also added an @ejb.interface-method
tag to my one business method.
In build.xml, I added an
ejbdoclet
target, with an embedded task of the same name, depending on init
. The destdir
attr looked most useful, and I added an excludedtags
and verbose
attr as well. I then added remoteinterface
, localinterface
, homeinterface
and localhomeinterface
elements (all empty), and a fileset
that listed my one source file, explicitly.
I'm pretty sure there's a better way to list my source files. I tried
**/*.java
, but with my destdir putting the generated files into my source dir (which may be a problem), compiling a 2nd time gives me interfaces for my interfaces, which is wrong. So for the moment, I'm listing each file separately, and will be looking for a better way. Like having a "generated" directory that's separate, or something. Suggestions welcome.
Then I troubleshot it. First off, it couldn't find the
ejbdoclet
task. Played around with the compile classpath, to no avail. Found that I could add an Ant classpath
element under the taskdef, but that felt unwieldy, especially as I had 5-6 jars eventually to add. Was about to separate it out as an Ant typedef, then thought that since Ant is a proper part of NB, there should be a config option. There was, under Tools/Options, Building, Ant Settings, Additional Classpath. Added several files there (xdoclet, xdoclet-ejb-module, xjavadoc, commons-logging and -collections, and jboss-j2ee.jar), and life was good.
I was also getting empty bean interfaces. Seems I forgot to put the @ejb.interface-method on the method, but adding the tag fixed that.
One thing made it slightly harder than it should have been. I had intended to start out with a very simple stateless session bean, and mimic xdoclet's sample. It turns out that xdoclet's sample stateless session bean was a sample of how *NOT* to let xdoclet generate the interfaces for you. Bad choice on my part. Ah well.
0 Comments:
Post a Comment
<< Home