You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stephen Colebourne <sc...@joda.org> on 2013/11/06 13:37:56 UTC

Plugin, how to resolve single dependency

I have a plugin that needs to access just one dependency from the project.

Currently I use "@requiresDependencyResolution compile" and build the
entire classpath:
https://github.com/JodaOrg/joda-beans-maven-plugin/blob/master/src/main/java/org/joda/beans/maven/AbstractJodaBeansMojo.java#L213

This is far from ideal as it requires the whole codebase that the
plugin is used on to compile, which is hard given that it is a code
generator...

It looks like @requiresDependencyCollection might be what I need, but
what steps must I take to find the actual dependency I want and then
resolve just that one into a classpath?

Feel free to examine the plugin:
https://github.com/JodaOrg/joda-beans-maven-plugin/blob/master/src/main/java/org/joda/beans/maven

thanks
Stephen

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


Re: Plugin, how to resolve single dependency

Posted by Olivier Lamy <ol...@apache.org>.
If the idea is to resolve an artifact when you know
groupId:artifactId:version[:type:classifier]

Try

     @Component
     protected ArtifactResolver resolver;

    @Component
    protected ArtifactFactory artifactFactory;

    @Parameter(property = "localRepository", readonly = true)
    protected ArtifactRepository localRepository;

   @Parameter( defaultValue = "${project.remoteArtifactRepositories}",
readonly = true, required = true )
    protected List<ArtifactRepository> remoteRepositories;



    protected Artifact resolve( String groupId, String artifactId,
String version, String type, String classifier )
        throws MojoExecutionException
    {
        Artifact artifact =
artifactFactory.createArtifactWithClassifier( groupId, artifactId,
version, type, classifier );
        resolver.resolve(artifact, remoteRepositories, localRepository);
        return artifact;
    }



On 8 November 2013 21:05, Stephen Colebourne <sc...@joda.org> wrote:
> Any thoughts on this?
> Stephen
>
> On 6 November 2013 12:37, Stephen Colebourne <sc...@joda.org> wrote:
>> I have a plugin that needs to access just one dependency from the project.
>>
>> Currently I use "@requiresDependencyResolution compile" and build the
>> entire classpath:
>> https://github.com/JodaOrg/joda-beans-maven-plugin/blob/master/src/main/java/org/joda/beans/maven/AbstractJodaBeansMojo.java#L213
>>
>> This is far from ideal as it requires the whole codebase that the
>> plugin is used on to compile, which is hard given that it is a code
>> generator...
>>
>> It looks like @requiresDependencyCollection might be what I need, but
>> what steps must I take to find the actual dependency I want and then
>> resolve just that one into a classpath?
>>
>> Feel free to examine the plugin:
>> https://github.com/JodaOrg/joda-beans-maven-plugin/blob/master/src/main/java/org/joda/beans/maven
>>
>> thanks
>> Stephen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>



-- 
Olivier Lamy
Ecetera: http://ecetera.com.au
http://twitter.com/olamy | http://linkedin.com/in/olamy

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


Re: Plugin, how to resolve single dependency

Posted by Stephen Colebourne <sc...@joda.org>.
Any thoughts on this?
Stephen

On 6 November 2013 12:37, Stephen Colebourne <sc...@joda.org> wrote:
> I have a plugin that needs to access just one dependency from the project.
>
> Currently I use "@requiresDependencyResolution compile" and build the
> entire classpath:
> https://github.com/JodaOrg/joda-beans-maven-plugin/blob/master/src/main/java/org/joda/beans/maven/AbstractJodaBeansMojo.java#L213
>
> This is far from ideal as it requires the whole codebase that the
> plugin is used on to compile, which is hard given that it is a code
> generator...
>
> It looks like @requiresDependencyCollection might be what I need, but
> what steps must I take to find the actual dependency I want and then
> resolve just that one into a classpath?
>
> Feel free to examine the plugin:
> https://github.com/JodaOrg/joda-beans-maven-plugin/blob/master/src/main/java/org/joda/beans/maven
>
> thanks
> Stephen

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