如何将Java项目转换为Maven项目或类似项目 [英] How to convert java project to Maven project or similar

查看:514
本文介绍了如何将Java项目转换为Maven项目或类似项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在创建一个应用程序,可以一次性编译多个Java项目以进行编程分配.由于提交Java项目的方式有很多(例如,作为eclipse项目,作为netbeans项目,作为jar文件),因此有一个类似的插件,您可以轻松地导入或在将Java项目转换为Maven的项目中使用.项目,以便它们都可以以相同的方式进行编译,而不必创建功能来允许程序编译所有不同类型的Java项目?

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?

如果不执行Maven项目,还有另一种方法可以完成我想做的事情吗?

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

推荐答案

在我看来,没有这样的工具可以像这样自由化Java自由项目. Maven基于一些不一定通用的约定.它不仅涉及Java文件的位置,而且还涉及资源的位置(例如,它们可以与Java文件位于同一目录中),其他资产的位置(例如WSDL文件),这些资产是什么,如何处理它们以及如何使用.使用所有这些东西来成功构建最终软件包.我认为没有机会拥有可以做到这一点的通用工具.

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.

我认为这里可以想象的最佳方案是弄清楚有关您必须构建的项目的一些常见假设,例如它们只能包含Java源,而只能包含常规资源.然后,您可以实施一些脚本或程序来扫描这种简化的Java项目,以了解所有这些文件的位置.即使这样,依赖关系又如何呢?您是否应该为它们扫描Eclipse/Netbeans/IDEA特定文件?甚至很难创建使项目足够简单以自动进行改造的这些假设.

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.

正如我说的那样,我真的不相信您可以做的事情比仅仅强制实施已经由Maven管理的项目还要好.

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

这篇关于如何将Java项目转换为Maven项目或类似项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