On Mon, 17 Jul 2006, Alexander Rau wrote:

> Yeah, in principle you are absolutely right. However I just need to
> execute the main method of a specific class without any additional
> arguments. That's a pretty generic functionality and the exec plugin
> proposed by Tim Kettler does the job.

Ah ok.. still, the main() method is really just one way of executing that
code - there's no reason why you couldn't call that from a plugin..


> I tried to write my own plugin and so far it could work if there wasn't
> a classpath problem. My custom class is not on the classpath of my
> plugin. Nothing of the project (which uses the custom plugin) is visible
> on the classpath (from the plugins point of view). Just curious: do I
> need to write some custom ClassLoader or should that work out of the box ?
>

You should create a new classloader, yes. You can just use the
URLClassLoader and add the mavenProject.getRuntimeClasspathElements() and
add those.

Not all (read: most) plugins don't need the classpath to be filled with
the dependencies. Only the unit test and compiler plugins, actually. The
rest just operates on the sources/resources/class files themselves,
or operate on the dependency files themselves. That's why it doesn work
'out of the box'.

But since this is such a popular request, there will probably be a utility
method somewhere that constructs your classloader for you, in the near
future.

-- Kenney

> Tnx and regards,
>
> Alex
>
>
>
> Kenney Westerhof wrote:
> > On Sat, 15 Jul 2006, Tim Kettler wrote:
> >
> > Hi,
> >
> > This is exactly what plugins are for. I suggest you write a small
> > plugin - a simple Mojo that calls your custom java code should do the
> > trick.
> >
> > See http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
> >
> >
> > -- Kenney
> >
> >> Hi,
> >>
> >> perhaps the exec-maven-plugin [1] is what you want?
> >>
> >> -Tim
> >>
> >> [1] http://mojo.codehaus.org/exec-maven-plugin/
> >>
> >> Alexander Rau schrieb:
> >>> Hi all,
> >>>
> >>> I need to run a custom java class for generating some stubs. How can I
> >>> integrate something like that into a pom.xml ? This should be similar to
> >>> the antrun plugin except that it's java code I want to execute.
> >>>
> >>> I've seen that it could be possible by using antrun itself, however a
> >>> more cleaner way would be nice.
> >>>
> >>> Tnx in advance
> >>>
> >>>
> >>> Alex
> >>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to