Plugin unnecessarily requires target/classes directory

3 views
Skip to first unread message

Michael Hackett

unread,
Mar 10, 2009, 10:18:34 PM3/10/09
to pyx4me-users
I just split my J2ME project into separate modules, and would like to
have the final MIDlet built by a module that has no other source code.
The actual code for the MIDlet is brought in through dependencies on
other modules. (Not sure if this is the best solution, but it seemed
reasonable given the way I understand Maven to work. I'm open to
suggestions, though.)

Anyway, the problem is that the maven-j2me-plugin fails with an error
if the target/classes directory is not present. And since there are no
Java source files, this directory is not created. (And I don't know of
any way to force its creation in Maven, except to make a dummy
resource or source file and get that copied in during the resource or
compile phase.)

I've looked at the source for maven-j2me-plugin and it looks like it
would be an easy fix to make this non-fatal. There doesn't seem to be
any reason that it absolutely needs to add this directory. The code
could first check that it exists, or ignore the failure and continue
on. I can't think of any reason this would break anything.

The code that I think would need to be changed is in
com.pyx4me.maven.j2me.PackageMojo.java, performJarPackaging(), where
it says "// Add classes to Package". I hope that's enough info to make
it an easy change. What do you think? Any issues with this?

Vlad Skarzhevskyy

unread,
Mar 11, 2009, 1:03:37 AM3/11/09
to pyx4me...@googlegroups.com
So other modules are just regular jar? and this last module does preverification using ProGuard and jaring all together?

The change is made in svn, the 2.0.4-SNAPSHOT plugin should be updated in snapshot repository in hour or so.

Vlad

Michael Hackett

unread,
Mar 11, 2009, 11:59:01 AM3/11/09
to pyx4me...@googlegroups.com
Vlad Skarzhevskyy wrote:
> So other modules are just regular jar? and this last module does
> preverification using ProGuard and jaring all together?

Yes, that's exactly right, Vlad.

> The change is made in svn, the 2.0.4-SNAPSHOT plugin should be updated in
> snapshot repository in hour or so.
>
> Vlad

Thanks! I'll give it a try shortly.

-- Michael

Michael Hackett

unread,
Mar 12, 2009, 4:42:56 PM3/12/09
to pyx4me...@googlegroups.com
Michael Hackett wrote:

> Vlad Skarzhevskyy wrote:
>> The change is made in svn, the 2.0.4-SNAPSHOT plugin should be updated in
>> snapshot repository in hour or so.
>>
>> Vlad
>
> Thanks! I'll give it a try shortly.
>
> -- Michael

Yep, that did the trick!

The only thing I would suggest is to reduce the scope of the "if
(classesDirectory.exists())" condition to just the two lines relating to
classesDirectory. While it may seem unlikely, it would be possible to
have a module with only test code (in fact, I have done that) so
conceivably someone might want to include just the testOutputDirectory,
but not have a classesDirectory. I don't think it will do any harm to
shrink the scope of the condition, but it's your call, obviously. What
you have done works for me.

Thanks again, and thanks for the very fast response!

Cheers,
-- Michael

Vlad Skarzhevskyy

unread,
Mar 12, 2009, 4:55:30 PM3/12/09
to pyx4me...@googlegroups.com
Done as you asked.

--
Vlad

Reply all
Reply to author
Forward
0 new messages