This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes How to mavenize a project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to mavenize a project" Watch "How to mavenize a project" New topic
Author

How to mavenize a project

Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
I am from an Ant background and was planning to move towards using Maven.

I was able to get a lot of info on how to create a new project in Maven but how do you convert an existing project to use Maven ?
Sunil Tiwari
Ranch Hand

Joined: Sep 19, 2006
Posts: 49

Hi Jay,

There are various tutorials available on the Internet for the same.

Try checking out the official one at http://maven.apache.org/maven-1.x/using/migrating.html

If you need some specific information, please feel free to put a reply post!

Sunil


~ Neil (SCJP)
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Sunil posted a link to a Maven 1 tutorial. Don't use Maven 1, use Maven 2 (or 3) instead.

The best thing to do is first learn how Maven works, build a few simple projects from scratch using it, and then decide how best to migrate your Ant builds to Maven.
If you read th
e other posts for the last day or two you will already have seen this link to some really good Maven books:
http://www.sonatype.com/books/maven-book/


JBoss In Action
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Out of topic, I've recently started with Gradle (combined the best of both Ant and Maven), looking good so far...


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Sunil Tiwari
Ranch Hand

Joined: Sep 19, 2006
Posts: 49

Yup, that was a quick search and paste link process

We too moved to Gradle and its looks cool!
Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
This URL defines my issue with understanding Maven
http://stackoverflow.com/questions/1163173/why-use-gradle-instead-of-ant-or-maven

Maven takes the opposite approach and expects you to completely integrate with the Maven lifecycle. Experienced Ant users find this particularly jarring as Maven removes many of the freedoms you have in Ant.


@Peter I saw the Maven book and somehow decided that it wasn't the right start. Now working on the book, building something from scratch to get a feel of things.

But I still feel Maven is too restrictive as compared to Ant.
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 423

Yes, that was also the first thing I was thinking, when I had a look at Maven. "Why the heck should I do it the Maven way?" And I was at that time also quite happy with Ant. But in my experience those restrictions are more helpful than harmful. Whenever I check out some sources of an open source project and it's using Maven, I usually just type mvn:compile on the console and that's it. I know the structure of the project and know where to look for the most important files. No need to try to look inside the brain of another developer who is using a structure that he defines "best".
Dependency management CAN get quirky with Maven. Don't know how it compares to Ivy. But all in all I'm quite happy with Maven. First I was hating it, then I was using it and now I'm loving it. Give it a few months a try. You can always switch back to Ant after that, if you feel like.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Use the right tool for the right purpose. Maven is a black box that does many things extremely well, provided you can find a plugin that does what you want. For anything else I use Ant because I can get Ant to do just about anything without having to resort to writing a plugin, and I have used Ant for some fairly strange things (e.g. scheduled backups, building release images of a fairly large software stack).

However, now that I have used Maven, even the Java projects for which I use Ant have the Maven directory structure. Or a slightly modified form thereof. Check out the build scripts for JBoss in Action.
Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 183
I got a couple of examples from the Maven site up and running but I am still unsure as to how I should go about refactoring an existing project (Eclipse-RAD 7.5) to allow a Maven build.

My project structure is listed below.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15639
    
  15

2 projects, 2 Maven pom.xml files, one in the root of each project. The EAR project should include the Web project as a dependency.

Java code goes in src/main/java. Static web content goes in src/main/webapp, which models the static part of the WAR/EAR. You might want to double-check on the directory structure for EAR, though. Just look for the EAR plugin in the Maven (version 2 or later) docs.

That will take care of the bulk of the mavenization process.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to mavenize a project
 
Similar Threads
Debugging Help
Maven target folder is empty when using Eclipse M2 plugin
DEBUG MAVEN PROJECT IN ECLIPSE
Maven change project setup m2eclipse
Libraries not visible under projects java build path in eclipse