Search code examples
androidjavadoc

Auto-generate @version value in javadoc


For the @version tag in javadoc, I use the same value as in BuildConfig.VERSION_NAME. I would like to inject that value, instead of changing every file for each release.

I tried:

* @version {@value BuildConfig#VERSION_NAME}

and

* @version @versionName (and add -tag versionName:a:"2.2.2")

but none of these works.

I could run sed just before the doc gets generated, but I would rather prefer something 'officially' supported.

Any ideas how to solve this?


Solution

  • For the second form, you can put your custom tag at the beginning of a javadoc line.

    /**
     * This is a class of Foo<br/>
     *
     * @version
     *
     * @configVersion.
     */
    

    Then use command javadoc -version -tag configVersion.:a:"2.2.2" to generate your javadoc, the custom tag should be handled in this way. Note the last dot(.) character in custom tag name, as the command javadoc suggests

    Note: Custom tags that could override future standard tags: @configVersion. To avoid potential overrides, use at least one period character (.) in custom tag names.