[ 
https://issues.apache.org/jira/browse/MNG-6371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17428264#comment-17428264
 ] 

Maarten Mulders commented on MNG-6371:
--------------------------------------

As far as I know, in more recent versions of Maven, this is possible. I wrote a 
little [PlantUML plugin|https://github.com/mthmulders/puml-maven-plugin] some 
time ago that leverages 
[{{ServiceLoader}}|https://github.com/mthmulders/puml-maven-plugin/blob/main/maven-plugin/src/main/java/it/mulders/puml/plugin/ServiceLoaderPlantUmlFactory.java]
 to find an adapter for the correct version of PlantUML, and it works with both 
Maven 3.8.3 and 4.0.0-alpha-1-SNAPSHOT.

That doesn't fix it for Maven 3.5.2 of course...

> Use ServiceLoader mechanism in JDK9 in maven plugins
> ----------------------------------------------------
>
>                 Key: MNG-6371
>                 URL: https://issues.apache.org/jira/browse/MNG-6371
>             Project: Maven
>          Issue Type: Improvement
>          Components: Class Loading, Plugins and Lifecycle
>    Affects Versions: 3.5.2
>            Reporter: John Poth
>            Priority: Major
>
> It'd be nice to be able to use the ServiceLoader mechanism in maven plugins 
> when using JDK9:
>  
> {code:java}
> import org.apache.maven.plugin.AbstractMojo;
> public class MyMojo extends AbstractMojo {
>     public void execute() throws MojoExecutionException {
>         // this is empty
>         Iterator<Tool> iterator = 
> ServiceLoader.load(javax.tools.Tool.class).iterator();
>     }
> }
> {code}
>  
> Work around is to use a different classloader.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to