In this tutorial I will show how to use the Scala IDE on an existing maven project, and how to start with a fresh project. Maven integration in Eclipse is a separate plugin, and depending on which version of Eclipse you have installed, you might already have it or not. The default maven plugin does not support Scala out of the box, so you need to install the m2eclipse-scala connector. This connector understands the Scala maven plugin and links the compile phase to the Eclipse Scala Builder. You can install both plugins by pointing Eclipse to the m2eclipse-scala update site.

Author:Zologis Jukus
Language:English (Spanish)
Published (Last):2 November 2010
PDF File Size:10.89 Mb
ePub File Size:2.93 Mb
Price:Free* [*Free Regsitration Required]

At the same time, Apache Maven continues to mature, and has grown to be the industry standard for creating extensible and reliable enterprise builds. While it is certainly possible to develop applications in Eclipse and use Maven as a command-line build tool, most developers expect the IDE to know how to invoke and interact with the build tool they are using.

Enter m2eclipse. It is a plugin which helps bridge the gaps between Maven and Eclipse. Using m2eclipse you can develop a large multi-module project with nested Maven modules and have this hierarchical structure reflected in your Eclipse IDE. Using m2eclipse, you can launch and manage your project's Maven build using editors, and your IDE will become aware of both the local and remote Maven repositories allowing you to quickly search for and locate any artifact made available in the Maven repository.

In this article, we will explore the features m2eclipse provides and help you start using an Eclipse plugin which provides real Maven integration for the best IDE platform available. After reading this article you should have enough information to install the m2eclipse plugin and start creating or importing existing Maven projects into your Eclipse workspace. You will also have an idea of some of the features provided the plugin. Note: This article is an enhanced version of the m2eclipse chapter which has been published as a part of Maven: The Definitive Guide , a free, online book from Sonatype which is to be published by O'Reilly in the Summer of The plugin was created in early by Eugene Kuleshov , and was developed under the auspices of the Codehaus community for two years.

In May of , the m2eclipse project was formally accepted into the Eclipse Foundation, and the plugin continues to undergo active development as the developers try to integrate m2eclipse with more features of the Eclipse platform.

The m2Eclipse plugin provides Maven integration for Eclipse. The Subclipse plugin provides the m2eclipse plugin with the ability to interact with Subversion repositories, and the Mylyn plugin provides the m2eclipse plugin with the ability to interact with a task-focused interface that can keep track of development context.

Just a few of the features m2eclipse provides include:. Plugin development is currently focused on providing first-class support for the Eclipse Web Tools Platform and Eclipse AspectJ tools as well as adding graphical editors for both the POM and the Maven settings.

There are many more features in m2eclipse beyond the list above and this article will survey some of the features which are currently available. Let's get started by installing m2eclipse in Eclipse. To install the m2Eclipse plugin, you will need to install some prerequisites. You will need to be running Eclipse 3. This article is going to assume that you are installing m2eclipse on the Eclipse 3. If you do not have Eclipse installed, we would encourage you to download the IDE and follow along with this article.

Eclipse 3. You can install these prerequisites when you install m2eclipse, just add a new remote update site to Eclipse for each of the prerequisite components. Choose the "Search for new features to install" option and click Next. You will then be presented with a list of "Update sites to visit". Click New Remote Site Add a new remote site for each plugin and then make sure that the remote site is selected.

After you click Finish, Eclipse will then ask you to select plugins components to install. Select the components you want to install and Eclipse will download, install, and configure your plugins.

If you are installing the 0. Once you've installed the prerequisites, you can install the m2eclipse plugin from the following Eclipse update URL:. If you would like to install the latest snapshot development version of the plugin, you should use the update-dev URL instead of the previous URL:.

To install m2eclipse, just add a the appropriate update site for m2eclipse. Add a new remote site for m2eclipse and then make sure that the remote site is selected. Select the components you want to install and Eclipse will download, install, and configure m2eclipse.

