Update Javadoc version and author across all files?

与世无争的帅哥 提交于 2019-12-24 16:24:43

问题


I need to keep in sync the @version tag of all class Javadocs in my project, 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.


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/4557747/update-javadoc-version-and-author-across-all-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!