Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] existing eclipse web project to maven

On 09/27/2011 10:23 AM, Mike Lee wrote:
I have an existing eclipse web project with no maven pom or anything. I just installed maven and m2. I created a basic pom.xml. All I want to do is make my existing eclipse project 'mavenized' so I can build it outside of eclipse. I have literally about 50 jars in the WEB-INF lib and just want to import them as is into the pom. I also don't know how to make it build a war. I tried to do that Configure-Configure eclipse for maven or whatever the option was in m2 and it just hosed up my eclipse project (says something about a facet yet won't let me drill down).

How do I do this?
There is literally NO documentation. It all sends you to that eclipse encyclopedia page or whatever which just describes what m2 does and has a link to a troubleshooting FAQ. There is a video that shows how to import jetty. Ok. That's nice.
I am not a maven expert but I have worked with it a while ago and understand the jist. I have less than one day or I'm moving back to ANT.
Michael Lee

m2e-users mailing list

I have been in your shoes. In fact, I've asked the same question here, and was told by some experts, "impossible", "forget it", "start over", "Learn Maven from the ground up". I think such advice by the maven community is like shooting itself in the foot. Use should be encouraged, not discouraged.

However, I'll agree that one day is aggressive. You realistically need more.

Here are some questions:
1) How important is it to you to maintain source code history? If not, if you can just copy existing source to new source control projects, it will be much easier.

2) Is it really one big app with 50 jars? Or are there "modules" you want to reuse elsewhere? If you don't want to gain reuse for sub-modules this will go a lot easier.

Assuming that you don't care about maintaining a link to source control history and you don't have a lot of modules, I don't see this as impossible.

I agree with the person who said, start with the web app archetype.

Then copy all of your source code to the appropriate maven package directory structure. Of course, you'll have bazillions of errors. Just start knocking em out one by one. You know what jars you need. Hopefully you know the versions as well. Just start adding dependencies. The rule of thumb is, if you import it in your source, it's a dependency you should add. If it's required by a dependency, but not directly in your source (a transitive dependency), then let Maven take care of it.

If you think a jar might be a runtime dependency rather than a compile time dependency err on the side of runtime at first. You can always make it compile-time later.

When it finally builds without errors, start looking for dependency conflicts and try to get rid of them. The dependency hierarchy view will flag such.

There may be a few things you can't get from Maven Central. Generally these exceptions are documented. Google is your friend.

Now fire the thing up and see what you've broken.  Rinse and repeat.

It might take you a week or two. It's time well spent. Go for it. Because once you're done you will UNDERSTAND the mess of spaghetti you've inherited. If your management can't see the value of that, they're idiots.

And good luck!

Back to the top