How can you import M2E Maven projects into Eclipse from the command line? - eclipse

I'm working on writing a script that will checkout multiple Maven projects that all have modules. I want to import all the modules into Eclipse Mars as M2E projects. Now I've scoured other questions and answers about this and only see Eclipse CDT based solutions (eclipse.exe -base workspace -importAll {someURI}). However this doesn't convert your projects into M2E projects in eclipse. They are just plain-Jane java projects.
Does anyone know how I can, from a Windows Batch Script, import Maven projects as M2E faceted projects in Eclipse Mars?
I'm using Eclipse Mars.1, Java 7, Maven 3.3.
ADDED:
Ultimately what I really want is a reliable way to build up a complex workspace of M2E projects. There are hierarchical dependencies between them so if it's not done right it's very confusing for more Junior developers.

You can try to use:
mvn eclipse:eclipse
This will generate eclipse configuration files, after of that you can import into eclipse:
eclipse.exe -base workspace -importAll {someURI}

Related

Import Existing Maven in Eclipse as WTP

I had to reinstall my Eclipse and now i have to import all the existing projects into the new workspace. The previous version of Eclipse was Galileo, this version is Indigo. The plugins are installed, but after the "Import Existing Maven Project" the projects are not showing as WTP (WebApp Project)...
Do i need something else to setup or config?
Thanks a lot!
Yes, you need to install additional software. The "Maven Integration for Eclipse WTP"
See here: http://marketplace.eclipse.org/node/96737
Update Site: http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/
You can convert a maven project to a Eclipse WTP project.
After that you only need to import the project as any other project.
The command to convert is:
mvn eclipse:eclipse -Dwtpversion=2.0

Trying to understand how to work with Maven and Eclipse

I import a project into eclipse from svn and then go and run 'mvn install' from the command line and everything compiles fine. But I don't understand why the code is not compiled in Eclipse too.
From my previous experience I know that I need to go ahead in Eclipse and import "existing maven projects" to have Eclipse compile the code, I just don't understand why.
Thanks!
How have you imported the projects to Eclipse? By runnint mvn eclipse:eclipse to import them as 'Java project' or importing the maven projects directly with the m2eclipse plugin?
By default maven builds each project into a directory target in each project whereas Eclipse builds into eclipse-out. mvn install builds each maven project to create an archive (jar, war, ear etc) whereas Eclipse needs to build to be able to run the code in Eclipse.

Question on "Converting Maven project of Mahout into Eclipse project"

While installing the open-source software like Mahout, I read some notes like
Convert Maven project of Mahout into Eclipse project
What does this mean? What's the difference between a Maven project and Eclipse project?
Install Maven if you haven't already done it.
Enter the command prompt or a shell and navigate to the directory where the Mahout is located (there's a pom.xml file). Type the command:
mvn eclipse:eclipse
which will create project files for Eclipse and open the project in Eclipse.
No conversion is needed. Eclipse supports Maven projects, and vice-versa.
Difference between these two projects yield from the difference of the tools. Eclipse is an IDE and Maven is a build tool. In fact, IDE is a superset of a build tool. That's why Eclipse may use Maven for building. Common properties between the projects relate to how the build is being done and Eclipse has a set of properties aimed to persist the state between programming sessions.

How to clone Hibernate sources using Egit (Eclipse)?

I need help using Egit (Eclipse git integration capabilities). My goal is to have Hibernate sources in my local Eclipse. Eventually I aim for running their tests, doing some changes in the sources, issuing a git pull request (patch), etc.
Can someone explain how to clone Hibernate sources and have them as Java Project(s) in Eclipse?
All I can achieve myself is to have the sources cloned (as needed) to some specified path (the suggested path is outside of the workspace directory). Then I am puzzled trying to convert the structure into Java projects in Eclipse. I try different ways to import the project(s) using File | Import (e.g. Existing projects into workspace) or linking sources into a new created Java project. The problem seems to be the Hibernate sources are not a single maven project (not quite sure about this one either, I am new to maven) and probably not an Eclipse project at all, so Eclipse doesn't recognize the source structure at all.
It looks like it has both maven and ant builds, so you can generate Eclipse projects with both of these.
For maven you have 2 options:
Run mvn eclipse:eclipse to generate
eclipse project artifacts and then
import existing projects.
Install m2Eclipse and import Existing Maven
Project. This is the preferred
approach when working with Maven and
Eclipse.
For ant, New project->Java Project from Existing Ant Buildfile

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/