39

We are using maven and git together for a Java project. In <scm> section, <tag> is automatically added by release plugin.

For example,

  <scm>
          <connection>scm:git:http://myserver:7990/scm/project/test.git</connection>
          <tag>releaes-tag</tag>
  </scm>

What does <tag> represent here?

I believe the normal convention is <tag>HEAD</tag>.

When we were using subversion, maven never used <tag></tag>

What is the meaning of <tag></tag>?

I searched google and maven documentation but I cannot find any information on it.

Andrew Swan
  • 13,427
  • 22
  • 69
  • 98
mjlee
  • 3,374
  • 4
  • 27
  • 22

1 Answers1

35

The <tag> element is used by release:prepare to specify the tag that was created for this release (implemented as MRELEASE-723). Outside of a release it is essentially a placeholder, and HEAD is an appropriate value.

When we were using subversion, maven never used <tag></tag>

As MRELEASE-723 explains:

when I invoke release:prepare with a URL like: https://example.test/svn/REPO/myproject/branches/release it will be replaced by https://example.test/svn/REPO/myproject/tags/myproject-1.0 which is fine because now you know which revision to checkout for building the release.

The <scm> element for a release build should contain enough information to check out the tag that was created for this release.

Subversion allows the tag to be included in the connection URL. Neither Git nor Mercurial allow this, so the <tag> element is used instead.

peterh
  • 18,404
  • 12
  • 87
  • 115
Joe
  • 29,416
  • 12
  • 68
  • 88
  • 5
    But on a branch (snapshot version of the artifact) I can simply remove the `HEAD` right? And have it just set automatically on the maven release for the release tag. Or does it always add it back to HEAD after a release? – Alexander Klimetschek Sep 30 '14 at 00:15
  • Perhaps I'm just thick but I still don't understand the need for *automated* adding of `` in the `` section. I tend to remove it when I see it but it keeps popping back. – peterh Oct 09 '16 at 09:23
  • So, the value of `` is uniquely chosen when running the `release:prepare` goal (the user is prompted for it). And afterwards the goal is sticking such value into the `pom.xml` under `/` just to store this information? – Johan May 08 '17 at 15:18
  • 5
    The reference for the [technical maven project descriptor](https://maven.apache.org/ref/3.5.0/maven-model/maven.html#class_scm) (i.e. the technical specification of the POM file) states that the default value for the `` element is indeed `HEAD`, so that's what is assumed when you don't specify the tag (just like `jar` is the default for the `` element). – Christian Sep 17 '17 at 13:47