Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are tag comments good for in pom.xml?

Tags:

maven

I'm currently going through https://spring.io/guides/gs/maven/#scratch and I just found

<dependencies>
    <!-- tag::joda[] -->
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.9.2</version>
    </dependency>
    <!-- end::joda[] -->
    <!-- tag::junit[] -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- end::junit[] -->
</dependencies>

and I wonder:

What is <!-- tag::joda[] --> good for?

like image 664
Martin Thoma Avatar asked Jun 27 '17 13:06

Martin Thoma


People also ask

How do you comment in POM xml?

Rules for adding XML commentsDon't use a comment before an XML declaration. You can use a comment anywhere in XML document except within attribute value. Don't nest a comment inside the other comment.

What is the difference between plugin and pluginManagement tags?

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.

Why POM xml is important?

A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.


1 Answers

The Getting Started Guide you are reading, is generated from an AsciiDoc file:

https://github.com/spring-projects/spring-boot/blob/master/README.adoc

AsciiDoc is a document format equivalent to DocBook XML. Instead of copy-pasting part of the source code, the AsciiDoc syntax allows to point to some parts of the source code.

To include a part of the pom.xml you can use the following syntax:

include::complete/pom.xml[tag=joda]

which will include the snippet:

<!-- tag::joda[] -->
<dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
    <version>2.9.2</version>
</dependency>
<!-- end::joda[] -->

To answer you question, <!-- tag::joda[] --> is a marker allowing AsciiDoc to extract a part of the file and inserting it into the getting started guide.

like image 125
Ortomala Lokni Avatar answered Sep 28 '22 06:09

Ortomala Lokni