Question

I am working in a private network which doesn't have internet proxy.

I can not create a local repository as well which involves the bureaucracy, management won't allow it. I may be a long term fix but not the solution for the question I asked.

I can not keep maven as a build tool as it requires the direct or indirect internet connection.

I HAVE to use ANT for building the project hence using maven in offline mode also not an option for me.

But I still want to use the maven dependency management for collecting all the jars in a one archive smartly.

My plan is to generate a ZIP file containing dependencies resolved using maven. And then we will share this ZIP file to all developers working inside a private network which doesn't have internet connection.

To do so I will get a temporary access to a computer which is having internet connection and from there I will define a dummy POM with all the dependencies required.

Now the question is how do I generate a ZIP file ( not a single jar ) using maven which contains all the dependencies defined in POM.

Was it helpful?

Solution 3

I ended up with a smart hack which lets me do dependency resolution and archiving!

I am creating a dummy maven web project with all the dependencies defined in pom xml.

Now the war packaging mode is used by default for web applications.

I simply install the maven project from internet facing machine.

I get all the dependencies and transitive dependencies in war file's "lib" directory with dependency naming version remaining unchanged !!!!

Copying and adding those files into an ANT project is a trivial task then..!

OTHER TIPS

while what youre suggesting is technically possible, it is (in my opinion) not the best solution to your problem.

your statement that

it requires the direct or indirect internet connection

is not accurate. what maven requires is a maven repository (or a set of them) to fetch stuff from. the best solution to your problem would be to install a local maven repository inside your organization's network. the 2 most popular choices for a loaclly-run maven repository seem to be nexus and artifactory - both offer free open source versions and paid supported pro versions.

once you set up a maven repository inside your organization's network and populate it with the artifacts you require you can simply configure all of your project's pom files to go to those repositories. for example, to configure maven to use your repo instead of maven central, you can do this:

<repositories>
    <!-- override central -->
    <repository>
        <id>central</id>
        <url>http://your.repo.location</url>
    </repository> 
</repositories>

you will need to map a plugin repository in a similar fashion. its also possible to achieve this by configuring the maven settings.xml file in each user's home directory if you dont want this in the pom files but from my experience its less error-prone this way

use following command to build Maven project offline.

mvn -o package

Refer this and this for more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top