Display Maven War Overlay files in Eclipse - eclipse

I'm trying to make a simple base war which includes all the boilerplate setup for spring, etc. to overlay on new projects to avoid rewriting. The overlay itself is working, however, is there a way to display the files that are being overlayed in eclipse in order to edit them without replacing the file in order to overwrite it?
Thanks!

It's a bit difficult for me to ascertain exactly what you are asking. But I'll take a guess!
I assume the WAR overlay Maven module you has an artifact packaging of type WAR. If so, this Maven module can be imported into Eclipse as its own project (File->Import->Maven->Existing Maven Projects).
Our team does this. Our Maven WAR overlay project is imported into Eclipse as a project along with several (downstream) Maven WAR projects also imported into Eclipse. This can be done regardless of whether the WAR overlay and the WAR Maven modules are part of a multi-module Maven project or are separate Maven projects.
Once the Maven WAR overlay project is imported into Eclipse you can work on it like any other Eclipse project, editing the files, validating, etc. When you are done editing you can save your work and then run Maven from the command line and everything will work fine. You get to edit the overlay files in Eclipse and still have all your Maven goodness.
Note that your Maven WAR projects can be imported into Eclipse as a vanilla Java projects or as WTP (web tools platform) projects. This is totally a matter of preference. For the past year, I worked in Eclipse on Maven WAR projects as regular (unfacted) Java projects. However, recently with the awesome M2E-WTP integration, I now get the full benefit of WTP projects AND the power of Maven. Amoung other things, means I can run the combined WAR on Tomcat from directly inside Eclipse. If you want to understand how to use Eclipse/M2E with M2E-WTP to properly handle WAR overlays, then see my other answer here:
How to handle Maven WAR overlays in Eclipse?
If you have further questions post them in the comments section.

Related

Working with a Scalatra application in an Eclipse workspace? (i.e. build path)

I am experimenting with a small Scalatra web application, which I have imported as a project into Eclipse.
I have used Eclipse to manage a few Lift applications before. With a Lift project, SBT copies all the dependency JAR's to a /lib_managed directory. I can therefore add those JAR's to Eclipse's build path, and it co-exists with SBT just fine without complaining about missing classes.
With Scalatra, however, the dependency JAR's don't seem to get copied anywhere helpful during the development cycle. If you build a WAR file, then the dependencies get bundled up into that... but there doesn't seem to be anything like Lift's /lib-managed directory.
Assuming that anyone else uses Eclipse in developing Scalatra projects, how might I easily set up Eclipse's build path? I suppose that I could manually create entries that point my local Ivy repository one-by-one, although that seems a bit ugly. Perhaps there's an easy way through SBT to setup something similar to Lift's /lib-managed subdirectory inside the project directory.
It looks like the best approach for this is using the SBT plugin for Eclipse.
This is not an "Eclipse plugin" for managing SBT. Rather, it's an "SBT plugin", for generating the .project and .classpath files used by Eclipse. The Maven world used to deal with Eclipse in a similar manner, before the m2eclipse Eclipse plugin reached maturity over the past couple years.
With this plugin installed (I installed it globally so I wouldn't have to change my project's files), you just type sbt eclipse after any changes to your dependencies. SBT will then update your Eclipse project files to match.
You could also use my Maven prototype, then simply import the maven project into Eclipse. Quite nice and you're not forced to use SBT.
https://github.com/fancellu/scalatra-maven-prototype

Eclipse Indigo with m2e can't find maven dependencies in a multi-module project

I've created a multi-module project using Indigo with m2e 1.0. One of the child modules has a dependency on the other. It all builds correctly under maven.
Eclipse, however, can't find any of the classes that this module uses from the dependency .jar. The project properties shows the artifact under Maven Dependencies, but it does not show the actual .jar file itself.
I added the dependency with the Maven menu for this project.
The .project and .classpath got generated automagically at some point. I did not have to run mvn eclipse:eclipse or mvn eclipse:m2e (or whatever the goal is for m2e). The .classpath doesn't have the dependent .jar in it, but it does have org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER.
I've tried all the options under the Maven menu (update dependencies, update configuration) and refreshing the project. I've closed and re-opened Eclipse. It still shows errors.
This makes Eclipse worthless as a Java editor in multi-module projects. I could manually add the dependency .jar in the .classpath, but this defeats the purpose of integration Eclipse and Maven with m2e.
Is there any solution for this in Eclipse?
Thanks.
The answer turned out to be the last answer to this question given by Jody Box. It's pretty bizzare that in order for Eclipse to resolve dependencies from another project in the Workspace that you have to uncheck the "Resolve dependencies from Workspace projects" checkbox.
I know mvn can be convoluted but this checkbox is doing the opposite of what it says.

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.

Eclipse Automatically Download / Update JAR files

I just created a Web App project from a repository through Eclipse's SVN support. What I would be doing is have an ANT build going and then finally deploy through Tomcat.
I am using Eclipse IDE for Java EE developers on an Ubuntu system.
There are a number of jar files needed
to support my project - like Struts,
Hibernate, etc. etc.
Do I need to
manually download each of them
and put them in the lib folder?
OR
Does Eclipse have a solution to
automatically UPDATE these from the internet? Any plugins to automatically take care of this?
You should consider using Maven for your project. It's VERY well supported in Eclipse, and handles all dependencies (as well as other things, such as releases).
The problem is there's a bit of a learning curve, but if you intend your project to get to a considerable size, I'd say it's very important.
Maven has support for ant builds and most libraries are in the central Maven repository. You just say your project has a dependency on the external project and it will automatically download the dependencies.
http://maven.apache.org/

Eclipse+Maven compile problem

currently, I am developing web-apps using Eclipse.
The build is done using Maven.
The problem is that during compile time Eclipse is showing a lot of errors since there are a lot of missing jars. The final result is OK since the Maven is responsible for fetching these jars.
How can make the eclipse not fail the compilation?
I know I can just add the missing jars to the project classpath, but that's not what I'm looking for because I have a lot of projects, and the .classpath file of each project is a file common to all developers, so I would rather not to change it.
My question is therefor, is there a way to add a common classpath to all Eclipse projects without changing each project's classpath?
I use m2eclipse. It adds a classpath container to the .classpath file. This container is populated with the Maven dependencies by a Maven builder (added to the .project when the Maven nature is enabled) which processes the POM and downloads any artifacts (and sources if needed).
To enable the Maven nature (assuming the plugin is installed), right-click on a project and select Enable Dependency Management.
By default m2eclipse uses an embedded version of Maven to do its processing. This typically means a separate local repository and duplicate files on the box. You can configure it to use your standard Maven installation in Window->Preferences->Maven->Installations. Then adding the path to your Maven installation (normally the same as M2_HOME).
There is another Maven plugin for Eclipse called IAM (formerly called Q4E). IAM is an Eclipse integration project and has some promising features - it's worth keeping an eye on.
There is a comparison of the Eclipse Maven integrations, alongside the maven-eclipse-plugin (a goal that generates the Eclipse metadata files from the POM contents). I personally find the maven-eclipse-plugin more trouble than it's worth but it may suit your purposes and it is handy for generating the initial metadata if you have none checked into the SCM.
Check out the m2eclipse plugin. It will read each project's POM and automatically fetch and add all dependencies to the classpath.