You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Brett Porter <br...@gmail.com> on 2008/09/01 02:25:44 UTC

Re: Override localRepository at plugin execution using another local repository plexus component implementation

You're on the right track, but there's a few problems here.
Firstly, I'm a bit confused as you have artifactFactory, but refer to local
repository. This is important - if the plugin is using a factory to create a
repository then you can replace the factory, but if it's using
${settings.localRepository} you'll have to override that in a different way.

As for replacing an implementation, the method you've given is not quite
correct. You actually need something like:

<configuration>
  <factory implementation="com.foo.bar.MyArtifactFactory" />
</configuration>

A good example of this is the shade plugin, which does so for it's
transformers.

But if @component is used, or @readonly - this may not work anyway.

For the specific use case you are talking about, replacement components
shouldn't be needed, it just sounds like you want to modify the local
repository. That seems like a feature request to make of the dependency
plugin.

Cheers,
Brett

2008/9/1 Dan Tran <da...@gmail.com>

> Currently,  a typical localRepository configuration is declared like
> this in the mojo.
>
>   /**
>     * Used to look up Artifacts in the remote repository.
>     *
>     * @parameter
> expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
>     * @required
>     * @readonly
>     */
>    protected org.apache.maven.artifact.factory.ArtifactFactory factory;
>
>
> This means, I can create my own local repository plexus component
> implementation, declare it as a dependency in my pom in the plugin's
> dependency list, and pass it in as a execution configuration like
>
>  <execution>
>    <configuration>
>       <local>myExecutionLocalRepository</local>
>    </configuration?
>  </execution>
>  </executions>
>  <dependencies>
>    my implementation goes here
>  </dependencies>
>
> Where myExecutionLocalRepository is the plexus component name, known as
> "hint"
>
> Is the right approach?
>
> The motivation behind this is that I have a need to use dependency
> plugin to copy and unpack some very large artifacts and I dont want
> it to pollute my global local repository especially when using
> snapshot artifacts.  myExecutionLocalRepository is located under
> target directory so that It can be cleanup via maven clean.
>
> Advice is greatly appreciated.
>
> Thanks
>
> -D
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Brett Porter
Blog: http://blogs.exist.com/bporter/

Re: Override localRepository at plugin execution using another local repository plexus component implementation

Posted by Dan Tran <da...@gmail.com>.
Thanks Brett, will file an enhance request against dependency plugin

-D

