以编程方式将Maven工件安装到本地存储库

时间:2021-03-25 23:56:49

What I have is the need to use a Groovy script or Maven plugin to generate a jar before compile time and then install it to the local repository so it can be used in the compile process (ie the depend will be satisfied by the build process and not downloaded through any external repos). I have got as far as using a groovy script to create this jar before the compiling / dependency resolution begins.

我所需要的是需要使用Groovy脚本或Maven插件在编译时生成jar然后将其安装到本地存储库,以便它可以在编译过程中使用(即依赖将由构建过程满足,并且不通过任何外部回购下载)。在编译/依赖关系解析开始之前,我已经使用了一个groovy脚本来创建这个jar。

As the API documentation for working with Maven outside of creating a Mojo is very slim, I would like some pointers to getting this jar into the local repository.

由于在创建Mojo之外使用Maven的API文档非常渺茫,我想要一些指针将这个jar放到本地存储库中。

Thanks in advance, md_5.

在此先感谢,md_5。

EDIT: I would also like to have a way of knowing if the artifact is in the maven repo beforehand.

编辑:我也希望有一种方法可以预先知道神器是否在maven repo中。

1 个解决方案

#1


0  

I think you need to use maven-invoker-plugin, which starts a new Maven instance, where you generate your artifact, build it, and install into local repo, using native Maven plugins.

我认为你需要使用maven-invoker-plugin,它启动一个新的Maven实例,你可以使用本机Maven插件生成你的工件,构建它,并安装到本地存储库中。

#1


0  

I think you need to use maven-invoker-plugin, which starts a new Maven instance, where you generate your artifact, build it, and install into local repo, using native Maven plugins.

我认为你需要使用maven-invoker-plugin,它启动一个新的Maven实例,你可以使用本机Maven插件生成你的工件,构建它,并安装到本地存储库中。