I have a Maven web project that depends on other projects that build WAR targets, and then uses the other web projects as overlays. All of these projects are part of a single parent project, imported into Eclipse as a Maven project.
The main web project's POM has dependencies and overlays with maven-war-plugin defined for the other modules.
My problem
in Eclipse, for some reason, when I update the Eclipse project from the Maven project, some of the modules are recognized as coming from other Eclipse projects, and others are expected to come from my Maven repository.
On closer inspection org.eclipse.wst.common.component shows a difference in the dependent-module for some modules.
<dependent-module ... handle="module:/overlay/prj/module1" />
vs.
<dependent-module ... handle="module:/overlay/var/M2_REPO/group/id/module2" />
Why would some modules be recognized differently than others?
Both are equally included as dependencies and overlays in the POM.
My workaround has been to edit this file by hand to get Eclipse to recognize that it should use the other Eclipse project directly (module:/overlay/prj) rather than look to the Maven repo.
Related
I have received a J2EE project which has some servlets defined.
I have imported this project in Eclipse [Version: Mars Release (4.5.0)] as a Java project.
This project has a pom.xml defined which contains a list of dependencies. How can pull the dependencies defined in pom.xml.
When I open pom.xml it opens as a raw xml.
Do I need to import this project as a Maven project?
If you have the m2e plugin (http://download.eclipse.org/technology/m2e/releases) installed into eclipse , you can import the project as a maven project and then run the dependencies by running as a maven build. Guess that will be the easiest to do.
In my maven eclipse project I see Maven dependency and Referenced Libraries. In some cases they have the same set of jars referring to M2_REPO. And in some they are entirely different. Leaves me confused as to why there are 2 different jar references in the same project.
Maven dependencies are added in pom file to a project. When you build the project, maven dependencies that you have added in pom file will be downloaded from the M2 repository.
Reference libraries are added manually for projects in Eclipse IDE.
When you leave confusing for those jar files, just add all libraries as maven dependencies.
Classes in both Referenced Libraries and Maven Dependencies are visible in Eclipse but Maven build can see only dependencies from pom. If you try to build the project with maven it may fail because of this
I have been working on maven for some time but never had this question before, Many times I created my maven project using a IDE wizard which helps me to create a maven project which has pom.xml pre-configured or the other way is to convert a general java project into maven project which generates a pom.xml. I have a question what exactly happens in the background when we convert this java project into a maven project. What will be configured and how does the java project detects it has a pom.xml.
Inside the .project file in the root of the Eclipse project, m2eclipse will add the org.eclipse.m2e.core.maven2Nature to it. This tells Eclipse that the m2e plugin will handle various stages of the project lifecycle, and m2e has a hybrid partially-internal and partially-external engine that applies the instructions in the pom.xml to the project. (For example, it finds the classpath placeholders that are marked as maven.pomderived and replaces them with the appropriate Maven dependencies.)
If i want to convert an EAR project a maven project , do i need to add the module in the deployment assembly as maven dependency or just use the convert in m2eclipse without any further configuration.
Me personally I wouldn't attempt any kind of conversion of an existing project. I would add the poms, make sure that mvn clean install works on the command prompt and then create a new mavenized Eclipse project from the poms.
The main reason is that you current project settings are effectively wrong when you switch to Maven - the Maven poms are the truth and what feeds the Eclipse project setup, so you really do not want to make your life difficult and work against m2eclipse - let it do the project creation for you. Fresh.
You can install m2eclipse and then do the following as well.
Go to the project menu (right click on Package Explorer) > Configure > Convert to Maven Project
Open the pom.xml and right-click and choose Run As -> Maven Clean. Similarly Choose Run As -> Maven Install.
Note : Please ensure that your eclipse project settings are correct and classpath libraries are not absolute and you don't have any project specific environment variables defined in your workspace. Please take a backup of your project before you do this.This is to ensure we don't mess up the current stable project configurations. Once m2eclipse generates the pom.xml for your project, you can update and make changes to it to
fully obtain a mavenized ear build. hope this helps
You can also try creating new maven project with archetype selection of "jboss-javaee6-ear" and follow the similar structure for your project. Most probably you will need parent Pom and child poms per each module (ejb, war, jar etc). There are other few similar approach but almost all of them requires you to have mulitple POMs
maven-ear-plugin and JBoss AS 7
You can also go through all the examples for maven ear plugin to find settings suitable for you
http://maven.apache.org/plugins/maven-ear-plugin/
I ended up ditching ear for war :) single POM and even ditched the JBOss for tomcat/jetty :)
If you want to convert your existing eclipse dependencies into Maven dependencies, you can try the JBoss Tools (JBT) Maven integration feature, which contains an experimental conversion wizard, plugged into m2e's conversion process : http://docs.jboss.org/tools/whatsnew/maven/maven-news-4.0.0.Beta1.html.
So, all you have to do is, as Keerthi explained, right-click on your project and Configure > Convert to Maven...
If your dependencies already are maven artifacts, it should work easily. If not, you'll need to convert them to Maven (if they're workspace projects) or make them available in your maven enterprise repository, before converting the EAR project.
JBT (requires Eclipse JavaEE) can be installed from http://download.jboss.org/jbosstools/updates/stable/kepler/ or from the Eclipse Marketplace (See https://marketplace.eclipse.org/search/site/jboss%2520tools)
I have a maven module for validation which I must pass to a old version of Eclipse which has the Jrules API within. However there is not a maven plugin for this eclipse IDE. So I figured I would do a maven:install on the module and move over the created jar.
However when I try to import->Existing Projects into Workspace->Select archive file:
and point it to the jar no projects appear. I'm at a loss as to how I can move my maven module to the outdated eclipse, without having to grab the 101 jars required for the project and non mavenise it...
Surely their has to be an easy way to this or is maven will monolithic
Use the maven-eclipse-plugin to generate the .project and .classpath files for you:
mvn eclipse:eclipse
This will create the IDE metadata files which reference all of the JARs your project depends on from within your local maven repository folder.
Attempting to import the JAR that is built by the Maven build process into Eclipse using the " import->Existing Projects into Workspace->Select archive file" doesn't work because Eclipse expects to find a .zip/.jar file with the .project metadata files and the source code. Your compiled JAR likely contains neither.
I would recommend using the M2Eclipse maven plugin. Right click the project -> Enable Dependency Management -> Update Project Configuration
I have used eclipse:eclipse extensively and my experience is that M2Eclipse is not only better supported but works better overall.