If I have the test path set on POM but if the file does
not exist (that situation can happens, for instance,
when your POM extends another), then emma:report fails:
BUILD FAILED
File......
/home/cb50e4in/.maven/cache/maven-emma-plugin-0.7-snapshot-cpqd-2/plugin.jelly
Element... ant:path
Line...... 348
Column.... 55
Reference maven.test.compile.src.set not found.
Total time: 6 seconds
Finished at: Thu Nov 24 19:16:16 BRST 2005
The fix is simple, it's just a matter of putting a
<c:if> inside the call to <ant:sourcepath>
<ant:sourcepath>
<ant:path refid="maven.compile.src.set"/>
<j:if
test="${context.getVariable('maven.emma.instrument.tests')
== 'true'}">
<ant:path refid="maven.test.compile.src.set"/>
</j:if>
</ant:sourcepath>
I will try to create a test case for this situation
tomorrow and then submit a patch.
-- Felipe
Logged In: YES
user_id=129356
Hmm, I tried to create a simple test case, but it's a little
bit complicated, as it would require running emma without
the test:test task setting the maven.test.compile.src.set
path id - one possible way (which is how I ran into the
problem) is using cactus, but that would require setting a
server to run the tests.
Also, it might be safer to check if the path exists instead
of checking the value of the property. Ideally, we should use:
<ant:available classpathref="maven.test.compile.src.set"
property="hasSrcSet"/>
<j:if test="${hasSrcSet}">
<ant:path refid="maven.test.compile.src.set"/>
</j:if>
The problem is that <ant:path> with the refid attribute is
not available on the version of Ant that maven 1.0.x uses.
So, another option would be to check if the directory exists:
<u:available file="${pom.build.unitTestSourceDirectory}">
<ant:path refid="maven.test.compile.src.set"/>
</u:available>
Logged In: YES
user_id=447346
Felipe,
Ok. I've been meaning to make some time to apply patches to
the plugin, I think there's one other issue pending.
If you create a patch that fixes this for you and doesn't
break the existing tests, then I'll apply it. You don't
have to worry about writing a test if it's too hard.
Thanks,
Chad
Logged In: YES
user_id=129356
Hi Chad,
Yes, I had submitted patches for 1329784 (with a test case
included).
Regarding this one, I will provide a new cumulative patch
then. My only concern is that this fix is not enough, as the
maven.test.compile.src.test can be manipulated. I mean, the
patch checks for the directory set on the POM, but
eventually a plugin or a custom maven.xml could have changed
the value. Anyway, this fix should be enough for most of the
cases...
-- Felipe
Logged In: YES
user_id=447346
Yes, that seems to be a basic problem of maven. Someone
could always hack the magic properties and break your
plugin. I wonder if Maven2 addresses this at all.
Unfortunately, I'm not using maven on my current project
right now so I don't have much time to play with it anymore.
Logged In: YES
user_id=129356
Chad,
I'm providing a patch with the proposed fix - I think it
would cover most of the cases, except when the
compile.src.set reference is redefined and the new directory
does not exist (I guess this is a rare case; anyway, nothing
can be done using Maven 1.0.x/Ant 1.5.x in this case).
This patch also includes the fix (and testcases) for 1336607.
-- Felipe
Logged In: YES
user_id=447346
Thanks a lot for your help Felipe. I'm leaving for vacation
in 2 days, so I may not get it applied this week, but this
is on my todo list. Also, thanks for rolling in the other
patch, that will help make things easier.
-- Chad
Logged In: YES
user_id=129356
Fixed (on CVS).
Logged In: YES
user_id=129356
Marking as Open -> Fixed (waiting for a new release...)