• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I add a jar file to artifactory?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roberto, I strongly recommend you read the free online PDF "Maven a Definitive Guide", it will clear all of this up for you.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Roberto Guerra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks anyways.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Roberto Guerra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Martijn.

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.

 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome, I simply followed through the book to setup our Nexus repo in exactly the same way you'd want to
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.



You are right and it is real easy to do with Artifactory. I suggest you look at the artifacts resolution section of the Artifactory guide, especially the "One minute setup" screencast at the end of the page (direct link).
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to Javaranch Yoav!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic