I would like to have all the JAR files of Maven in my hard-drive to do some experiments. Is there any way to download all the jar files from Maven repository?
My operating system that i used is Windows 7.
It is not clear what you mean by "all the JAR files of Maven", the Maven central repository contains gigs of jar files. If you can explain further what you are trying to do then it will be easier to help.
If you have a maven project then you can run:
mvn clean install
from the directory where the pom.xml file is located. Maven will download all of the dependencies required by the project to your computer, the default location is the .m2 directory under your user directory.
Another option is to use the maven dependency plugin to download all of the dependencies of a given project to a location.
Use a repository manager like Nexus. http://nexus.sonatype.org/
or Apache Archiva too http://archiva.apache.org/ :-)
See http://docs.codehaus.org/display/MAVENUSER/Maven+Repository+Manager+Feature+Matrix
Related
Because my repository misses some jar files. I want to redownload the whole repository again. where can I download it?
Like this:
Maven Repository
I'm not sure what you mean..
As upper comment says, maven will automatically download the dependent jar files once if you had described in pom.xml.
Or.. if you want to force re-download the whole jar files,
then just remove folders in .m2/repository/ and re-update or build mvn project again.
I have a maven project i need to copy the jar files from a ftp server to the lib folder during the mvn clean install task.
Suggest me the plugins or steps to achieve this.
THANKS
you can't do that .because Maven resolves its dependencies via HTTP,
you can deploy via ftp but not resolve the dependencies
Creating a Jar file:
I want to create Jar files from a Github Java repository. How can I create below Jar files?
Jars to create:
geo-ip-java.jar
hive-udf-geo-ip-jtg.jar
Git URL: https://github.com/edwardcapriolo/hive-geoip
I found we can create them as below syntax, but seems it is using maven to compile them:
jar cf jar_file.jar file.java
As this is a maven project (as seen that the file pom.xml exists) you can create the target artifact (in your case the jar file) by simply executing mvn package.
If you want to use the jar file in another maven project (as dependency) then it is more usefull to use mvn install as this also installs the artifact in your local repository.
I am using maven to build my java project.
I have a library jar named my.jar used as my project's dependency. However, it is not available in the remote central repository. So, I would like to put the jar file under my project. So, I created a folder named my_repo/ under MyProject.
The directory structure of MyProject looks like this:
MyProject/
my_repo/
my.jar
pom.xml
But I have no idea how could I define my pom to find this particular dependency under MyProject/my_repo/my.jar ?
Could someone please help me for my scenario? By the way, I have also some other dependencies defined in my pom.xml, they are available in the remote central repo.
Using the system scope. ${basedir} is the directory of your pom.
<dependency>
<artifactId>..</artifactId>
<groupId>..</groupId>
<scope>system</scope>
<systemPath>${basedir}/my_repo/my.jar</systemPath>
</dependency>
The recommended way is usually to use a Maven Repository Manager (e.g. Nexus) and then deploy your library to this Maven Repository Manager.
See here for how to set up the settings.xml file:
http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html
How to create maven dependency for your local jars..
1)Create a maven project of the program of which you have to create the jar.
2)Add required groupid and artifact id and version no.
3)Then after writing the java files export it as a jar.
4)Now open other project in which you want to add local jar dependency.Go into its pom.xml and add dependency with the group id,artifact id and version which u had entered in the jar project.
5)Maven clean and install.Now that jar file will be available in your local repository. :)
I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the pom file into that dir. Cd into that dir and ran mvn command without any arguments but I got bunch of errors. I am absolutely new to maven so I think I am missing something. I tried also from Eclipse ( Import project -- exisitng maven project) but that also does not work except eclipse creates a project that has just that file pom.xml. I expect something that first it will download the jar for the project and then download all dependent jars and config files but nothing there.
So given a pom file how do I build the project from it?
mvn install should get you going
I have a maven pom file for an open source project. This pom file has all the info like what other jars it depends on etc. I installed maven. Created a dir samprj and copied the pom file into that dir ...
It sounds like you only have the project's POM file. This is not sufficient. You need to checkout the complete source tree for the project. Having done that, change directory to the directory containing the POM file and run mvn install.
Also, don't copy the POM to a different directory. Maven expects to find all of the source files relative to the POM file location.
FOLLOW UP
Thanks for advice. I was not able to use the command mvn install as it gave errors.
Probably because you hadn't checked out the source.
I don't know how to check the source tree of the project ...
Use a subversion client (the svn command for example), or one of the Eclipse subversion plugins.
If this was a properly documented project, there would be clear instructions on what version control and build tools you needed, how to checkout the source code and how to build it.
... as I thought POM itself should have this information to automatically checkout if the source is not check out.
It doesn't necessarily, though in this particular case it does.
Anyway I was able use Eclipse to build the project without errors.
(Other readers can read #icyrock.com's answer for links to the m2eclipse plugin and documentation.)
The only problem is the dependent jars were downloaded but hidden deep paths in .m2 repository folder on my linux box.
But I would like these dependent jars to be relative to dir where POM file is.
Sorry, but that is not the way Maven works.
The ~/.m2/repository directory is a fundamental part of Maven. It is not a problem. It is a feature. (Don't fight it!)
If you want to open this within Eclipse, you need to install m2eclipse:
http://www.eclipse.org/m2e/
and then import the project as a Maven project as described here:
http://books.sonatype.com/m2eclipse-book/reference/creating-sect-importing-projects.html
Try out their getting started guide. It has a lot of good examples:
http://maven.apache.org/guides/getting-started/