On Mon, Sep 1, 2008 at 12:34 AM, Brett Porter <br...@gmail.com> wrote:
> You can't configure an artifact repository easily from the plugin
> configuration, so the likely change is to make a feature request to have
> something like:
> /** @parameter */
> private String alternateLocalRepository;
>
> This would be used instead of localRepository when specified.
>
> Cheers,
> Brett
>
> 2008/9/1 Dan Tran <da...@gmail.com>
>
>> On Sun, Aug 31, 2008 at 5:48 PM, Dan Tran <da...@gmail.com> wrote:
>> > Oops, I pasted the wrong declaration, it should be
>> >
>> >    /**
>> >     * Location of the local repository.
>> >     *
>> >     * @parameter expression="${localRepository}"
>> >     * @readonly
>> >     * @required
>> >     */
>> >    protected org.apache.maven.artifact.repository.ArtifactRepository
>> local;
>> >
>> > Looks like the expression=${localRepository} is the implicit
>> > ${settings.localRepository}
>> >
>> > Is there a way to pass in   my own localRepository instead of using
>> > the implicit settings.localRepository.  This way, there is no need to
>> > enhance the plugin.
>>
>> Of course, we still need to remove @readonly which is a minimal change
>> in the plugin
>>
>>
>> >
>> > If we need to enhance dependency plugin to allow override of its
>> > "local" configuration,
>> > how is it going to be?  Perhaps, we can add an additional
>> > configuration like localRepositoryPath( String) and create a new
>> > DefaultArtifactRepository if it is not null to replace the declared
>> > "local" at execution time?
>> >
>> >
>> > Thanks
>> >
>> > -Dan
>> >
>> > On Sun, Aug 31, 2008 at 5:25 PM, Brett Porter <br...@gmail.com>
>> wrote:
>> >> You're on the right track, but there's a few problems here.
>> >> Firstly, I'm a bit confused as you have artifactFactory, but refer to
>> local
>> >> repository. This is important - if the plugin is using a factory to
>> create a
>> >> repository then you can replace the factory, but if it's using
>> >> ${settings.localRepository} you'll have to override that in a different
>> way.
>> >>
>> >> As for replacing an implementation, the method you've given is not quite
>> >> correct. You actually need something like:
>> >>
>> >> <configuration>
>> >>  <factory implementation="com.foo.bar.MyArtifactFactory" />
>> >> </configuration>
>> >>
>> >> A good example of this is the shade plugin, which does so for it's
>> >> transformers.
>> >>
>> >> But if @component is used, or @readonly - this may not work anyway.
>> >>
>> >> For the specific use case you are talking about, replacement components
>> >> shouldn't be needed, it just sounds like you want to modify the local
>> >> repository. That seems like a feature request to make of the dependency
>> >> plugin.
>> >>
>> >> Cheers,
>> >> Brett
>> >>
>> >> 2008/9/1 Dan Tran <da...@gmail.com>
>> >>
>> >>> Currently,  a typical localRepository configuration is declared like
>> >>> this in the mojo.
>> >>>
>> >>>   /**
>> >>>     * Used to look up Artifacts in the remote repository.
>> >>>     *
>> >>>     * @parameter
>> >>>
>> expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
>> >>>     * @required
>> >>>     * @readonly
>> >>>     */
>> >>>    protected org.apache.maven.artifact.factory.ArtifactFactory factory;
>> >>>
>> >>>
>> >>> This means, I can create my own local repository plexus component
>> >>> implementation, declare it as a dependency in my pom in the plugin's
>> >>> dependency list, and pass it in as a execution configuration like
>> >>>
>> >>>  <execution>
>> >>>    <configuration>
>> >>>       <local>myExecutionLocalRepository</local>
>> >>>    </configuration?
>> >>>  </execution>
>> >>>  </executions>
>> >>>  <dependencies>
>> >>>    my implementation goes here
>> >>>  </dependencies>
>> >>>
>> >>> Where myExecutionLocalRepository is the plexus component name, known as
>> >>> "hint"
>> >>>
>> >>> Is the right approach?
>> >>>
>> >>> The motivation behind this is that I have a need to use dependency
>> >>> plugin to copy and unpack some very large artifacts and I dont want
>> >>> it to pollute my global local repository especially when using
>> >>> snapshot artifacts.  myExecutionLocalRepository is located under
>> >>> target directory so that It can be cleanup via maven clean.
>> >>>
>> >>> Advice is greatly appreciated.
>> >>>
>> >>> Thanks
>> >>>
>> >>> -D
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >>> For additional commands, e-mail: users-help@maven.apache.org
>> >>>
>> >>>
>> >>
>> >>
>> >> --
>> >> Brett Porter
>> >> Blog: http://blogs.exist.com/bporter/
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
> --
> Brett Porter
> Blog: http://blogs.exist.com/bporter/
>

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


Re: Override localRepository at plugin execution using another local repository plexus component implementation

Posted by Brett Porter <br...@gmail.com>.
You can't configure an artifact repository easily from the plugin
configuration, so the likely change is to make a feature request to have
something like:
/** @parameter */
private String alternateLocalRepository;

This would be used instead of localRepository when specified.

Cheers,
Brett

2008/9/1 Dan Tran <da...@gmail.com>

