I need to keep in sync the @version
tag of all class Javadocs in my projec开发者_运维知识库t, as well as the @author
tag. However I don't know an easy way to do this.
Is there a plugin (preferably a maven plugin) that could accomplish this? And no, the maven-release plugin will not do this for me.
The way I use @version
is, in conjunction with @since
. IMHO, I think @version
represents version of software when this class was modified and @since
represents the version of the software when this file/class was created.
On @author
, my policy is each developer who has ever contributed to that class (in some major way) should append his/her name.
So, if you see all these processes are manual and need to be done by Class creator/modifier at the time of coding. And, obviously you will have unequal version of files. And, I guess that makes sense.
I would like to listen if someone differs on this.
Of course there's a maven way to do it, but it's very unusual:
define your src/main/java folder as <resource>
, with a fixed outputDirectory. Then reconfigure javadoc and jar plugins, something like this:
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<targetPath>sources</targetPath>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<sourcepath>${project.build.outputDirectory}/sources</sourcepath>
</configuration>
<!-- other config stripped -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<configuration>
<excludes>
<exclude>sources/**</exclude>
</excludes>
</configuration>
<!-- other config stripped -->
</plugin>
</plugins>
</build>
Now you can use placeholders in your source files and interpolate them with maven properties (see maven filtering for reference)
精彩评论