简体   繁体   English

Maven 外部依赖项 - Nexus 不是一个选项

[英]Maven external dependencies - Nexus not an option

I have a Maven project which holds a number of shared classes for two other projects (one maven Java SE project and one Android project).我有一个 Maven 项目,其中包含其他两个项目(一个 Maven Java SE 项目和一个 Android 项目)的许多共享类。

I need to package this shared jar up in the other projects when I do a build.我需要在构建时将此共享 jar 打包到其他项目中。

Now I know of Nexus, but I'm working without access to a shared installation of it.现在我知道 Nexus,但我无法访问它的共享安装。

Is the only option to include the shared jar as part of the maven/gradle projects in src/main/resources for example?例如,将共享 jar 作为 maven/gradle 项目的一部分包含在 src/main/resources 中是唯一的选择吗?

The best answer is to host your own internal host repository.最好的答案是托管您自己的内部主机存储库。 See here for more details.请参阅此处了解更多详情。 We use SonaType Nexus .我们使用SonaType Nexus

However, you could just rely on your "local repo".但是,您可以依靠您的“本地回购”。 When you do mvn install , the artifacts you build get hosted to your local filesystem, typically at ~/.m2/repository .当您执行mvn install ,您构建的工件将托管到您的本地文件系统,通常位于~/.m2/repository See your Maven settings.xml for the exact location.有关确切位置,请参阅您的 Maven settings.xml

So, if you always build your shared code first with mvn clean install , the shared artifacts will be available when you do mvn clean install in the projects that use it.因此,如果您始终首先使用mvn clean install构建共享代码,则当您在使用它的项目中执行mvn clean install时,共享工件将可用。 Of course, this will mean that the artifacts are not published and remain local to your build server or local machine.当然,这意味着工件不会发布并保留在您的构建服务器或本地机器的本地。 This defeats somewhat the dependency management feature of Maven.这在一定程度上破坏了 Maven 的依赖管理特性。

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

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