Managing dependencies with Maven in an offline environment

Asked

Viewed 594 times

4

I don’t know if what I’m going to ask is simple or complex, but it turns out that I started using Maven about two weeks ago in college, on a somewhat complex project of the Java EE discipline. I installed Maven, everything straight on my laptop and personal computer at home, everything is ok, but in my work the internet is quite restricted. After downloading the Github project he won’t let Maven download the dependency and says that it couldn’t create Workspace. Is there any way I can export the laptop dependencies and take them to my work?

2 answers

3


There are two main options to work offline on your computer using Maven.

Download everything in advance

Maven dependencies are in the folder .m2 within your user directory.

If you know you will work offline, run the build dependency:go-offline for Maven to try to cache everything it needs for a particular project.

If you are working on another machine, after running the build above, copy the folder .m2 to a flash drive and take with you. Put this folder in the user directory of the target computer and Maven will not download the dependencies again.

Ignore the Maven

You can also copy the necessary jars by running build dependency:copy-dependencies.

All the jars of your dependencies will be copied to the folder target/dependency. Just copy them to a flash drive and take with you.

The drawback of this is that you will have to disable Maven in the other environment and manually add the jars, taking care not to "commit" the modified settings in your IDE by mistake.

  • that’s right! Just a question, when I run build dependency:go-offline, does Maven only try to cache or does it stop downloading? After saving the folder . m2 to put on the flash drive, should I activate again?!

  • @Joãoneto You are confusing "offline mode" with "go-offline". "go-offline" forces the download of dependencies. Offline mode prevents Maven from accessing the internet.

  • Ahh, now I get @utluiz. Thank you very much, thanks! = DD

0

  • But for example, if the site of Hibernate is blocked by proxy for example, it will download the same way by Maven Proxy?

  • These are two different things. Maven Proxy is one thing, and the company’s Internet proxy is another. Read this.

  • I’m on, in the title I put as offline environment precisely for this, for being the company’s internet block. So since the internet is not available I need a solution to pass the dependencies files (already downloaded) for a USB stick, something like that. And every time I update myself on my laptop, I would update on the computer without internet access as well. That’s about it.

  • When I update myself on my notebook I would update on computer without internet access in case by flash drive again.

  • In fact, as far as I know from Maven Proxy, it downloads a mirror of the packets on your machine when possible. Artifactory, on the other hand, has more options than pure and simple replication.

  • In my case it is not an option to replace Maven with Artifactory since it is an academic project of a subject and have to be done with Maven :( only that I need to program it in my work. But ta complicated kkkk.

  • This doesn’t change anything. Artifactory is an implementation of a Maven server. It can use yes without problems.

  • 1

    Hmmm, got it, so I’ll take a look. Thanks man.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.