简体   繁体   English

将Maven插件放在nexus存储库中

[英]Put Maven plugins in nexus repository

I would like to set up a Maven repository with Nexus, which is NOT connected to Maven central (due to company policy). 我想使用Nexus设置Maven存储库,该存储库未连接到Maven Central(由于公司政策)。

Now Maven tries to download a lot of plugins when I start it: All downloads fail because I am not connected to Maven central. 现在,当我启动Maven时,它尝试下载许多插件:由于我未连接到Maven Central,所有下载均失败。

Is it possible to either put the plugins into my Nexus repository or install Maven with a reasonable set of plugins? 是否可以将插件放入我的Nexus存储库中,或者使用一组合理的插件安装Maven?

I feel inconsistency in your needs: Nexus is mirror. 我觉得您的需求不一致:Nexus就是镜像。 Maven central is face. Maven中央是面孔。 Nexus content is reflection. Nexus内容是反思。 You want reflection without face. 您想要无脸的反射。 That is impossible. 那是不可能的。

But answer must be positive. 但是答案必须是肯定的。 I offer two options. 我提供两种选择。

Practical: 实际的:

  1. Plug Maven central to Nexus (add face to mirror) 将Maven Central插入Nexus(添加到镜像)
  2. Build app: it will feed Nexus with plugins (catch reflection) 构建应用程序:它将为Nexus提供插件(捕捉反射)
  3. Unplug Maven central 拔下Maven Central

Scientific: 科学:

  1. Call mvn dependency:resolve-plugins . 调用mvn dependency:resolve-plugins You should get several messages like 您应该会收到几条消息,例如

[WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 is missing, no dependency information available [警告]缺少org.apache.maven.plugins:maven-clean-plugin:jar:2.5的POM,没有可用的依赖项信息

  1. Add plugin artifact to Nexus (as said, it is not a problem) 将插件工件添加到Nexus(如上所述,这不是问题)
  2. Repeat step 1 until all plugins are resolved 重复步骤1,直到解决所有插件

If you want to have a manually managed and provisioned repository you will have to provision the needed dependencies and plugins first. 如果要拥有手动管理和配置的存储库,则必须首先配置所需的依赖项和插件。

You can eg do that with my Maven Repository Provisioner . 您可以使用我的Maven Repository Provisioner进行操作

Or you could provision a Nexus repository by running a bunch of builds connected to the Central repository and then take it offline after whatever is needed was proxied. 或者,您可以通过运行连接到中央存储库的大量构建来配置Nexus存储库,然后在完成所需的一切后将其脱机。

Another, much better solution would be to use a policy-based approach and use Nexus Firewall. 另一个更好的解决方案是使用基于策略的方法并使用Nexus防火墙。

You might also be interested in the problems of the manual provisioning approach. 您可能还对手动配置方法的问题感兴趣。 I blogged about this at http://blog.sonatype.com/2013/10/golden-repository/ 我在http://blog.sonatype.com/2013/10/golden-repository/上对此发表了博客。

In either case you are going to have to set up and configure your Maven settings.xml so that dependencies of your plugins and your projects are not mixed up. 在这两种情况下,您都必须设置和配置Maven settings.xml,以便不会混淆插件和项目的依赖项。

And don't forget, Maven relies on a repository for plugins, plugin dependencies and your project dependencies. 而且不要忘记,Maven依赖于存储库来存储插件,插件依赖项和项目依赖项。 All of these have to be available. 所有这些都必须可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM