You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Andrew Robinson <an...@gmail.com> on 2011/03/31 23:53:28 UTC

Using maven-exec-plugin as a non-reusable plugin?

It is sometimes very convenient to have a java class with a main method used
to help build a maven project, but one that is so specific to that project
that it is too large of an overhead to author it as a reusable maven plugin.

Using maven-exec-plugin, the class can be run, but then the question becomes
who will compile it? Since the class is only used by the build, it should
not be included in the produced artifact (jar, war, etc), but the
maven-compiler-plugin is not written to taken configured source and
destination directories, only to use project-wide directories.

Is there a better solution than to just filter the classes out of the built
artifact, or another way to build code to be used like a plugin, but without
the full need to support the plugin as a reusable tool?

Re: Using maven-exec-plugin as a non-reusable plugin?

Posted by Anders Hammar <an...@hammar.net>.
You could always put it in a separate Maven project and declare a dependency
to that artifact for the exec plugin. But then it might be better to create
a Maven plugin instead...
If it's something simple, why not just write a Groovy script and use the
gmaven-plugin to execute it? You'll then keep it separate from your Java
code, which is what you want.

/Anders

On Thu, Mar 31, 2011 at 23:53, Andrew Robinson <andrew.rw.robinson@gmail.com
> wrote:

> It is sometimes very convenient to have a java class with a main method
> used
> to help build a maven project, but one that is so specific to that project
> that it is too large of an overhead to author it as a reusable maven
> plugin.
>
> Using maven-exec-plugin, the class can be run, but then the question
> becomes
> who will compile it? Since the class is only used by the build, it should
> not be included in the produced artifact (jar, war, etc), but the
> maven-compiler-plugin is not written to taken configured source and
> destination directories, only to use project-wide directories.
>
> Is there a better solution than to just filter the classes out of the built
> artifact, or another way to build code to be used like a plugin, but
> without
> the full need to support the plugin as a reusable tool?
>