Classpath for Maven Plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Classpath for Maven Plugin

Karl Heinz Marbaise-3
Hi,

i'm working on the development of a plugin which can have a
configuration like this.

<plugin>
   <groupId>com.soebes.maven.plugins.mlv</groupId>
   <artifactId>maven-license-verifier-plugin</artifactId>
   <version>0.4</version>
   <dependencies>
     <dependency>
       <groupId>YouCompanyPackage.licenses</groupId>
       <artifactId>licenses</artifactId>
       <version>6</version>
     </dependency>
   </dependencies>
   <configuration>
     <verbose>true</verbose>
   </configuration>
</plugin>

So the question is:

Is there a good way to access the classpath of the plugin only (not
compile, test etc.) and be sure to get the given dependency
(YouCompanyPackage.licenses) in simple way? Or do i have to inject
something special to the Plugin like documented on
http://maven.apache.org/guides/mini/guide-maven-classloading.html for
plugin class loader...

Does there exist an example how to do this?

Many thanks in advance...

Kind regards
Karl Heinz Marbaise
--
SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise        ICQ#: 135949029
Hauptstrasse 177                         USt.IdNr: DE191347579
52146 Würselen                           http://www.soebes.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Classpath for Maven Plugin

Jörg Schaible
Hi Karl Heinz,

Karl Heinz Marbaise wrote:

> Hi,
>
> i'm working on the development of a plugin which can have a
> configuration like this.
>
> <plugin>
>    <groupId>com.soebes.maven.plugins.mlv</groupId>
>    <artifactId>maven-license-verifier-plugin</artifactId>
>    <version>0.4</version>
>    <dependencies>
>      <dependency>
>        <groupId>YouCompanyPackage.licenses</groupId>
>        <artifactId>licenses</artifactId>
>        <version>6</version>
>      </dependency>
>    </dependencies>
>    <configuration>
>      <verbose>true</verbose>
>    </configuration>
> </plugin>
>
> So the question is:
>
> Is there a good way to access the classpath of the plugin only (not
> compile, test etc.) and be sure to get the given dependency
> (YouCompanyPackage.licenses) in simple way? Or do i have to inject
> something special to the Plugin like documented on
> http://maven.apache.org/guides/mini/guide-maven-classloading.html for
> plugin class loader...
>
> Does there exist an example how to do this?

Not really possible for M2, since every plugin is loaded only once i.e. if
you have configured this plugin two times with different deps in the
reactor, the classpath is fixed with the first execution, ignoring the deps
in the second.

M3 will use separate classloders. If that artifact is of type jar, you may
simply load any content as resource.

> Many thanks in advance...

What do you really try to achieve?

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Classpath for Maven Plugin

Karl Heinz Marbaise-3
Hi Jörg,

first thanks for your answer...

>> <plugin>
>>     <groupId>com.soebes.maven.plugins.mlv</groupId>
>>     <artifactId>maven-license-verifier-plugin</artifactId>
>>     <version>0.4</version>
>>     <dependencies>
>>       <dependency>
>>         <groupId>YouCompanyPackage.licenses</groupId>
>>         <artifactId>licenses</artifactId>
>>         <version>6</version>
>>       </dependency>
>>     </dependencies>
>>     <configuration>
>>       <verbose>true</verbose>
>>     </configuration>
>> </plugin>
>>
> Not really possible for M2, since every plugin is loaded only once i.e. if
> you have configured this plugin two times with different deps in the
> reactor, the classpath is fixed with the first execution, ignoring the deps
> in the second.
The plugin is intended for M3 (may be some support for M2 not sure about
that, may be i have to make the decision some time)...


Currently my intention is to a load a resource (one or later more xml
files) from that dependency which is given via the plugin dependency ...

> M3 will use separate classloders. If that artifact is of type jar, you may
> simply load any content as resource.
Do i have to access this class loader in a special way or can i use the
usual way via this.getClass().getResourceAs..().. from within the Mojo
i'm working on...?

The current solution i'm using is via this.getClass()...see here:
https://github.com/khmarbaise/Maven-License-Verifier-Plugin/blob/master/src/main/java/com/soebes/maven/plugins/mlv/AbstractLicenseVerifierPlugIn.java#L267

Many thanks in advance..

Kind regards
Karl Heinz Marbaisea
--
SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise        ICQ#: 135949029
Hauptstrasse 177                         USt.IdNr: DE191347579
52146 Würselen                           http://www.soebes.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Classpath for Maven Plugin

Jörg Schaible-3
Karl Heinz Marbaise wrote:

> Hi Jörg,
>
> first thanks for your answer...
>
>>> <plugin>
>>>     <groupId>com.soebes.maven.plugins.mlv</groupId>
>>>     <artifactId>maven-license-verifier-plugin</artifactId>
>>>     <version>0.4</version>
>>>     <dependencies>
>>>       <dependency>
>>>         <groupId>YouCompanyPackage.licenses</groupId>
>>>         <artifactId>licenses</artifactId>
>>>         <version>6</version>
>>>       </dependency>
>>>     </dependencies>
>>>     <configuration>
>>>       <verbose>true</verbose>
>>>     </configuration>
>>> </plugin>
>>>
>> Not really possible for M2, since every plugin is loaded only once i.e.
>> if you have configured this plugin two times with different deps in the
>> reactor, the classpath is fixed with the first execution, ignoring the
>> deps in the second.
> The plugin is intended for M3 (may be some support for M2 not sure about
> that, may be i have to make the decision some time)...
>
>
> Currently my intention is to a load a resource (one or later more xml
> files) from that dependency which is given via the plugin dependency ...
>
>> M3 will use separate classloders. If that artifact is of type jar, you
>> may simply load any content as resource.
> Do i have to access this class loader in a special way or can i use the
> usual way via this.getClass().getResourceAs..().. from within the Mojo
> i'm working on...?
>
> The current solution i'm using is via this.getClass()...see here:
> https://github.com/khmarbaise/Maven-License-Verifier-
Plugin/blob/master/src/main/java/com/soebes/maven/plugins/mlv/AbstractLicenseVerifierPlugIn.java#L267

AFAICS this should work.  However, I avoid this situation normally since we
still use M2 for production. Therefore is my expertise rather brittle for
the M3 case.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]