> On Sun, Aug 31, 2008 at 5:48 PM, Dan Tran <da...@gmail.com> wrote:
> > Oops, I pasted the wrong declaration, it should be
> >
> >    /**
> >     * Location of the local repository.
> >     *
> >     * @parameter expression="${localRepository}"
> >     * @readonly
> >     * @required
> >     */
> >    protected org.apache.maven.artifact.repository.ArtifactRepository
> local;
> >
> > Looks like the expression=${localRepository} is the implicit
> > ${settings.localRepository}
> >
> > Is there a way to pass in   my own localRepository instead of using
> > the implicit settings.localRepository.  This way, there is no need to
> > enhance the plugin.
>
> Of course, we still need to remove @readonly which is a minimal change
> in the plugin
>
>
> >
> > If we need to enhance dependency plugin to allow override of its
> > "local" configuration,
> > how is it going to be?  Perhaps, we can add an additional
> > configuration like localRepositoryPath( String) and create a new
> > DefaultArtifactRepository if it is not null to replace the declared
> > "local" at execution time?
> >
> >
> > Thanks
> >
> > -Dan
> >
> > On Sun, Aug 31, 2008 at 5:25 PM, Brett Porter <br...@gmail.com>
> wrote:
> >> You're on the right track, but there's a few problems here.
> >> Firstly, I'm a bit confused as you have artifactFactory, but refer to
> local
> >> repository. This is important - if the plugin is using a factory to
> create a
> >> repository then you can replace the factory, but if it's using
> >> ${settings.localRepository} you'll have to override that in a different
> way.
> >>
> >> As for replacing an implementation, the method you've given is not quite
> >> correct. You actually need something like:
> >>
> >> <configuration>
> >>  <factory implementation="com.foo.bar.MyArtifactFactory" />
> >> </configuration>
> >>
> >> A good example of this is the shade plugin, which does so for it's
> >> transformers.
> >>
> >> But if @component is used, or @readonly - this may not work anyway.
> >>
> >> For the specific use case you are talking about, replacement components
> >> shouldn't be needed, it just sounds like you want to modify the local
> >> repository. That seems like a feature request to make of the dependency
> >> plugin.
> >>
> >> Cheers,
> >> Brett
> >>
> >> 2008/9/1 Dan Tran <da...@gmail.com>
> >>
> >>> Currently,  a typical localRepository configuration is declared like
> >>> this in the mojo.
> >>>
> >>>   /**
> >>>     * Used to look up Artifacts in the remote repository.
> >>>     *
> >>>     * @parameter
> >>>
> expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
> >>>     * @required
> >>>     * @readonly
> >>>     */
> >>>    protected org.apache.maven.artifact.factory.ArtifactFactory factory;
> >>>
> >>>
> >>> This means, I can create my own local repository plexus component
> >>> implementation, declare it as a dependency in my pom in the plugin's
> >>> dependency list, and pass it in as a execution configuration like
> >>>
> >>>  <execution>
> >>>    <configuration>
> >>>       <local>myExecutionLocalRepository</local>
> >>>    </configuration?
> >>>  </execution>
> >>>  </executions>
> >>>  <dependencies>
> >>>    my implementation goes here
> >>>  </dependencies>
> >>>
> >>> Where myExecutionLocalRepository is the plexus component name, known as
> >>> "hint"
> >>>
> >>> Is the right approach?
> >>>
> >>> The motivation behind this is that I have a need to use dependency
> >>> plugin to copy and unpack some very large artifacts and I dont want
> >>> it to pollute my global local repository especially when using
> >>> snapshot artifacts.  myExecutionLocalRepository is located under
> >>> target directory so that It can be cleanup via maven clean.
> >>>
> >>> Advice is greatly appreciated.
> >>>
> >>> Thanks
> >>>
> >>> -D
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>> For additional commands, e-mail: users-help@maven.apache.org
> >>>
> >>>
> >>
> >>
> >> --
> >> Brett Porter
> >> Blog: http://blogs.exist.com/bporter/
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Brett Porter
Blog: http://blogs.exist.com/bporter/

Re: Override localRepository at plugin execution using another local repository plexus component implementation

