Eclipse (STS) + Maven - eclipse

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/

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.

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

setting up a maven project in Juno Eclipse

I recently upgraded my Eclipse to Juno and am struggling with the way maven dependencies are handled.
I installed the m2e plugin. Still, many of my projects started complaining about libraries missing as if the dependencies specified in the pom were completely ignored. This happened despite right-clicking on the project, selecting Configure --> Convert to Maven project, which seems to be the replacement for what used to be "Maven --> Enable dependencies" before. When I looked at the Maven dependencies under the project directory, there were many fewer dependencies listed than in my pom.
Running a maven compile on the command line outside of Eclipse allowed my project to build and after selecting Maven --> Update project, I was able to see the dependencies added or removed accordingly to what I specified in the pom.xml.
Bottom line: maven dependencies seem to work now but I had to do some combination of operations I didn't think should have been needed:
- Configure -> Convert to Maven project
- Maven -> Update dependencies
- Run maven outside of Eclipse
To get everything to work when with previous versions of Eclipse, all I had to do was Maven -> enable dependencies. What is the equivalent of this in Juno, i.e. what is the correct way of setting up juno Eclipse to handle properly a maven project?
I have been using Juno for a while now and the reliable way to solve Maven dependencies from within Eclipse after importing a project that is maven based is simply:
Configure --> Convert to Maven project
Maven --> Update project
Running Maven outside of Eclipse doesn't seem to help.
I am not sure why these two steps are now required when they were not before with previous version of Eclipse (at least, two steps were not needed before for sure).
Running
mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
outside of Eclipse has brought me the problems I described in my comment to the other answer.
On a Mac running Windows under Parallels Desktop on OS X? This similar discussion may solve your problem: intellij - java: Cannot find JDK '1.7' for module

Eclipse Juno, maven project not able to run on server

I upgraded to Eclipse Juno(for Java EE developers). I installed Maven Integration for Eclipse through marketplace.
Just to test, I created a web app using maven-archetype-webapp. I cannot run on server(There's no menu Run On Server). The same happens with another maven project which runs fine using Eclipse Indigo. A tried deleting .settings, .classpath, .project then re-importing the project but nothing. I was hoping so much on Juno!
Does anyone know a real solution to this problem?
May be Dynamic Web Module in Project Facet is not selected
Go to :- Project > Properties > Project Facets > check Dynamic Web Module
How about installing the m2e-wtp plugin and trying? You would want to confirm that the maven project is of war packaging as well.
Run on server is not a maven feature, it's a "classic eclipse" feature.
In order to run a maven project on a server you must adopt a plug-in (e.g a Jetty plug-in for your webapp) and the run the proper maven goal (e.g jetty-run).
Said this, you can run a web project on a server with (right-click) > Run as > Run on server if you have the proper runtime environment configured.
Enabling "Dynamic Web Module" in Project Facets may not help here in maven projects.
Because maven projects are structured differently (target/sampleApp-1.0-SNAPSHOT.war) than the normal Dynamic Web Projects (WebContent/).
So, If you use Dynamic Web Module manually, then eclipse will try to use "WebContent" directory structure as deployment directory for Application Server which won't be the case in maven projects.
Solution is to use m2e-wtp plugin to do the deployment.
If you installed m2e-wtp plugin, it'll automatically detect your maven project type & it'll show you the "Run as Server" option in "Run as" menu in "Project".

Maven plugin install with Eclipse

I am new to Maven, I have to install maven plugin in eclipse. I am facing some issues in the same, as the inputs I am getting different sites are not working.
I have also gone through existing posts like this, which talks about running the command like :
mvn install:install-file -Dfile=c:\kaptcha-2.3.jar -DgroupId=com.google.code
-DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar
but where do I run this command ??
This site talks about adding as parameter maven.repo.remote like :
maven -DartifactId=maven-eclipse-plugin-plugin -DgroupId=mevenide -Dversion=0.3.1 plugin:download
BUt where are these parameter set ??
Please can someone help me with pointing some good resource, which gives easy steps to install maven plugin in eclipse?
My eclipse version: indigo release, Java EE IDE.
If you are running eclipse Indigo for Java EE you can install the missing m2e plugin this way:
Help-> Install new software -> Work with: Indigo -> General Purpose Tools -> m2e
See also: Where is m2eclipse?
Start with Eclipse Indigo Java EE edition
m2e is the maven integration for Eclipse. Install this plugin in the IDE.
Import maven project if you have any or create a new one
mvn install:install-file is used to install maven artifacts in local repository, if it cannot be automatically downloaded and installed by maven. This is not normally required, but if you have to do this, you can go to Run as -> Run Configurations... and create an appropriate Maven Build configuration.
maveide is not maintained and not to be referred.
In the Indigo release, Maven is already included by the eclipse plugin m2e. At the plugins website, you will find plenty of material. The steps are normally:
Install eclipse with m2e
Install separately a current maven version (depending on what you need, Maven 2.2.x or Maven 3.0.x)
Configure your installed Maven inside Eclipse due to the documentation. Do that in the section Window > Preferences > Maven > Installations. If that is not visible in Eclipse, you first have to install m2e with the normal installation procedure: Help > Install New Software > Work with: Indigo > Filter text: m2e > Collaboration > m2e. Then next, next, next ...
Hope that helps.
Eclipse > Help > Eclipse Marketplace...
Search for m2e
Install Maven Integration for Eclipse (Juno and newer). [It works for Indigo also]