How to add the axis mar files as a runtime library in a maven project using m2e in eclipse? - eclipse

I have a Maven project in eclipse and I am using the eclipse m2e plugin to manage the Maven dependencies in eclipse.
The m2e plugin is smart enough to let eclipse treat the maven dependencies as a eclipse library and hence I am able to launch and debug my samples and test code from the eclipse.
This all works fine until I have to work with .mar files from axis (specifically addressing.mar). Now this is mentioned as an dependency in the pom.xml, but eclipse is not able to recognize this as a library during runtime until i explicitly add it to the classpath. Is there a way to let eclipse become aware of addressing.mar as a library that is coming from the maven dependencies.

Related

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

How eclipse maven and ant work together?

I made simple maven project and I opened it with Eclipse. I have installed maven plugin for Eclipse. I'm interested in following:
How Eclipse compiles code when I hit save on my source code (does it use configuration from ant or maven or something else)?
When I run tests from JUnit plugin for Eclipse those Eclipse calls mvn test (I suppose not, but what is then happening exactly)?
Is it possible that maven does the build successfully but Eclipse is
showing errors in code?
The Maven Integration for Eclipse makes it easier to edit POM files, allows you to execute maven builds from within Eclipse and to help with dependency management. It doesn't actually compile your code (unless of course you execute a maven build from within Eclipse). The main help is with the dependency management and writing the .classpath file of your project within Eclipse.
To try and answer your questions:
Eclipse uses its standard mechanism to compile code. With a standard eclipse for java developers your project will have a Java Project nature and Eclipse will then use the Java Development Tools - JDT to compile the code. (Internally this uses an incremental builder to build the code http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresAdv_builders.htm). What source files it will compile and where it will place the resultant .class files is configured in your project's Java Build Path (which I am guessing the maven plugin may well configure for you)
JUnit support is part of the Java Development Tools as well.
It is possible that maven will successfully build a project outside of Eclipse, but that the same project will show errors within Eclipse. This is usually down to classpath errors (dependencies defined in the project's POM not being added to the classpath in Eclipse). If you are using the maven plugin with eclipse this probably shouldn't happen. If you are not using the maven plugin within eclipse you can execute maven eclipse:eclipse to have maven update the Eclipse .classpath file of the project which should then fix any of these problems.

Create an eclipse plugin with dependency on a maven project

I have a maven project that contains a certain api I need to use in an eclipse plugin. This eclipse plugin is not currently a maven project but a normal eclipse plugin project with a manifest. I converted this plugin project to a maven project (using m2e menu command to change project to maven) I added the dependency to the maven project from this project. My maven build for this project is running fine from command line. Now when I launch the eclipse application I am getting a ClassNotFoundException for the api I am referring to from the plugin project. Please help.
This can be done by adding tyco configuration to the maven project. That enables you to have a maven project with a Manifest thus enabling other plugins to depend on it. More info: http://www.eclipse.org/tycho/

How can I add a classpath entry as a publish/export dependency in an Eclipse dynamic web project?

I successfully created a project using Wicket quickstart and turned it into an Eclipse dynamic web project by running
mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0
I imported the project to Eclipse without any issues, but got this warning for each JAR:
Classpath entry M2_REPO/**.jar will not be exported or published.
Runtime ClassNotFoundExceptions may result.
I can fix this by using right click → QuickFix on each warning and selecting "Mark the associated raw classpath entry as a publish/export dependency," but this takes a lot of time and would not be possible if there were a lot of dependencies.
There must be a way to have Maven do this for me; what is it?
EDIT: I've found out that using m2eclipse core + Maven Integration for WTP (from m2eclipse extras) resolves my issues.
I'm still interested in how to achieve this without m2eclipse, though, just out of curiosity :p
The two Maven plugins needed to work with web projects in Eclipse are available from the Eclipse Marketplace.
Maven Integration for Eclipse (included in the Java version of Eclipse)
Maven Integration for Eclipse WTP

Generate Web Application Project for Eclipse using Maven.

I'm new to this approach. I've used Maven, Tomcat and Eclipse for my web application. But I'm trying the approach where you create a Maven project using an archetype plugin.
My goal is to create a Web Application Project for Eclipse using Maven that can then be imported into Eclipse. I'm pretty sure there is a super-easy way to do this and I want to know what it is.
I'm using Tomcat 6, Eclipse Helios and Maven 2.
I was referring to this 3-part post:
http://united-coders.com/phillip-steffensen/maven-2-part-1-setting-up-a-simple-apache-maven-2-project
But when I imported the project into Eclipse, I couldn't see the Run As > Run on server option.
What is the best way to go about this? Any links to resources that'd help me understand the approach would be great!
My goal is to create a Web Application Project for eclipse using maven that can then be imported into Eclipse. I'm pretty sure there is a super-easy way to do this and I want to know what it is.
Use the maven archetype plugin to generate your project. Here is how to tell it to use the maven-archetype-webapp when invoking it from the command line:
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp
But when I imported the project into eclipse, I couldn't see the Run As > Run on server option.
It actually all depends on what you use for Eclipse/Maven integration. There are basically two options (and they both provide WTP integration):
the maven-eclipse-plugin which is a Maven plugin that can generate Eclipse files (.project and .classpath and so on) allowing to import the project as Existing projects into Workspace.
the m2eclipse plugin which is an Eclipse Plugin providing Maven integration inside Eclipse and allowing to import a Maven project as Existing Maven projects.
The maven-eclipse-plugin approach
If you use the maven-eclipse-plugin, you have to configure it for WTP support and here is a typical configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
<manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
</configuration>
</plugin>
With this configuration, running mvn eclipse:eclipse on your maven project will generate the WTP files so that the project can be recognized as a Dynamic project (i.e. runnable on a Server). Then import it via Import... > Existing projects into Workspace.
The m2eclipse approach
If you use the m2eclipse plugin (and that would be my recommendation), make sure to install the Maven Integration for WTP from the extras. From the install instructions:
Installing m2eclipse Extras
To install optional m2eclipse
components, you will need to use the
m2eclipse Extras update site. This
update site contains the following
m2eclipse components:
Maven SCM Integration
Maven SCM handler for Team/CVS
Maven SCM handler for Subclipse
Maven issue tracking configurator for Mylyn 3.x
Maven Integration for WTP
M2Eclipse Extensions Development Support
m2eclipse Extras Update Site: http://m2eclipse.sonatype.org/sites/m2e-extras
And then just import your project via Import... > Existing Maven projects and if it's a webapp, it should get recognized as a Dynamic project.
Indigo: m2eclipse approach for Indigo is different. See Maven/Tomcat Projects In Eclipse Indigo/3.7
Important: Note that both approaches are exclusive, use one or the other. But in both cases, there is no need to add a facet manually if you use them correctly.
Download and install the eclipse maven plugin from here. Create your project using the new project wizard in eclipse. Select Maven project and create the project using the archetype you discussed. Set appropriate source folders and add libraries used as part of project properties. This should set you up for your project.
Very simple,
you only have to create a new Maven project with packaging type ‘war’ and directories creation done automatically