Hi, I am a maven Newbie. We want to put all our jar dependencies for one of our projects in a repository, for example, spring.jar, commons-logging.jar, etc. So in our project.xml for the projects we working on, we can specify which jar file we want to use as a dependency and then have maven download it to a lib folder. I can't find any documentation on how to do this.
Do I have to create a maven project for each individual jar file?
Martijn Verburg wrote:Hi Roberto, I strongly recommend you read the free online PDF "Maven a Definitive Guide", it will clear all of this up for you.
Maven maintains a repository on your development machine. When it processes a project's POM, it builds the repository, if one doesn't already exist, then for each dependency, it downloads the dependency jar into the repository. The build process will copy that jar into the target if the dependency scope demands it. You pay a pretty hefty price the first time, when everything has to be downloaded at once, but after that, only changes get downloaded.
That's the short answer. Take Martin's advice for a more advanced explanation.
An IDE is no substitute for an Intelligent Developer.
Joined: Mar 09, 2007
I understand. What I want to avoid is for the developers to download from the Internet the first time. I want to control the jar files that they use in each project. I thought it was possible to host the jar files in a local server and have the developers get their dependencies from there instead of the Internet.
Yes, you can provide your own repositories locally and share them amongst the internal development staff.
Maven isn't designed to forbid use of jars, regardless of where they come from, but if you have internally-developed assets that you want Maven to be able to exploit, they can be published to a local shared registry.
If you have a situation where the desktop developers are denied direct access to the Internet (a tactic that rarely works very well), you can stage/cache the publicly-published items like the j2ee api jars in your site repository as well.
Maybe you should take a look at Nexus (http://nexus.sonatype.org/). Nexus is, in a few words, a web application that you deploy on one of your servers whcih functions as a proxy for your maven repository.
Nexus allows you also to mirror other repositories. That means: the first time a JAR is needed (e.g. spring.jar) it would be downloaded from an official repository and would be copied to your internal repository. Any other developer who would need this particular JAR later, would download it from your Nexus-server. So you could restrict internet-access this way. But if it's worth the effort to setup all JARs in Nexus on your own... that's something you have to decide.
There's also a chapter about Nexus in the book mentioned by Martijn. Definitely worth reading.
Joined: Mar 09, 2007
But if it's worth the effort to setup all JARs in Nexus on your own
Actually, that is what I want to do. I do not want the developers to download any jar for official projects from the Internet. We do not restrict Internet access. But what we want is for all developers to use the same jar files for company projects. So that way we are sure that they are using the same version of spring, the same version of log4j, etc. If a different version is needed for a different project, then we want to be able to put that jar file in the repository and have the developers pull from there. Yes, they have Internet access, but we want to be sure everyone is using the same versions of the libraries we specify.
Roberto Guerra wrote:I understand. What I want to avoid is for the developers to download from the Internet the first time. I want to control the jar files that they use in each project. I thought it was possible to host the jar files in a local server and have the developers get their dependencies from there instead of the Internet.