Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in Starting with Maven

 
Kulpreet Singh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have to use Maven as a build tool for my existing project. I need help in understanding that, i have limitation that i cannot modify the structure of project to what maven provides.

What all i have read till now it says that i have to move my source files to Maven structure and then can write my POM file. Is this a limitation of Maven or i can write my POM file with existing structure?

Will appreciate any help!!

Thanks,
Kulpreet
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you cannot modify the structure?

Although maven (some goals at least) requires a set structure?

Sounds like a conundrum to me.

It would help if we knew a little more about your project.

WP
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resist the urge to bend Maven to your will. Even though you can redefine where things are located, not all plugins will recognize the new locations. Besides, one of the perks of Maven is that every project looks the same and is built the same way. Well, at least until you get into very complex projects that invoke a lot of specialty plugins, but even then you can define project types and every project of that type can look the same. My recommendation is to reformat the project, possibly breaking it up into multiple projects, to fit the Maven best practices. I spent the last half of last year doing this for a dozen projects, which turned into about 20 projects by the time I got done. But everyone is happier with the results than what we they before (it was pretty much managed chaos).

If you are still set on breaking Maven, you will have to pay close attention to the properties available for every plugin goal. You will also have to know the pom.xml structure inside and out. Between the pom.xml settings and the plugin properties, you should be able to relocate almost anything. I highly recommend that you do not attempt this until you are very familiar with how Maven works and have spent some time building things the maven way. If you are new to Maven, don't even think about trying it.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Kulpreet!

Probably Maven's 2 biggest strengths are that it automatically downloads dependencies and that it standardizes project structure, and you have apparently been commanded to discard one of those primary strengths.

As Peter has pointed out, attempting to force a non-Maven structure on Maven is tedious, difficult and error-prone. In business terms, it's expensive. Expensive to set up, expensive to maintain, and the project itself is more expensive to use, since unlike "real" Maven projects, you won't be able to just hand it to anyone anywhere and expect them to be able to instantly know where all the pieces are.

Although I'm not the biggest fan in the world of how Maven lays things out, it does work and it works well. And even if someday Maven goes away, the project organization still works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic