You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by matthewadams <ma...@yahoo.com> on 2007/01/17 19:32:26 UTC

How do I programatically add an element to my plugin's classpath?

My mojo allows the user to define an extra property ("private File
licenseFileDirectory"), which is a directory, that I'd like to add to the
classpath when my mojo runs so that I can find a resource (a license file)
in the given directory.

How can I programatically add this to the classpath in my mojo?  Is there
some best practice for this?

Thanks,
Matthew
-- 
View this message in context: http://www.nabble.com/How-do-I-programatically-add-an-element-to-my-plugin%27s-classpath--tf3029052s177.html#a8416113
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: How do I programatically add an element to my plugin's classpath?

Posted by allan ramirez <aq...@gmail.com>.
right, or you can do it on another method that will be called by the
execute(). What matters most is the MavenProject instance you can get
it by

public class MyMojo
{
    /**
     * @parameter expression="${project}"
     */
    private MavenProject project;
}

On 1/18/07, matthewadams <ma...@yahoo.com> wrote:
>
> Just to be clear, I do this in my mojo's execute() method, right?
>
>
> allan ramirez wrote:
> >
> > try this
> >
> > List classpathElements = project.getCompileClasspathElements();
> > classpathElements.add( your directory );
> >
> > where your project is MavenProject
> >
> > Regards
> > -allan
> >
> >
> > On 1/18/07, matthewadams <ma...@yahoo.com> wrote:
> >>
> >> My mojo allows the user to define an extra property ("private File
> >> licenseFileDirectory"), which is a directory, that I'd like to add to the
> >> classpath when my mojo runs so that I can find a resource (a license
> >> file)
> >> in the given directory.
> >>
> >> How can I programatically add this to the classpath in my mojo?  Is there
> >> some best practice for this?
> >>
> >> Thanks,
> >> Matthew
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/How-do-I-programatically-add-an-element-to-my-plugin%27s-classpath--tf3029052s177.html#a8416113
> >> Sent from the Maven - Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> >
> > --
> > ==========================================================
> > - alramirez
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-do-I-programatically-add-an-element-to-my-plugin%27s-classpath--tf3029052s177.html#a8425308
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
==========================================================
- alramirez

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


Re: How do I programatically add an element to my plugin's classpath?

Posted by matthewadams <ma...@yahoo.com>.
Just to be clear, I do this in my mojo's execute() method, right?


allan ramirez wrote:
> 
> try this
> 
> List classpathElements = project.getCompileClasspathElements();
> classpathElements.add( your directory );
> 
> where your project is MavenProject
> 
> Regards
> -allan
> 
> 
> On 1/18/07, matthewadams <ma...@yahoo.com> wrote:
>>
>> My mojo allows the user to define an extra property ("private File
>> licenseFileDirectory"), which is a directory, that I'd like to add to the
>> classpath when my mojo runs so that I can find a resource (a license
>> file)
>> in the given directory.
>>
>> How can I programatically add this to the classpath in my mojo?  Is there
>> some best practice for this?
>>
>> Thanks,
>> Matthew
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-I-programatically-add-an-element-to-my-plugin%27s-classpath--tf3029052s177.html#a8416113
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 
> -- 
> ==========================================================
> - alramirez
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-I-programatically-add-an-element-to-my-plugin%27s-classpath--tf3029052s177.html#a8425308
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: How do I programatically add an element to my plugin's classpath?

Posted by allan ramirez <aq...@gmail.com>.
try this

List classpathElements = project.getCompileClasspathElements();
classpathElements.add( your directory );

where your project is MavenProject

Regards
-allan


On 1/18/07, matthewadams <ma...@yahoo.com> wrote:
>
> My mojo allows the user to define an extra property ("private File
> licenseFileDirectory"), which is a directory, that I'd like to add to the
> classpath when my mojo runs so that I can find a resource (a license file)
> in the given directory.
>
> How can I programatically add this to the classpath in my mojo?  Is there
> some best practice for this?
>
> Thanks,
> Matthew
> --
> View this message in context:
> http://www.nabble.com/How-do-I-programatically-add-an-element-to-my-plugin%27s-classpath--tf3029052s177.html#a8416113
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
==========================================================
- alramirez

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