Tell me if I understand well :

your code-generator has been packaged as a Mojo and is used in another
project. It loads some config file from classpath to generate code.

Maven plugins run in isolated classloaders, they have no acces to the
current project classpath.

First option (the maven way) is to rework the code generator to use a
parametrized folder to load config files used in generation. You then just
have to set a new @parameter in the Mojo.

Second option - if changing the legacy code is too complex - is to setup a
new URLClassloader with the plugin classloader as parent and add the project
resources folder. You can the load the generator class using this
classloader and invoke the "generate()" method by reflexion.

Nico.





2007/12/8, Kallin Nagelberg <[EMAIL PROTECTED]>:
>
> I'm trying to convert the source-generation of a legacy system into a
> mavenized project. Basically I need to run a couple of java classes from
> an
> already existing dependency (during the generate-sources phase I assume)
> which should populate my source directories. The problem I'm having is
> that
> it seems maven is ignoring my <resource> declarations during the
> generate-sources phase. Is this normal? To run the two java classes
> requried
> for source generation I'm using the exec-maven-plugin and it definitely
> doesn't find my declared resources on it's classpath..
>
> I've managed to find some hacks around this, like telling the
> maven-resources-plugin to execute the 'resources' goal during
> generate-sources, but that doesn't seem so clean to me, as it's probably
> going to do it again during the generate-resources phase..
>
> Any ideas?
>

Reply via email to