Search code examples
javamavenjavadoc

How to set maven version to the @version tag in Javadoc?


I want to use the javadoc plugin to generate the Java Documentation. The @version should be the Projekt Version but I can't get it to work.

This is my pom file:

...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <defaultAuthor>Meeresgott</defaultAuthor>
                    <defaultVersion>${project.version}</defaultVersion>
                    <version>true</version>
                    <author>true</author>
                </configuration>
                <executions>
                    <execution>
                        <id>javadoc</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
...

But the version tags don't shows up at any point. Is there some tag that i should place in the commentate section in the java class?

Something like:

/**
*
* @version <useMavenVersion>
**/

public class MyClass {


}

Solution

  • Thanks! With this configuration it works!

    First you have to run this command: "mvn javadoc:fix" After that you can build your javadoc as normal with "mvn install" or "mvn javadoc:jar"

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.1.1</version>
                    <configuration>
                        <defaultAuthor>Meeresgott</defaultAuthor>
                        <defaultVersion>${project.version}</defaultVersion>
                        <version>true</version>
                        <author>true</author>
                    </configuration>
                    <executions>
                        <execution>
                            <id>update</id>
                            <goals>
                                <goal>fix</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>javadoc</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>