26

My objective is to install a jar file in a Maven repository. This post explains how to do an install with MVN.

But but since I have Maven embedded in Eclipse, I don't know where to run the following command:

mvn install:install-file  -Dfile=C:\lib\rest\WadlGenerator.jar \
                          -DgroupId=foo.in.shop.rest.wadl \
                          -DartifactId=WadlGenerator \
                          -Dversion=1.0 \
                          -Dpackaging=jar \
                          -DlocalRepositoryPath=C:\maven\repositories\internal

In short: How can I identify the Maven installation directory for Eclipse-embedded Maven?

Arne
  • 17,706
  • 5
  • 83
  • 99
Dinesh
  • 1,088
  • 4
  • 16
  • 28

4 Answers4

31

From eclipse you can do:

Run -> Run Configurations -> Maven Build (double click)

Your goal is install:install-file

And also you should fill parameters' keys and values

P. S. But I think that it is more better to have external maven installation in system

darwin
  • 354
  • 2
  • 2
  • As you told I did everything. But I'm getting this error. http://pastebin.com/NGYXKDU2 – Dinesh Dec 01 '10 at 12:40
  • I 'm passin the below parameters -Dfile -DgroupId -DartifactId -Dversion -Dpackaging -DlocalRepositoryPath – Dinesh Dec 01 '10 at 12:40
  • 3
    Its worth noting you should add parameter names without the '-D', and you only need 'file', 'groupId', 'artifactId', 'version' and 'packaging'. – Vedran Aug 21 '12 at 09:54
  • This answer is now unnecessary, as the answer below it provides a much simpler way of doing this. – Robert Rapplean Jul 27 '18 at 20:38
6

Or you can simply do: 1. Run 2. Maven Build.. 3. Copy the whole command in Goals i.e.

install:install-file  -Dfile=C:\lib\rest\WadlGenerator.jar \
                          -DgroupId=foo.in.shop.rest.wadl \
                          -DartifactId=WadlGenerator \
                          -Dversion=1.0 \
                          -Dpackaging=jar \
                          -DlocalRepositoryPath=C:\maven\repositories\internal 
  1. Run

This is much easier than filling keys and values :D

Divya Bansal
  • 85
  • 1
  • 8
3

If you have M2Eclipse installed, and you have a Maven pom building the jar, use

Run -> Run As... -> Maven Install

from the Eclipse menu to do the equivalient of mvn install

user281806
  • 1,020
  • 9
  • 14
1

The default location for the maven repository would be ~/.m2/repository.

Unless you changed this in the preferences of your eclipse plugin, then you should go with that. Replace the ~/ with whatever is appropriate for your home dir on your OS.

Edit: Updating based on the comments: There's an online book available for the m2eclipse plugin, and it would appear that you can run goals from the m2eclipse plugin - see the section here: m2eclipse Goals

I presume there is a wizard of some sort when you click on the goal - I don't have m2eclipse installed here.

Edit2: actually looking at the other answer, this has been answered already :)

Goibniu
  • 2,212
  • 3
  • 34
  • 38
  • But What I need is installation directory which is different from the rep dir. – Dinesh Dec 01 '10 at 12:27
  • Sorry, I understand now. I would still install a version of maven on your local system, for these exceptional cases. Eclipse plug-ins are all well and good until you need to do something like this. Some of the plug-ins also allow you to use the external maven install, so that would prevent issues with different versions. – Goibniu Dec 01 '10 at 12:32
  • Yes I can install another maven installation. But I need to do things with Default Eclipse maven. Any luck? – Dinesh Dec 01 '10 at 12:47
  • Which plugin are you using? m2eclipse or mavenide? – Goibniu Dec 01 '10 at 14:01
  • Glad to see your reply. It's m2eclipse – Dinesh Dec 02 '10 at 05:28