Posted by Dan Tran <da...@gmail.com>.
On Sun, Aug 31, 2008 at 5:48 PM, Dan Tran <da...@gmail.com> wrote:
> Oops, I pasted the wrong declaration, it should be
>
>    /**
>     * Location of the local repository.
>     *
>     * @parameter expression="${localRepository}"
>     * @readonly
>     * @required
>     */
>    protected org.apache.maven.artifact.repository.ArtifactRepository local;
>
> Looks like the expression=${localRepository} is the implicit
> ${settings.localRepository}
>
> Is there a way to pass in   my own localRepository instead of using
> the implicit settings.localRepository.  This way, there is no need to
> enhance the plugin.

Of course, we still need to remove @readonly which is a minimal change
in the plugin


>
> If we need to enhance dependency plugin to allow override of its
> "local" configuration,
> how is it going to be?  Perhaps, we can add an additional
> configuration like localRepositoryPath( String) and create a new
> DefaultArtifactRepository if it is not null to replace the declared
> "local" at execution time?
>
>
> Thanks
>
> -Dan
>
> On Sun, Aug 31, 2008 at 5:25 PM, Brett Porter <br...@gmail.com> wrote:
>> You're on the right track, but there's a few problems here.
>> Firstly, I'm a bit confused as you have artifactFactory, but refer to local
>> repository. This is important - if the plugin is using a factory to create a
>> repository then you can replace the factory, but if it's using
>> ${settings.localRepository} you'll have to override that in a different way.
>>
>> As for replacing an implementation, the method you've given is not quite
>> correct. You actually need something like:
>>
>> <configuration>
>>  <factory implementation="com.foo.bar.MyArtifactFactory" />
>> </configuration>
>>
>> A good example of this is the shade plugin, which does so for it's
>> transformers.
>>
>> But if @component is used, or @readonly - this may not work anyway.
>>
>> For the specific use case you are talking about, replacement components
>> shouldn't be needed, it just sounds like you want to modify the local
>> repository. That seems like a feature request to make of the dependency
>> plugin.
>>
>> Cheers,
>> Brett
>>
>> 2008/9/1 Dan Tran <da...@gmail.com>
>>
>>> Currently,  a typical localRepository configuration is declared like
>>> this in the mojo.
>>>
>>>   /**
>>>     * Used to look up Artifacts in the remote repository.
>>>     *
>>>     * @parameter
>>> expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
>>>     * @required
>>>     * @readonly
>>>     */
>>>    protected org.apache.maven.artifact.factory.ArtifactFactory factory;
>>>
>>>
>>> This means, I can create my own local repository plexus component
>>> implementation, declare it as a dependency in my pom in the plugin's
>>> dependency list, and pass it in as a execution configuration like
>>>
>>>  <execution>
>>>    <configuration>
>>>       <local>myExecutionLocalRepository</local>
>>>    </configuration?
>>>  </execution>
>>>  </executions>
>>>  <dependencies>
>>>    my implementation goes here
>>>  </dependencies>
>>>
>>> Where myExecutionLocalRepository is the plexus component name, known as
>>> "hint"
>>>
>>> Is the right approach?
>>>
>>> The motivation behind this is that I have a need to use dependency
>>> plugin to copy and unpack some very large artifacts and I dont want
>>> it to pollute my global local repository especially when using
>>> snapshot artifacts.  myExecutionLocalRepository is located under
>>> target directory so that It can be cleanup via maven clean.
>>>
>>> Advice is greatly appreciated.
>>>
>>> Thanks
>>>
>>> -D
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>
>>
>> --
>> Brett Porter
>> Blog: http://blogs.exist.com/bporter/
>>
>

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


Re: Override localRepository at plugin execution using another local repository plexus component implementation

Posted by Dan Tran <da...@gmail.com>.
Hi Wendy, that would not work since it switch to a new local repo for
the whole maven build lifecycle.  What I want is just to temporary
change it at a specific plugin's execution time.

Thanks

-D

On Sun, Aug 31, 2008 at 6:12 PM, Wendy Smoak <ws...@gmail.com> wrote:
> On Sun, Aug 31, 2008 at 5:48 PM, Dan Tran <da...@gmail.com> wrote:
>
>> Is there a way to pass in   my own localRepository instead of using
>> the implicit settings.localRepository.  This way, there is no need to
>> enhance the plugin.
>
> On the off chance this is less complicated than it looks... does
> -Dmaven.repo.local=/path/to/repo do what you want?
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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


Re: Override localRepository at plugin execution using another local repository plexus component implementation

Posted by Wendy Smoak <ws...@gmail.com>.
On Sun, Aug 31, 2008 at 5:48 PM, Dan Tran <da...@gmail.com> wrote:

> Is there a way to pass in   my own localRepository instead of using
> the implicit settings.localRepository.  This way, there is no need to
> enhance the plugin.

On the off chance this is less complicated than it looks... does
-Dmaven.repo.local=/path/to/repo do what you want?

-- 
Wendy

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


Re: Override localRepository at plugin execution using another local repository plexus component implementation

Posted by Dan Tran <da...@gmail.com>.
Oops, I pasted the wrong declaration, it should be

    /**
     * Location of the local repository.
     *
     * @parameter expression="${localRepository}"
     * @readonly
     * @required
     */
    protected org.apache.maven.artifact.repository.ArtifactRepository local;

Looks like the expression=${localRepository} is the implicit
${settings.localRepository}

Is there a way to pass in   my own localRepository instead of using
the implicit settings.localRepository.  This way, there is no need to
enhance the plugin.

If we need to enhance dependency plugin to allow override of its
"local" configuration,
how is it going to be?  Perhaps, we can add an additional
configuration like localRepositoryPath( String) and create a new
DefaultArtifactRepository if it is not null to replace the declared
"local" at execution time?


Thanks

-Dan

On Sun, Aug 31, 2008 at 5:25 PM, Brett Porter <br...@gmail.com> wrote:
> You're on the right track, but there's a few problems here.
> Firstly, I'm a bit confused as you have artifactFactory, but refer to local
> repository. This is important - if the plugin is using a factory to create a
> repository then you can replace the factory, but if it's using
> ${settings.localRepository} you'll have to override that in a different way.
>
> As for replacing an implementation, the method you've given is not quite
> correct. You actually need something like:
>
> <configuration>
>  <factory implementation="com.foo.bar.MyArtifactFactory" />
> </configuration>
>
> A good example of this is the shade plugin, which does so for it's
> transformers.
>
> But if @component is used, or @readonly - this may not work anyway.
>
> For the specific use case you are talking about, replacement components
> shouldn't be needed, it just sounds like you want to modify the local
> repository. That seems like a feature request to make of the dependency
> plugin.
>
> Cheers,
> Brett
>
> 2008/9/1 Dan Tran <da...@gmail.com>
>
>> Currently,  a typical localRepository configuration is declared like
>> this in the mojo.
>>
>>   /**
>>     * Used to look up Artifacts in the remote repository.
>>     *
>>     * @parameter
>> expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
>>     * @required
>>     * @readonly
>>     */
>>    protected org.apache.maven.artifact.factory.ArtifactFactory factory;
>>
>>
>> This means, I can create my own local repository plexus component
>> implementation, declare it as a dependency in my pom in the plugin's
>> dependency list, and pass it in as a execution configuration like
>>
>>  <execution>
>>    <configuration>
>>       <local>myExecutionLocalRepository</local>
>>    </configuration?
>>  </execution>
>>  </executions>
>>  <dependencies>
>>    my implementation goes here
>>  </dependencies>
>>
>> Where myExecutionLocalRepository is the plexus component name, known as
>> "hint"
>>
>> Is the right approach?
>>
>> The motivation behind this is that I have a need to use dependency
>> plugin to copy and unpack some very large artifacts and I dont want
>> it to pollute my global local repository especially when using
>> snapshot artifacts.  myExecutionLocalRepository is located under
>> target directory so that It can be cleanup via maven clean.
>>
>> Advice is greatly appreciated.
>>
>> Thanks
>>
>> -D
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
> --
> Brett Porter
> Blog: http://blogs.exist.com/bporter/
>

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