简体   繁体   English

没有(远程)存储库的Maven?

[英]Maven without (remote) repository?

I have a Maven 2 multi-module project and want to be sure everything is taken from my local checked-out source. 我有一个Maven 2多模块项目,并希望确保所有内容都来自我当地的签出源。

  • Is it possible to tell Maven to never download anything for the modules it has the source of? 是否有可能告诉Maven永远不会为它拥有的模块下载任何东西? 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? Maven是否总是必须采用昂贵的方式将模块安装到本地存储库中,然后再为每个依赖项提取它?
  • Does Maven automatically first recompile dependencies for a module if their local source changed, and then compile the dependent? 如果模块的本地源发生了变化,Maven是否会自动首先重新编译模块的依赖项,然后编译依赖项?

Is it possible to tell Maven to never download anything for the modules it has the source of? 是否有可能告诉Maven永远不会为它拥有的模块下载任何东西?

No. Maven 2 only "sees" the current module while it builds. 没有.Maven 2只在构建时“看到”当前模块。 On the plus side, you can build part of the tree by running Maven in a module. 从好的方面来说,您可以通过在模块中运行Maven来构建树的一部分。

Do I have to disable the remote repositories? 我是否必须禁用远程存储库?

Yes, use the "offline" option -o or -offline . 是的,使用“离线”选项-o-offline Or use settings.xml with a proxy that doesn't have any files. 或者将settings.xml与没有任何文件的代理一起使用。 This isn't what you want, though. 但这不是你想要的。

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? Maven是否总是必须采用昂贵的方式将模块安装到本地存储库中,然后再为每个依赖项提取它?

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. 使用依赖项时,Maven只是将文件的路径添加到Java进程。 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). Maven假定本地存储库中的文件不会更改(或仅在下载/安装发生时更改一次)。

Does Maven automatically first recompile dependencies for a module if their local source changed? 如果模块的本地源发生了变化,Maven会自动首先重新编译模块的依赖关系吗?

No. There were plans for Maven 3 but I can't find an option to enable something like that. 没有。有Maven 3的计划,但我找不到一个选项来启用这样的东西。

To solve your issues, you should install a local proxy (like Nexus ). 要解决您的问题,您应该安装本地代理(如Nexus )。

  1. Maven download stuffs (dependencies) only if it's not available in your local reposiotory ( $USER_HOME/.m2/repository ). 只有当你的本地reposiotory( $USER_HOME/.m2/repository )中没有它时,Maven才会下载东西(依赖项)。 If you do not want anything to be downloaded use offline mode. 如果您不想下载任何内容,请使用离线模式。 This can be done by using -o switch. 这可以通过使用-o开关来完成。 Eg 例如

     mvn -o clean install 
  2. 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. 然后,当您构建一个依赖于这些项目的项目时,Maven只会将它们从硬盘上的本地存储库复制到将为当前项目创建的包。

  3. No . I have been burnt. 我被烧了。 Maven does not compile dependencies automatically. Maven不会自动编译依赖项。 There is a plugin called Maven Reactor Plug-in . 有一个名为Maven Reactor Plug-in的插件 This plugin enables you to build a project's dependencies before the project is built. 此插件使您可以在构建项目之前构建项目的依赖项。

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

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