how to manually install maven plugins, dependencies - maven

i have installed Apache Maven 2.2.1, but this server doesn't have internet connection. So maven couldn't install basic plugins. Can i do it manually, could someone tell my how to do it, please.

I would suggest to do the needed build on a machine which has internet access and transfer the local maven repository later to the target machine.
Or better solution using a repository manager where this machine has access to which solves the problem completely.

http://mvnrepository.com/
Go to the MvnRepository, search for the one you need and download the binary. Store it in the appropriate local maven repository directories to be pulled in from there or manually add a reference to wherever you store the .jar

Related

Fetch all dependencies, put them in a new local Maven repository using Gradle

I have a Gradle project with several subprojects and many, many dependencies. I would like to have a simple way to tell Gradle to download all dependencies (including those under buildscript!) and put them in a local Maven/Ivy repository for later use. The Gradle script should then be able to pull all dependencies from the local repository.
Background: I need to build the application on a server which has absolutely no access to any public Maven repositories, so all dependencies must already be present on the host. I've tried a flat directory, but I have not found it easy to resolve the transitive dependencies, and managing them by hand is not an option. Copying the Gradle cache did not work, either.
Can anyone suggest something? Thanks.
I found a solution, namely to install Apache Archive (http://archiva.apache.org/) locally and set it up as a proxy. Then I copied the entire installation to the target-server and disabled the remote repositories. The dependencies could then be fetched locally.

Maven install without internet connection

I am trying to run the cmd maven compile install. I have mentioned my needed dependencies in the pom.xml. I know that it will get the needed jars from the local repository or central repository.
The problem is that I dont have internet connection (no connection to central repository). My question is - can I able to do the same with the system having internet connection and get all the required files in local repository by running maven compile install.
Then by copying the entire local repository (.m2 folder) from the networked system to the system without internet connection will make the maven compile install to succeed ?
or any other solution is there ?
please help me out. Thanks
The best solution is to install a repository manager run the build on one machine all the artifacts will be downloaded into the repository manager and from that time you can build that only with access to the repository manager.
An other solution would be to do as you described on one machine with internet access build your project and copy the local repository onto a second machine and run your build there via mvn -o ....

Change Maven repository that NetBeans uses

I'm using Ubuntu and I already had an installation of Maven in usr/share/maven and the projects that I install go into repository which is at /root/.m2/repository. Then I installed NetBeans which has it's own Maven in NetBeans/java/maven and it is referring to a repository that it created in /home/user/.m2/rep.
How do I make my NetBeans use "/root/.m2/repository" instead of the other one.
I tried looking into services and looked to change the path to repository, but it's not letting me.
there are 2 files influencing the local repository location.
~/.m2/settings.xml - this one is per user, thus all maven installations on the computer will use it.
${maven.home}/conf/settings.xml - this one is private to given maven installation
Netbeans uses by default the maven installation defined in it's own installation directory (it ships with it) but you can change that in Tools/Options/Maven and with your custom maven installation, it will start using your ${maven.home}/conf/settings.xml. However please note that the installations customized by various linux distributions can sometimes reshuffle where files are located. I would always recommend to use maven binaries downloaded straight from apache website.

Maven Repository

I have downloaded all artifacts in maven repository. Now I copied the repository folder content to other computer running maven. I have to access this new repository for maven commands but it is trying to connect to net for downloading artifacts required. What should I do??
Is there any way of using such repository created manually??
Are you using snapshot versions of your dependencies? If so, Maven might still try to connect to a remote repository to check if there is a new version available. However, you can avoid this by using -o (=offline), like this:
mvn -o <your_command>
Did you set the correct path to the maven repository in your settings.xml file?
This is happening because you might have a different version of Maven on your new machine and thus, it will try to install all the new compatible plugins while you try to build it. So there is no way to get around it except for using exactly the same maven version and same settings

Maven without Internet connection

I'm new to maven project.
I'm changing an ant project to maven project.
To install the 3rd party jar's in maven local repository, I used install command.
Its trying to download the resource jar.pom.
I don't have download access in my organization so the build failed for installtion.
After request i got the resouce jar and clean jar in my desktop(also i can get other necessary jar).
How to make maven to use these jar for the process and how to install the jar in local repository without internet acess.
I downloaded the jar and placed in local repository but it couldn't point the path and use those jars.
please let me know what steps i have follow to run maven install and other commands to build the project without internet access.
where should i placed the jar which i have downloaded by external way.
Please guide me for building and deploying the project.
Thanks in advance.
http://maven.40175.n5.nabble.com/Maven-installation-and-using-in-project-without-Internet-conncetion-tp4564443p4564443.html.
http://www.coderanch.com/t/544641/Jobs-Offered/careers/Maven-installation-project-without-Internet#2471141
I've posted same question in these link
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.
In fact the maven strenght is mainly in the internet accessible repositories and automatic dependency management. But it's possible to use this tool to build your project if you have all dependencies required for your project in your local repository. Then you may use -o option for offline mode and maven will not try to download updated artefact versions.
To get the artifacts into you local repository you have several options:
1) connect to the internet once and mvn build the project (this will download all required dependencies)
2) install dependencies as jar to the local repository manualy (using appropriate mvn command)
I think the questioner is looking for -o or --offline option for mvn. This is a command line option and can be provided while executing.
I think you can setup your repo correctly and execute the mvn goals once when you are connected to internet and use the -o option for later executions .
Hope this helps.
~Abhay
You can configure maven to run in offline mode. Add this entry to your settings.xml
<offline>true</offline>
See here for further information:
http://maven.apache.org/settings.html
Before you can use offline mode, you have to install all necessary third party jars to your local maven repository.
mvn install:install-file
-Dfile=filename.jar
-DgroupId=com.stackoverflow
-DartifactId=artifact
-Dversion=1.0.0
-Dpackaging=jar
-DcreateChecksum=true
-DgeneratePom=true
It's much easier to get those jars in your local repository using an internet connection and online mode.
It's possible to install these resource jars in your local maven repo using install-file. This will make the available to the build. You'll have to do this for each individually, but once that's done you won't have to do anything special.
To be clear, maven puts everything in your local repository, both the jar you're building with this project and the various library jars. Because your system cannot be connected to the internet to maven can populate the local repo with your libraries, you'll have to use this manual approach.
Edit: You should be able to run install-file anywhere. When you do, you'll need to provide the groupId, artifactId, version, and packaging using the command line options. If you already have a POM file for the library, you can provide that instead via -DpomFile=your-pom.xml.
This question has some useful info: How to manually install an artifact in Maven 2?

Resources