开发者

Newbie question about maven

开发者 https://www.devze.com 2022-12-29 16:52 出处:网络
Is it true that the only configuration fi开发者_Go百科le 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? Maven uses XML for POM files

Is it true that the only configuration fi开发者_Go百科le 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?


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.


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).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号