The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ragill (2) [Avatar] Offline
#1
I'm trying to use the xdoclet plugin for Maven to generate mock objects and haven't had any success. I've tagged my interfaces with @mock.generate, installed the xdoclet plugin and placed the xdoclet-mockobjects-module in my local repository. I've also set my dependancies in my POM to include the xdoclet jars. The documentation on the xdoclet site is very sketchy about what if any properties need to be set, so I've dug into the the plugin.jelly file and added the following to my build.properties file:

################# XDoclet #################
maven.xdoclet.mockobjectdoclet.destDir=${basedir}/src/mock
#maven.xdoclet.mockobjectdoclet.mergeDir=
#maven.xdoclet.mockobjectdoclet.force=true
maven.xdoclet.mockobjectdoclet.verbose=true
maven.xdoclet.mockobjectdoclet.addedTags=false
maven.xdoclet.mockobjectdoclet.fileset.0=${basedir}/src/java
maven.xdoclet.mockobjectdoclet.fileset.0.include=**/*.java

I've also difined the following goal in my maven.xml file:
<goal name="MockObjects">
<attainGoal name="xdoclet:mockobjectdoclet" />
</goal>

I've also tried making the xdoclet:mockobjectdoclet goal a pregoal for java:compile without any success.

When I run Maven, the goal is run but there is no output. When I run a similar ant build file (using the jars in the maven repository for my xdoclet.lib.path), the mock objects are created.

Any ideas? Do you know where there is any documentation on the xdoclet plugin for maven? (other then the brief intro on the xdoclet site)

Thank you for looking into this problem.
habuma (279) [Avatar] Offline
#2
Re: Maven and MockObjects
I can't try this myself right now (for various reasons), but I thought I'd go ahead and give you a few quick answers that may help.

Try adding this line to your properties file:

maven.xdoclet.mockobjectdoclet.mockobjects.0=true

I think your problem (or at least part of your problem) is that you are successfully executing the <mockobjectdoclet> task, but because the line above is missing, you aren't executing any subtasks. In other words, <mockobjectdoclet> starts up, has nothing to do, then shuts down. The line above effectively adds the <mockobjects> subtask to the mix.

If this doesn't work, try running maven with the -X parameter to see if there are any useful log messages.
ragill (2) [Avatar] Offline
#3
Re: Maven and MockObjects
Thanks for the tip!

It's still not working correctly (I'm getting a double reference to the classes - see below), but at least it's trying.

I'll take a deeper look at the problem tomorrow using the -X option.

INFO: Some classes refer to other classes that were not found among the sources or on the classpath.
(Perhaps the referred class doesn't exist? Hasn't been generated yet?)
The referring classes do not import any fully qualified classes matching these classes.
However, since no packages are imported, xjavadoc has assumed that the referred classes
belong to the same package as the referring class. The classes are:
Csmilierogram FileseclipseworkspacecamodsrcjavamildticcamodcronutilCronMail.java --> CAModMail qualified to mil.dtic.camod.cron.util.CAModMail
Csmilierogram FileseclipseworkspacecamodsrcjavamildticcamodcronutilOracleDAO.java --> CAModCronDAO qualified to mil.dtic.camod.cron.util.CAModCronDAO
Csmilierogram FileseclipseworkspacecamodsrcjavamildticcamodcronutilCronMail.java --> CAModMail qualified to mil.dtic.camod.cron.util.CAModMail
Csmilierogram FileseclipseworkspacecamodsrcjavamildticcamodcronutilOracleDAO.java --> CAModCronDAO qualified to mil.dtic.camod.cron.util.CAModCronDAO