Using maven outside of Eclipse - eclipse

I am already using maven outside of eclipse, but would like to use Eclipse as my main editor. I don't want to use the maven already embedded with M2E. I want to use mine located at /usr/bin/mvn.
Under Window > Preferences, I try to add a maven installation at /usr/bin/mvn (clicking Ok does nothing; stays at the same window) and at /usr/bin (gives the error: The selected directory is not a valid Maven directory..

Ask your maven where is Maven Home
$ mvn -V
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 14:51:28+0100)
Maven home: /home/myuser/maven
and in Eclipse add Maven Home to Maven Installation settings.
But better solution is to use Maven distribution from http://maven.apache.org/. Simply unpack this and configure in Eclipse. Maven from system distribution work great with application installed from system and is not good for development.

/usr/bin/mvn is where the binary is placed, actual maven installation directory might be at /usr/share/maven

Related

Where maven is installed (eclipse plugin)

I have M2Eclipse plugin installed on my eclipse, and now I am reading a book that says to use the mvn command, I think that I could use eclipse IDE to follow the book, but I want to know a little more about maven. Of course, the command "mvn" is not recognized, I need to edit my PATH variable.
I googled where is maven installed, and the answer is that it is an apache tool and the path is where you want to unzip the package.
BUT, what if I donĀ“t want to install the apache project?? Is there any other option, because how I say at the beginning, I have M2Eclipse plugin installed, so I image that the executable file must to be in some folder into the plugin eclipse path... or does it use only java jar libraries without a binary??
Thank you very much.
M2E is a plugin in Eclipse and not Maven. You are using an embedded Maven version which is part of Ecilpse. You should always install Maven to be useable via command line cause there are difference between M2E/Eclipse and command line.
You can run any mvn goal by clicking on a maven project, than right click and select Run As -> Maven Build... and type any goal you want.

Connect project via local maven (in Eclipse)

In Eclipse, I can create dependency project and refer it from Projects tab from Java Build Path dialog.
May I substitute this with something "mavenish"?
For example, may be I can post maven project to local repository and then refer it by maven coordinates as usually in pom.xml?
Yes you could install it to your local maven repository (mvn install). But it also works if you just have the project in your workspace you don't even have to refer it from Java Build Path as you've mentioned. Just add it as a dependency in your pom and the maven plugin in eclipse will use the dependency from your workspace.

Regarding Maven

I am new to Maven and if you feel i am asking really basic question then please forgive me.
I am facing couple of problems with Maven mentioned below.
I am using Eclipse Luna 4.4.1 (Which comes with the Maven Plugin).Now i installed two plugins..out of which one is for subclipse(with SVNKit) and m2e-Subclipse which is used for integrating the maven with SVN.I downloaded the project in eclipse using svn plugin as "checkout as Maven project" and i could see the project being downloaded and now to remove all the errors related with the POM.XML i downloaded the Maven and given the local path of the Maven in the preferences > Maven > installations and changed the Global Settings and user settings files which are project specific.
1). Now even after doing all this circus i still can not see the Maven build options in my Eclipse.
2). I am not even able to clean the project from command prompt.
when i go to my project directory and type "mvn -version" which shows me the correct version of maven.
But when i try to clean it using mvn clean. it does not work.
Please help.
Regards.

Where does Eclipse install maven?

As far as I know eclipse ships with maven already installed. But in order to set up my M2_HOME in order to work with maven from the command line I need to know where eclipse stores it?
I don't want to download maven separate and have 2 instances of that on my PC. That can only create headaches.
In Eclipse there is only installed a maven-embedder which is a part of Maven which means you have to install maven for the command line separately.
Maven plugin, uses java implementation for calling maven.
What you can do is download and unzip/untar maven for mvn command-line scripts and bin, later you can configure eclipse to point to your created maven home.
Eclipse Embedded Maven is installed into:
\plugins\org.eclipse.m2e.maven.runtime_XXX
Where XXX - version and timestamp

Eclipse (STS) + Maven

I basically have 2 questions:
Is there a way to invoke maven console from eclipse? (where I could write eclipse:eclipse, and it started building eclipse project)
Where does STS unpack it's maven? I'd like to add that path to env variables, so that I could use it from my windows console.
Is there a way to invoke maven console from eclipse? (where I could write eclipse:eclipse, and it started building eclipse project)
You could open a shell inside eclipse , cd into the right directory and run the maven console from there. But, when using M2Eclipse (see next point), you're not supposed to run eclipse:eclipse.
Where does STS unpack it's maven? I'd like to add that path to env variables, so that I could use it from my windows console.
STS bundles M2Eclipse which comes with an embedded version of Maven (so it doesn't "unpack" Maven). But you can Configure M2Eclipse to use an external version. Go to window > Preference > Maven > Installations and Add... your external install:
Try the m2eclipse plugin from sonatype and you can eliminate use of 'mvn eclipse:eclipse' altogether. After installing m2eclipse and restarting eclipse, select File->Import->Maven->Existing Maven project. Browse to your maven project and select it. The m2eclipse plugin reads the pom and creates an eclipse project (this is the step that 'mvn eclipse:eclipse' gives). There are other useful features of the m2eclipse plugin including pom editor.
m2eclipse project is moving out of sonatype into the eclipse foundation project page and will be released on the Indigo train.
See this page for more info on m2eclipse: http://m2eclipse.sonatype.org/