You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Arnaud WEBER <aw...@excilys.com> on 2007/12/12 12:31:49 UTC

Mojo accessing to rootDirectory

Hello,

I'm actually developping a little plugin and i need to access to the 
root directory of my project as a File or as a String.

i've seen there is a Map called pluginContext in the AbstractMojo Class 
and I guess it should be in. Is it inside? with which key? isn't there a 
more elegant way to find the project root directory?

Thanks
Arnaud

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Mojo accessing to rootDirectory

Posted by Stuart McCulloch <st...@jayway.net>.
On 12/12/2007, Arnaud WEBER <aw...@excilys.com> wrote:
>
> Hello,
>
> I'm actually developping a little plugin and i need to access to the
> root directory of my project as a File or as a String.
>
> i've seen there is a Map called pluginContext in the AbstractMojo Class
> and I guess it should be in. Is it inside?


I don't believe so

with which key? isn't there a
> more elegant way to find the project root directory?


the 'project root directory' is a vague concept, as I could check-out a
portion
of a Maven project, and as long as the modules depend on released parent
poms it will still build - in this scenario which is the root: the logical
top-level
parent which doesn't exist in my filesystem, or the top of the fragment that
I checked out?

looking for projects with null parents, using project.getParent() to
traverse
the project hierarchy, or even using getBasedir() and java.io.File to look
for
the top-level pom.xml will provide some answer, but may not be what you
really need...

it's often better to step back and ask: why do I need to know the root
folder?

if it's because you need some resources relative to it, then why not bundle
them up as another jar and use a dependency? - ie. let Maven do the work!

HTH

Thanks
> Arnaud
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Cheers, Stuart