How to programatically invoke a maven dependency plugin

前端 未结 3 1614
再見小時候
再見小時候 2021-02-03 12:53

I am trying to invoke maven-dependency-plugin programatically. i am using maven 3 version. the problem is that when i invoke it through pluginManager.executeMojo(session, execut

3条回答
  •  一整个雨季
    2021-02-03 13:35

    Maven Plugins are not meant to be invoked programmatically.

    They rely on values that are injected by the underlying plexus container.

    So either you will have to find out how to inject those values or you will have to rely on the default mechanism.

    One thing you can use is the Maven Invoker. With that, you can programmatically launch maven lifecycles, but they will execute in a separate VM. So if you need to change the model dynamically beforehand, you will need to serialize the model out to a temporary pom.xml and use that with maven invoker. This is heavy stuff, but I have done it successfully some two years ago.

提交回复
热议问题