Newbie question about maven

可紊 提交于 2019-12-12 22:18:40

问题


Is it true that the only configuration file I need to bother with is pom.xml ?

It seems to me that Java guys live xml more than any other stuff,is that true?


回答1:


Maven uses XML for POM files because XML is a good choice for describing things ... and a POM file is a description of a project. I supposed that the Maven implementors could have invented a custom language, but then lots of people would have complained about having to learn another language syntax.

It would make no sense to express Maven POM files in some kind of scripting language because they are not "scripts" in any recognizable sense.

It seems to me that Java guys live xml more than any other stuff,is that true?

No. "Java guys" use all sorts of technologies for configuring things: XML, JSON, properties files, databases, bespoke languages, you name it someone has used it.

If your problem is that you hate using XML, either:

  • get over it,
  • get an editor that hides the XML syntax from you,
  • use (shudder) Make,
  • use (whimper) build scripts written in some clunk old scripting language, or
  • go away and implement a better solution.

But I'll stick with Maven, thanks.




回答2:


Is it true that the only configuration file I need to bother with is pom.xml ?

Yes, Maven uses a pom.xml file to describe a project's medata and extend Maven's behavior, which also known as the Project Object Model (POM) file.

Maven will also look by default for a per user configuration file in ~/.m2/settings.xml but this file is optional.

Why doesn't maven use scripts for this kind of job, I don't see xml has any advantage here, which is why I don't like ant

What should Maven have used in 2002 if not XML? Makefiles? In my opinion, XML was and still is a very decent choice for a declarative Project Object Model. Yes XML is verbose but it is perfect for the job and allows to benefit from nice things like validation, transformation, code completion which seem important to me.

Now, nothing forces you to use Maven if you don't like it and feel free to use Gradle or Gant or Buildr (if the size of their communities is not a concern).

Just in case, note that Maven 3 offers polyglot support (see this post and this one) but as I said, writing a pom in Groovy, YAML, etc doesn't only have advantages (e.g. validation).




回答3:


You probably want to give some attention to the settings.xml file too. However, for the most part you are correct, everything is in the pom.xml



来源:https://stackoverflow.com/questions/2808051/newbie-question-about-maven

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!