Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert java project to Maven project or similar

Tags:

java

maven

I am currently creating an application for compiling multiple java projects in one go for programming assignments. As there are many different ways to submit java projects(e.g. as eclipse project, as netbeans project, as jar file) is there a plugin of something similar that you can easily import or use in a project that will convert a java project to a maven project so they can all be compiled in the same way rather then having to create functionality to allow the program to compile all different types of java projects?

If not to maven projects, is there another way to accomplish what i am trying to do?

like image 610
flexinIT Avatar asked Jun 13 '12 13:06

flexinIT


People also ask

Is Maven project same as Java project?

Many may give just a normal answer like “Maven has the ability to download dependencies automatically based on the dependencies block you put in respective maven project's pom. xml file”. Yes, that's true and its one of the major bonus point of maven based java project.


1 Answers

In my opinion, there is no such tool to mavenize just freestyle Java project just like that. Maven is based on some own conventions that are not necessarily common. It's not just about where Java files are, but also where the resources are (e.g. they can be at a same directory with Java files), where other assets are (e.g. WSDL files), what are these assets, how to handle them and how to use all this stuff to successfully build final package. I think there's no chance to have such universal tool that can do this.

I think the best scenario one can imagine here is to figure out some common assumptions about projects you have to build, e.g. they can only contain Java sources and just regular resources. Then you can implement some script or program that scans such simplified Java project to know where all these files are. And even then, what about dependencies? Should you scan Eclipse/Netbeans/IDEA specific files for them? It's really hard to even create these assumptions that make projects simple enough to auto-mavenize.

As I said, I really don't believe you can do something better than just enforce projects to be already Maven-managed.

like image 162
Michał Kalinowski Avatar answered Nov 15 '22 06:11

Michał Kalinowski