/*
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2011-2018, Sebastian Staudt
 */

package com.github.koraktor.mavanagaiata.mojo;

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;

import com.github.koraktor.mavanagaiata.git.GitRepository;
import com.github.koraktor.mavanagaiata.git.GitRepositoryException;
import com.github.koraktor.mavanagaiata.git.GitTagDescription;

/**
 * This goal provides the most recent Git tag in the "mavanagaiata.tag" and
 * "mvngit.tag" properties.
 *
 * @author Sebastian Staudt
 * @since 0.1.0
 */
@Mojo(name = "tag",
      defaultPhase = LifecyclePhase.INITIALIZE,
      threadSafe = true)
public class TagMojo extends AbstractGitMojo {

    /**
     * This will first read all tags and walk the commit hierarchy down from
     * HEAD until it finds one of the tags. The name of that tag is written
     * into "mavanagaiata.tag" and "mvngit.tag" respectively.
     *
     * @throws MavanagaiataMojoException if the tags cannot be read
     */
    public void run(GitRepository repository) throws MavanagaiataMojoException {
        try {
            GitTagDescription description = repository.describe();
            String describe = description.toString();
            if (dirtyFlag != null &&
                    repository.isDirty(dirtyIgnoreUntracked)) {
                describe += dirtyFlag;
            }

            addProperty("tag.describe", describe);
            addProperty("tag.name", description.getNextTagName());
        } catch(GitRepositoryException e) {
            throw MavanagaiataMojoException.create("Unable to read Git tag", e);
        }
    }

}

@@ -622,19 +622,293 @@
 erties.%0A
+ * This goal provides the most recent Git tag name in the%0A * %22mavanagaiata.tag.name%22 and %22mvngit.tag.name%22 properties. Additionally,%0A * more exact information as per %7B@code git describe%7D is provided in the%0A * %22mavanagaiata.tag.describe%22 and %22mvngit.tag.describe%22 properties%0A
  *%0A
-
  * @auth
@@ -1274,24 +1274,29 @@
 nagaiata.tag
+.name
 %22 and %22mvngi
@@ -1300,16 +1300,21 @@
 ngit.tag
+.name
 %22 respec
@@ -1321,16 +1321,169 @@
 tively.%0A
+     * %3Cp%3E%0A     * A more canonical representation as per %7B@code git describe%7D is stored%0A     * in %22mavanagaiata.tag.describe%22 and %22mvngit.tag.describe%22.%0A
      *%0A 

Fix documentation of the tag mojo