Maven without (remote) repository?

后端 未结 2 499
隐瞒了意图╮
隐瞒了意图╮ 2021-01-14 10:37

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
相关标签:
2条回答
  • 2021-01-14 10:46
    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.

    0 讨论(0)
  • 2021-01-14 11:00

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

    0 讨论(0)
提交回复
热议问题