aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes How do I add a jar file to artifactory? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How do I add a jar file to artifactory?" Watch "How do I add a jar file to artifactory?" New topic
Author

How do I add a jar file to artifactory?

Roberto Guerra
Greenhorn

Joined: Mar 09, 2007
Posts: 8
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
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Roberto, I strongly recommend you read the free online PDF "Maven a Definitive Guide", it will clear all of this up for you.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Roberto Guerra
Greenhorn

Joined: Mar 09, 2007
Posts: 8
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

Joined: Jun 25, 2001
Posts: 15641
    
  15

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.
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 423

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

Joined: Mar 09, 2007
Posts: 8
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
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You're welcome, I simply followed through the book to setup our Nexus repo in exactly the same way you'd want to
Yoav Landman
Greenhorn

Joined: Dec 09, 2009
Posts: 1
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
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Welcome to Javaranch Yoav!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I add a jar file to artifactory?
 
Similar Threads
Maven dependency infomation of third-party jars
Publish to maven repository as "latest"
GENERATE WEBSERVICE[JAX-WS] CLIENT JAR FILE USING MAVEN.XML
Maven 2: Copy JAR of Dependent Project to Distribution
ant vs. maven