maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Dillon <ja...@planet57.com>
Subject Re: How to get ${localRepository} from plexus component (not mojo)
Date Mon, 09 Oct 2006 20:23:15 GMT
In the first snip, I need to get a list of all dependencies for a  
project in a tree so that I can add some dependencies to a classpath  
to execute a child java process.  The second snip is used to resolve  
artifacts which are not configured directly as dependencies, but  
defined similar to how the dependency plugin lists <artifactItems>.

I have a few different plugins that need this and I want to put all  
of the code to do it into a helper component so it is easier to reuse  
and maintain.  I also need to be able to get all of the transitive  
deps for an <artifactItem> too.  For example, in the Geronimo car  
plugin, there is a goal which packages a car, and in that jar we need  
to specify a classpath.  The classpath needs to contain a sub-set of  
the dependencies of the module which is building the car... and since  
in m2 there is no mechanism to annotate dependency elements with  
custom data to allow my plugin to use that to determine which to  
include, I have to do something similar to the dependency plugin and  
define nested artifactItem elements in the plugins config.  Right now  
it lists all of the deps, but I would like to list a few deps and  
pick up the rest as transitive deps of those few artifacts.

So I was building a DependencyHelper plexus component, which defines:

     DependencyTree getDependencies(MavenProject)

     DependencyTree getDependencies(Artifact)

Then mojo's that need this, can use use the helper component and not  
need all of the other bits that are needed to make this work.  So  
far, at least for getDependencies(MavenProject) this works, except  
that I need to pass in the ${localRepository} reference from the  
mojo... which means the mojos that use it need to define fields for  
the helper and the ${localRepository}.  I'd like to avoid needing  
those mojos to know anything about the ${localRepository}.

I've got some similar problems with other components, where I'm  
trying to put commonly used code into helper objects or components to  
share them between my mojos but its a bit of a pain right now as  
helper objects don't get @parameter bits processed and that some of  
the needed objects are not available (AFAIK) to be used in @component  
references.

I'm also a little confused as there seem to be several different ways  
(that have been suggested to be by folks in #maven) to get a tree of  
a specific projects deps transitively or the same for a specific  
artifact.

But, I was able to get something to work with the collector.

Anyways, as we start making more and more plugins to help with the  
Geronimo build, its is becoming more and more important to put the  
shared helper code into components to allow them to be easily shared  
between plugin modules and easier to maintain.

--jason


On Oct 9, 2006, at 6:25 AM, Jason van Zyl wrote:

> What is it that you're actually trying to do?
>
> Jason.
>
> On 9 Oct 06, at 3:03 AM 9 Oct 06, Jason Dillon wrote:
>
>> No I did not send that message 5 times.
>>
>> I need the localRepository for calls like:
>>
>> <snip>
>> artifactCollector.collect(
>>                 project.getDependencyArtifacts(),
>>                 project.getArtifact(),
>>                 managedVersions,
>>                 getArtifactRepository(), // ${localRepository}
>>                 project.getRemoteArtifactRepositories(),
>>                 artifactMetadataSource,
>>                 null,
>>                 Collections.singletonList(listener));
>> </snip>
>>
>> or:
>>
>> <snip>
>> getArtifactResolver().resolve(artifact, getProject 
>> ().getRemoteArtifactRepositories(), getArtifactRepository());
>> </snip>
>>
>> --jason
>>
>>
>> On Oct 9, 2006, at 12:38 AM, Kenney Westerhof wrote:
>>
>>>
>>> Is it my mail client or did you really send this message 5 times?
>>>
>>> The settings object (which contains the local repo) is not a  
>>> component,
>>> so you can't inject that.
>>> You could re-parse the settings.xml yourself, but that's not a nice
>>> solution.
>>>
>>> I think you're stuck with passing the settings or local repo to  
>>> the component
>>> on method calls, or call a setter.
>>>
>>> Btw, why do you need the local repository? If it's for artifact  
>>> resolution you could also a component from maven-artifact(-manager).
>>>
>>> -- Kenney
>>>
>>> Jason Dillon wrote:
>>>> Anyone know how to get the "${localRepository}"  
>>>> ArtifactRepository from a Plexus component... not a mojo.
>>>> More specifically I have created a new component, which I inject  
>>>> into my mojo (with @component and a <component> role defined in  
>>>> plexus/components.xml) and I want that injected component to  
>>>> have access to "${localRepository}", but I don't want to define  
>>>> that in my mojo and pass it in to the component each time it  
>>>> needs it.
>>>> Anyone know how to do this?
>>>> Thanks,
>>>> --jason
>>>> ------------------------------------------------------------------- 
>>>> --
>>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>
>>> -------------------------------------------------------------------- 
>>> -
>>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: dev-help@maven.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>


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


Mime
View raw message