没有(远程)存储库的 Maven?
我有一个 Maven 2 多模块项目,并希望确保所有内容都取自我本地签出的源。
- 是否可以告诉 Maven 永远不要下载其来源模块的任何内容?我必须禁用远程存储库吗?
- Maven 是否总是必须采用昂贵的方式将模块安装到本地存储库中,然后为其每个依赖项再次提取它?
- 如果本地源发生更改,Maven 是否会首先自动重新编译模块的依赖项,然后再编译依赖项?
I have a Maven 2 multi-module project and want to be sure everything is taken from my local checked-out source.
- Is it possible to tell Maven to never download anything for the modules it has the source of? Do I have to disable the remote repositories?
- Does Maven always have to go the expensive way of installing a module into the local repository, and then extracting it again for each of its dependents?
- Does Maven automatically first recompile dependencies for a module if their local source changed, and then compile the dependent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不会。Maven 2 在构建时仅“看到”当前模块。从好的方面来说,您可以通过在模块中运行 Maven 来构建树的一部分。
是的,使用“离线”选项
-o
或-offline
。或者将settings.xml
与没有任何文件的代理一起使用。但这不是你想要的。是的,但并不贵。在构建过程中,文件被复制(这在十年前是昂贵的)。当使用依赖项时,Maven 只是将文件的路径添加到 Java 进程中。因此该文件不会再次被复制或修改。 Maven 假定本地存储库中的文件不会更改(或仅在下载/安装时更改一次)。
没有。有 Maven 3 的计划,但我找不到启用类似功能的选项。
要解决您的问题,您应该安装本地代理(例如 Nexus)。
No. Maven 2 only "sees" the current module while it builds. On the plus side, you can build part of the tree by running Maven in a module.
Yes, use the "offline" option
-o
or-offline
. Or usesettings.xml
with a proxy that doesn't have any files. This isn't what you want, though.Yes but it's not expensive. During the build, the file is copied (that was expensive ten years ago). When a dependency is used, Maven just adds the path to the file to the Java process. So the file isn't copied or modified again. Maven assumes that files in the local repository don't change (or only change once when a download/install happens).
No. There were plans for Maven 3 but I can't find an option to enable something like that.
To solve your issues, you should install a local proxy (like Nexus).
仅当您的本地存储库 (
$USER_HOME/.m2/repository
) 中没有可用的内容时,Maven 才会下载该内容(依赖项)。如果您不想下载任何内容,请使用离线模式。这可以通过使用-o
开关来完成。例如里面没有什么昂贵的东西。如果您正在构建完整父项目,它将构建所有模块,然后将工件复制到本地存储库。然后,当您构建一个依赖于这些项目的项目时,Maven 只会将它们从硬盘上的本地存储库复制到将为当前项目创建的包中。
不。我被烧伤了。 Maven 不会自动编译依赖项。有一个名为 Maven Reactor 插件 的插件。该插件使您能够在构建项目之前构建项目的依赖项。
Maven download stuffs (dependencies) only if it's not available in your local reposiotory (
$USER_HOME/.m2/repository
). If you do not want anything to be downloaded use offline mode. This can be done by using-o
switch. E.g.There is nothing expensive in it. If you are building the complete parent project, it will build all the modules and then copy the artifacts to your local repository. Then, when you build a project that has dependencies on those project, Maven will just copy them from local repository on your hard disk to the package that is going to be created for current project.
No. I have been burnt. Maven does not compile dependencies automatically. There is a plugin called Maven Reactor Plug-in. This plugin enables you to build a project's dependencies before the project is built.