Is there a way to let maven configure code templates in eclipse? - eclipse

eclipse has the possibility to configure code templates per project. These are stored in /.settings/org.eclipse.jdt.ui.prefs.
when you have a maven project you usually omit all eclipse project stuff and only keep the pom.xml. Then you check it out in eclipse and the m2eclipse plugin generates the project files. Maven even writes the above /.settings/org.eclipse.jdt.ui.prefs.
The problem with this approach is that every developer needs to specify the same templates for the project, since the pom.xml does not know about templates, and so maven does not write them to the prefs file.
I googled for eclipse maven code template and found only that the maven-eclipse plugin is capable of defining a code style in eclipse, but i did not find anything about templates.
Does anybody know of a maven plugin which can solve this?
Any workarounds or other solutions for this?

I use workspacemechanic to share my eclipse settings between different workspaces. Sharing code templates (Window->Preferences->Java->Editor->Templates) seems to work too.
Its an eclipse plugin you have to install, no maven plugin.

Related

IntelliJ IDEA - Sync between Eclipse .classpath and IntelliJ .iml

Say I open an Eclipse project in IntelliJ IDEA, and then I add a library dependency in Eclipse.
How can I sync the .iml file with the modified .classpath one? If there is a way...
If you want to keep dependency consistency across IDE's and achieve even more if you want it... You must use Maven.
Maven is awesome about it. You only will have your project's real code and a file called pom.xml.
You are able to add dependencies in the Maven way to that pom.xml and no matter what you are able to run your project in IntelliJ, Netbeans, and Eclipse without a problem, even across multiple developer on different IDEs.
You can learn a good deal about Maven from this tutorial:
https://www.tutorialspoint.com/maven/
It shows you it's usage in Eclipse, IntelliJ and Netbeans in the last chapters of the tutorial.

How do I mavenize a JSF 2.0 project in eclipse?

I have a JSF 2.0 project on my eclipse. I would like to mavenize the same preferably from Eclipse itself. I tried doing it from outside the eclipse manually. There are quite a few steps and I don't like the manual nature of that approach. Could someone help?
Make sure that you have the standard folder structure as recommended by Maven for web projects. Follow this link.
Now, install maven plugin in eclipse (am not sure if it is available by default or we have to download it manually). Simply right click on the project, select Configure and Convert to Maven Project. This should automatically do all that steps to takes to mavenize your current project. This will create a pom.xml file and you can modify it going forward as per your requirements. By the way, I use Eclipse Juno.

Indigo Maven Project Builder

In Eclipse it is possible to configure builders for a project. I am using m2e and Eclipse indigo for a dynamic web project. I am trying to figure out exactly what happens when I invoke Build for the project from eclipse and so be able to understand the difference between this and a just doing a maven build from the command line. I go to project / builders and see there are five builders: JavaScript Validator, Java Builder, Faceted Project Validation Builder, Maven Prokect Builer and Validation. It would be interesting to see what goals the Maven Project Builder will do but I can't see this from this screen. Edit is disabled. I try Project Properties / Maven and there is nothing to do with Goals there. Even though this http://maven.40175.n5.nabble.com/Preventing-Maven-project-builder-from-being-run-td137622.html suggests there should be.
I am wondering is there any way to see and configure what goals Eclipse will call?
Many thanks.
Strange as it sounds, m2e does not really invoke Maven to do the build.
Its job is to parse POM file and delegate the job of doing everything that it finds there to Eclipse.
It does so by mapping maven plugins to special m2e Eclipse plugins.
Sometimes, when no mapping exists you get a warning and you have a choice of either disabling this part of your build or running the maven plugin in I guess default wrapper provided by m2e. In either case the result is not as good as when a maven-to-eclipse plugin mapping exists

How can I execute Maven goals from Eclipse without M2Eclipse?

I am using the eclipse plugin for maven to generate eclipse projects from maven pom.xml files.
mvn -Dwtpversion=1.5 eclipse:eclipse
This works fine and, after some experimenting with several of the 400 different archetypes available, I settled on using the webapp-javaee6 archetype, which was the only one which generated a set of dependencies that were both all available and which created a project that was useable by the WTP plugin.
The problem now is that I would like to be able to invoke mvn goals from eclipse. The accepted way to do this I understand is to use the m2eclipse plugin, which I have installed.
However, after playing around a bit and getting nowhere I discovered this comment in my .project file:
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
Further searching (see this lengthy diatribe from October) suggests I'm not (just) being stupid in not being able to get this to work.
The how-to linked in the top answer to this question seems hopelessly out of date.
So, the real question - what is currently the correct way to use maven to generate a WTP-friendly project that can be converted to eclipse and then use eclipse to call the project's goals?
Have you tried File -> Import -> Check out existing Maven Projects from SCM? My understanding is that m2eclipse will then create the eclipse project for you. If the packaging defined in the pom is war, the project should be deployable with WTP. (The latter used to require an the maven-wtp-integration plugin as well, don't know whether that's still the case).
Not sure about WTP or maven archetypes, but have you come across SpringSource Tool Suite (Spring packaged eclipse) and created a Spring Roo project? You can use this to create a data driven maven built web-app in a few mins. You can even remove the spring roo bits if you don't want them, it will give you a good starting point for a web-app with very little pain.

Managing external jar dependencies

I'v written a selenium framework which needs to be extended to the team. I've checked in the code in SVN. How can I make sure that external jars are added to build path and folder that folder by other team members? Basically I want to manage these dependencies better. Somebody said, Maven can take care of these so I tried to install m2eclipse plugin for eclipse 3.2 without any success. Can Maven solve this problem and is there any better way of managing it?
Do the easy way: commit the jars into SVN. It will save everybody a lot of time.
If you are amenable to using Eclipse, Maven, and m2eclipse, I would suggest using SpringSource Tool Suite. It is an Eclipse based IDE with Maven and m2eclipse pre-bundled. This bundling makes getting those three tools to work together very easy.