简体   繁体   English

通过Maven编译的github项目之间的依赖关系

[英]Dependencies between github projects that compile via maven

Looking for the best option, or a solution I am unaware of: 寻找最佳选择或我不知道的解决方案:

(probably unnecessary context) I developed "project A", a 1990's RPG video game ported to Java. (可能是不必要的上下文),我开发了“项目A”,这是1990年代移植到Java的RPG视频游戏。 Currently starting on "project B", a server to co-ordinate project A to run as a MMORPG. 当前从“项目B”开始,这是一个服务器,用于协调项目A以作为MMORPG运行。

Project A, lives in gitHub, compiles in maven and has no dependencies on project B. 项目A驻留在gitHub中,在maven中编译,并且与项目B没有依赖关系。
Project B, (will) live in gitHub, has dependencies on "project A", and aspires to compile in maven 项目B(将)位于gitHub中,对“项目A”具有依赖性,并希望在Maven中进行编译

  • I would like both to sit in separate github repositories 我想两个都坐在单独的github仓库中
  • I would like project B's pom.xml to specify the version of 'project A' needed. 我希望项目B的pom.xml指定所需的“项目A”的版本。
    • No preference if this is achieved via specifying a git branch/version or maven artifactId/version. 如果通过指定git branch / version或maven artifactId / version来实现,则没有任何偏好。
  • I would like running maven for project B to find either: 我想为项目B运行Maven来找到两个:
    • (if available) Project A's last local build of specified version. (如果可用)项目A的指定版本的最新本地版本。
    • (fallback) Projects A's latest version on gitHub (备用)在gitHub上投影A的最新版本
  • I would prefer not to host project A Jars in some url (or git repo from project A, or B), as they will become large due to graphics. 我宁愿不要在某些URL(或来自项目A或B的git repo)中托管项目A Jars,因为它们会因图形而变大。 Also that type of thing rubs me the wrong way. 同样,这种事情也使我误解。
  • I would like "project B" to "just work" via a 'git clone ...', followed by a 'mvn package'. 我希望“项目B”通过“ git clone ...”“紧随其后”,然后是“ mvn软件包”。

There seems to be a multitude of approaches: 似乎有很多方法:

  • via 3rd party: eg jitpack 通过第三方:例如jitpack
  • via maven reactor / modules (with what appear to be several sub approaches) 通过Maven反应器/模块(似乎有几种子方法)
  • running 'mvn install' from project A 从项目A运行“ MVN安装”
  • nexus, artifactory 关联,人工的
  • via git submodules 通过git子模块

I would like both to sit in separate github repositories 我想两个都坐在单独的github仓库中

that's trivial 这是微不足道的

I would like project B's pom.xml to specify the version of 'project A' needed. 我希望项目B的pom.xml指定所需的“项目A”的版本。

you can use version to distinguish your jars 您可以使用版本来区分您的罐子

I would like running maven for project B to find either: (if available) Project A's last local build of specified version. 我想为项目B运行Maven来找到以下两者之一:(如果可用)项目A的指定版本的最新本地版本。 (fallback) Projects A's latest version on gitHub (备用)在gitHub上投影A的最新版本

that's maven by design 这是设计的专家

I would prefer not to host project A Jars in some url (or git repo from project A, or B), as they will become large due to graphics. 我宁愿不要在某些URL(或来自项目A或B的git repo)中托管项目A Jars,因为它们会因图形而变大。 Also that type of thing rubs me the wrong way. 同样,这种事情也使我误解。

have you consider to separate resources from core? 您是否考虑过将资源与核心分开? ie put them in separate project given that they least likely to change 即将它们放在单独的项目中,因为它们更改的可能性最小

now solution, in my opionion what you need is remote maven repository (by remote i mean opposite to local which will be accessable whenever you want to work on your project. personally i would recommend nexus, but i might be biased here, given that i have most experience with it. other solution might be maven repository on github. never tried it, but it looks ok 现在的解决方案,在我看来,您需要的是远程maven存储库(通过远程,我的意思是与local相反,只要您想在项目上工作就可以访问它。我个人会推荐nexus,但是鉴于我,我可能对此有偏见。拥有最丰富的经验。其他解决方案可能是github上的maven存储库。从未尝试过,但看起来还可以

You can 您可以

  • check out both projects on your computer, build project A with version xyz and then build B against A with that version. 在您的计算机上签出两个项目,使用xyz版本构建项目A,然后使用该版本针对A构建项目B。 This works through the local Maven repository on your computer. 这可以通过计算机上的本地Maven存储库来工作。
  • put both B and A into a multi-module project so that you can build everything at once. 将B和A都放入一个多模块项目中,以便您可以一次构建所有内容。 This means that both projects have to be in subdirectories of some parent directory. 这意味着两个项目都必须位于某个父目录的子目录中。
  • Use your own Nexus/Artifactory. 使用您自己的Nexus / Artifactory。 Then you can mvn deploy B in a version to this repository and resolve it in A through the same one. 然后,您可以mvn deploy某个版本的B mvn deploy到此存储库,并通过同一版本在A中解析它。 Works more or less like the local repository, but is much more convenient to use and search in. 或多或少像本地存储库一样工作,但是使用和搜索更加方便。

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

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