After you install the m2eclipse plugin, one of the first things you are going to want to do is enable the Maven Console. When you import a Maven project, or create a new Maven project, you are going to want to watch the Maven console to see what the m2eclipse plugin is doing. Then click on the little arrow on the right-hand side of the Open Console icon and select Maven Console as shown below:.

Maven Console shows the Maven output that normally appears on the console when running Maven from the command line. It is useful to be able to see what Maven is doing and to work with Maven debug output to diagnose issues. When using Maven, project creation takes place through the use of a Maven Archetype. In Eclipse, project creation takes place via the new project wizard.

The m2eclipse plugin improves upon this wizard to provide the following additional capabilities:. When you are trying to set up a development environment in an organization with an existing codebase, you are likely going to want to checkout Maven projects from a source control system like Subversion, and this process is covered in more detail later. If you are moving to Maven, you'll want to be able to add new pom. The m2eclipse plugin introduces the concept of the Maven Archetype to the Eclipse platform, and because m2eclipse has access to an index of the Central Maven Repository, you gain access to a large collection of Maven Archetypes.

This is probably the most interesting new functionality introduced by the m2eclipse plugin. Without m2eclipse, creating a new Maven project from a Maven Archetype involves typing out a huge command line in which you specify the artifactId and groupId of both the Archetype and the project you are trying to create.

With m2eclipse, using a Maven Archetype is as easy as filling out a simple New Maven Project dialog and selecting an archetype from a list of all Maven Archetypes in the Central Maven Repository. If someone has published a Maven Archetype to a Maven repository, m2eclipse will be able to locate this archetype when it queries the repository index. Right out of the gate, m2eclipse provides access to over 80 Maven Archetypes for projects ranging from Mule to AppFuse.

Select New Maven Project and click Next. In the first screen of the New Maven Project wizard dialog, you can select "Create a simple project" which will have the effect of skipping Maven Archetype selection. This first screen also allows you to change the directory in which the new project will be created.

By default, the new project will be created in your Eclipse workspace. The second screen of the New Maven Project provides an interface to select a Maven Archetype for your new project. Nexus maintains an index of all artifacts and metadata in the Maven Central Repository which allows tools like Nexus and m2eclipse to rapidly search the contents of a Maven repository.

When this article was written, m2eclipse had approximately ninety archetypes in this Archetype dialog. In addition to the standard set of Maven archetypes, this list of Archetypes contains the following highlights:. And these were just the archetypes that were listed under the Nexus Indexer Catalog, if you switch Catalogs you'll see other archetypes.

A catalog is simply a reference to a repository index. You can manage the set of catalogs that the m2eclipse plugin knows about by clicking on the Configure If you have your own archetypes to add to this list, you can click on Add Archetype This last page of the New Maven Project wizard is where you configure the Maven Coordinates for your project: the artifactId , the groupId , and the version. This dialog also provides you with a field to customize the default package for a new project, and the ability to specify properties to be present in the new project pom.

Once you've selected an archetype and provided a set of unique coordinates, click Finish. If you already have an Eclipse project which is not using Maven, you can start using Maven in a project by creating a new Maven POM file.

Click the Next button to start adding dependencies. Because m2eclipse maintains an index of the Maven Central Repository, you can easily search for dependencies by name, artifactId , groupId , and even locate artifacts that contain a particular class.

If you are trying to work with an existing codebase, then you will need to import a Maven project using m2eclipse. When you have a Maven project on your computer and you need to import one or more modules from this project into Eclipse, you can tell m2eclipse where to find the project and it will scan a directory tree for pom.

Given nothing more than a project's POM, m2eclipse can use the metadata about a project to locate the Source Control repository. Let's take a look at the most straightforward import operation, importing an existing set of Maven projects from a directory.

