Maven without (remote) repository?

一笑奈何 提交于 2019-12-01 08:36:48

Is it possible to tell Maven to never download anything for the modules it has the source of?

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.

Do I have to disable the remote repositories?

Yes, use the "offline" option -o or -offline. Or use settings.xml with a proxy that doesn't have any files. 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?

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).

Does Maven automatically first recompile dependencies for a module if their local source changed?

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).

  1. 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.

    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.

  3. 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!