could the first ever maven build be made offline?

后端 未结 3 1354
情话喂你
情话喂你 2021-01-06 15:28

The problem: you have a zipped java project distribution, which depends on several libraries like spring-core, spring-context, jacskon, testng and slf4j. The task is to make

相关标签:
3条回答
  • Maven has a '-o' switch which allows you to build offline:

     -o,--offline                           Work offline
    

    Of course, you will need to have your dependencies already cached into your $HOME/.m2/repository for this to build without errors. You can load the dependencies with:

    mvn dependency:go-offline
    

    I tried this process and it doesn't seem to fully work. I did a:

    rm -rf $HOME/.m2/repository
    mvn dependency:go-offline       # lot of stuff downloaded
    # unplugged my network
    # develop stuff
    mvn install                     # errors from missing plugins
    

    What did work however is:

    rm -rf $HOME/.m2/repository
    mvn install                     # while still online
    # unplugged my network
    # develop stuff
    mvn install
    
    0 讨论(0)
  • 2021-01-06 15:50

    Specify a local repository location, either within settings.xml file with <localRepository>...</localRepository> or by running mvn with -Dmaven.repo.local=... parameter. After initial project build, all necessary artifacts should be cached locally, and you can reference this repository location the same ways, while running other Maven builds in offline mode (mvn -o ...).

    0 讨论(0)
  • 2021-01-06 16:01

    You could run maven dependency:go-offline on a brand new .m2 repo for the concerned project. This should download everything that maven needs to be able to run offline. If these are then put into a project-scope local repo, you should be able to achieve what you want. I haven't tried this though

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