Create an eclipse plugin with dependency on a maven project - eclipse

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/

Related

How to add the axis mar files as a runtime library in a maven project using m2e in 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.

maven plugin in eclipse

Will all the jars used by the project added automatically to build path of project in eclipse by adding the maven plugin to eclipse(m2eclipse)? If not added automatically what should be done to get the jars into build path?
Will all the jars used by the project added automatically to build
path of project in eclipse by adding the maven plugin to
eclipse(m2eclipse)?
All the JARs that you define as dependencies in pom.xml will be added automatically to the Eclipse build path.
If your project is set up as a Maven project in Eclipse, then yes. Also this assumes that your settings.xml file and pom.xml are correct.
If it is an exsisting non-maven project, you will need to use the context menus to convert it into a maven project before the dependencies are added.

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.

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

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/