Pointing m2eclipse at the directory containing a pom. Notice that all the POMs from the project are listed in a hierarchy which reflects the module-submodule relationships of the multi-module project. This is a vast improvement on the way one had to work with Maven projects before m2eclipse. Before m2eclipse, Eclipse had no awareness of the hierarchical nature of a Maven multi-module project, and, when you were using Eclipse to work with nested modules, you just had to accept the fact that Eclipse wasn't going to be able to understand these relationships.

Once you import these projects, Eclipse is going to list each module as a project in your workspace. The top-level servicemix project would be next to a project for other multi-module projects like build , parent , and core. All of these projects would be next to child projects which contain source code like servicemix-jbi and servicemix-core. While m2eclipse allows Eclipse to model the relationships between modules in a multi-module Maven project, Eclipse will still show each node in the tree in a single list of projects.

You'll likely need to do this if you are checking out the source for an existing project or if you need to import some Maven projects from an open source project. There are additional options in this dialog for specifying a particular revision by browsing the revisions in a Subversion repository or by simply entering the revision number manually.

If you wanted to checkout a particular revision of a Subversion repository you would click on the Select When you click on Select You can also control which projects the m2eclipse plugin is going to import from the checked out directory.

By default, m2eclipse is going to import every project under the directory it checks out from source control. If you checkout a large directory tree which contains several nested Maven modules, m2eclipse is going to scan these directories and list each of these projects in a subsequent dialog. If "Check out All projects" is not selected, m2eclipse will only import the top-level Maven project.

If "Use default Workspace location" is checked, m2eclipse will checkout the projects into your Eclipse workspace. If you prefer to keep your project's source code outside of your Eclipse workspace, uncheck this option and supply a Location for the newly checked out Eclipse project. In addition to Subversion, the m2eclipse plugin also supports the following SCM providers:. You can use this feature to "materialize" projects from nothing more than a POM file if the POM file has the appropriate elements to specify the location of a source repository.

Browse the central Maven repository for projects, and materialize them into Eclipse projects. This comes in handy if your project depends on a third-party open source library, and you need to get your hands on the source code. Instead of tracking down the project web site and figuring out how to check it out of Subversion, just use the m2eclipse project to magically "materialize" the Eclipse project.

This is because no projects have been added yet. In order to add a project, you must click the Add button on the right side and select a dependency to add from the central Maven repository.


Maven - Eclipse IDE

The m2eclipse plugin also provides a set of features for working with Maven projects once they are inside of Eclipse. In the previous section, I materialized a Maven project and selected a subproject from the Apache Camel project named camel-core. By right-clicking on the camel-core project, and selecting the Maven menu item, you can see the available Maven features. If the central Maven repository contains a source artifact for a particular project, you can download the source from the repository and expose it to the Eclipse environment. When you are trying to debug a complex issue in Eclipse, nothing can be easier than being able to right click on a third-party dependency and drill into the code in the Eclipse debugger. Select this option, and m2eclipse will attempt to download the source artifact from the Maven repository.


Using Scala IDE on Maven projects

In this tutorial, we will see how to install m2eclipse plugin which provides Maven integration in Eclipse IDE. JDK should be installed with proper environment set up. Read this page for installing the JDK and setting up the environment. Make sure you have Eclipse IDE installed. If you need to install Eclipse, you can read this page. Installing m2eclipse is fairly simple. When the site loads, select the features to install, or click the Select All button.


Get more...

This tooling is developed in the M2Eclipse project. This tooling manages the project dependencies and updates the classpath of the project dependencies in the Eclipse IDE. It ensures that the Maven experience in Eclipse is as smooth as possible. The tooling also provides different kind of wizards import andto create new Maven based projects. It also provides an editor for the pom. You can select the tab labeled pom.


Introduction to m2eclipse

By using our site, you acknowledge that you have read and understand our Cookie Policy , Privacy Policy , and our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I have spent been on the Maven site reading the 5- and minute tutorials, and trialing Maven out for the first time. Despite an honest effort, I have been unable to find a comprehensive tutorial on any Maven plugin. M2E , which seems like the de facto standard, has nothing but broken or recursive links on their site.

Related Articles