1

I'm trying to convert a java project into a Maven project with the Eclipse plugin. However my work environment does not allow any internet connection whatsoever and I cannot compile the code outside of the work environment. I have listed all the Referenced Libraries (which im guessing are the dependency libs) in the original Java project which I was hoping Maven would take from rather than connecting to the internet. Is there a way I can build the Maven project without connecting to the internet>

Nazilla
  • 581
  • 1
  • 7
  • 17
  • Google for instructions to create `private Maven repositories`. It should help. –  May 28 '15 at 10:48
  • I'd say you need to build the first time with internet so that maven can create his cache (`.m2` directory) and then after that, the next time it will seek in cache before going to internet – flafoux May 28 '15 at 10:49
  • My recommendation: don't expect a tool to do the work for you. Sit down; read a maven tutorial, and learn how to **manually** create a maven setup. It seems that you are working in a complex environment; so it would be much better to **understand** what using maven actually means in that context. – GhostCat May 28 '15 at 10:49

2 Answers2

1

You need an internet connection. Maven isn't initially self-sufficient. It needs to download a bunch of plugins along with their dependencies and the dependencies of your own project. And this really depends on what sort of settings you have for your projects. One set up will require one set of dependencies, another - a whole different one. You can't download artifacts from the Maven Central manually and then install them locally one by one. Simply put, that sounds stupid.

I understand that you're coming from the Ant world where Ant has everything it needs on the local file system. However, Maven relies on the fact that it will have a central repository (either Maven Central, or your own repository - Nexus, Artifactory, etc.) from which to download the plugins and dependencies it needs. There is no point in you migrating to Maven, unless you'll be allowed access to the Central Maven Repository.

Yes, indeed, you can run Maven offline and you can have Maven produce a local repository for you to use when you are in offline mode. However, what you're trying to do is against Maven's principles.

If your company won't allow access to Maven Central, just stick to Ant. Your effort will be a waste of your company's and, ultimately, your own time.

Pavan Kumar K
  • 1,360
  • 9
  • 11
  • If you have no internet access then Maven is not the right tool. – Qwerky May 28 '15 at 10:53
  • 2
    Internet is not required *on your workstation* if you can set up a maven repository (Nexus/artifactory) in another node of your company's network that proxies maven central. – Timo May 28 '15 at 10:54
1

you can add every jar to maven repository using mvn install command, then use dependency for only added jar. if you use plugins you need do some works for them..you use maven for 1 time with internet then use -o to use maven offline(mvn -o install).

 mvn install:install-file -DgroupId=com.example -DartifactId=example -Dversion=1.0 -Dpackaging=jar -Dfile=/path/to/jarfile

    <dependency>
            <groupId>com.example</groupId>
            <artifactId>example</artifactId>
            <version>1.0</version>
    </dependency>
Ragu
  • 373
  • 5
  • 15