Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to mavenize a project

 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
Clojure Redhat Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Out of topic, I've recently started with Gradle (combined the best of both Ant and Maven), looking good so far...
 
Sunil Tiwari
Ranch Hand
Posts: 49
Clojure Redhat Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup, that was a quick search and paste link process

We too moved to Gradle and its looks cool!
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic