Added packageName annotation element.

This commit is contained in:
Erik C. Thauvin 2017-04-26 11:19:01 -07:00
parent 2810a402b0
commit c65c0033e2
4 changed files with 19 additions and 13 deletions

View file

@ -113,13 +113,14 @@ Please also look at this [example](https://github.com/ethauvin/mobibot/blob/mast
The following annotation elements and properties are available: The following annotation elements and properties are available:
Element | Property | Description | Default Element | Property | Description | Default
:------------|:---------------------|:----------------------------------|:---------------- :-------------|:---------------------|:----------------------------------|:-------------------------
`project` | `version.project` | The project name. | `project` | `version.project` | The project name. |
`major` | `version.major` | The major version number. | `1` `major` | `version.major` | The major version number. | `1`
`minor` | `version.major` | The minor version number. | `0` `minor` | `version.major` | The minor version number. | `0`
`patch` | `version.patch` | The patch version number. | `0` `patch` | `version.patch` | The patch version number. | `0`
`preRelease` | `version.prerelease` | The pre-release version. | `preRelease` | `version.prerelease` | The pre-release version. |
`buildMeta` | `version.buildmeta` | The build metadata version. | `buildMeta` | `version.buildmeta` | The build metadata version. |
`packageName` | | The package name. | _Same as annotated class_
`className` | | The name of the generated class. | `GeneratedVersion` `className` | | The name of the generated class. | `GeneratedVersion`
`properties` | | The properties file. | `properties` | | The properties file. |
`template` | | The template file. | `version.mustache` `template` | | The template file. | `version.mustache`

View file

@ -62,6 +62,8 @@ public @interface Version {
int patch() default Constants.DEFAULT_PATCH; int patch() default Constants.DEFAULT_PATCH;
String packageName() default Constants.EMPTY;
String patchKey() default Constants.KEY_VERSION_PATCH; String patchKey() default Constants.KEY_VERSION_PATCH;
String preRelease() default Constants.EMPTY; String preRelease() default Constants.EMPTY;

View file

@ -78,6 +78,7 @@ public class VersionInfo {
preRelease = version.preRelease(); preRelease = version.preRelease();
project = version.project(); project = version.project();
className = version.className(); className = version.className();
packageName = version.packageName();
} }
/** /**

View file

@ -156,7 +156,9 @@ public class VersionProcessor extends AbstractProcessor {
final PackageElement packageElement = (PackageElement) enclosingElement; final PackageElement packageElement = (PackageElement) enclosingElement;
try { try {
final VersionInfo versionInfo = findValues(version); final VersionInfo versionInfo = findValues(version);
if (version.packageName().equals(Constants.EMPTY)) {
versionInfo.setPackageName(packageElement.getQualifiedName().toString()); versionInfo.setPackageName(packageElement.getQualifiedName().toString());
}
note("Found version: " + versionInfo.getVersion()); note("Found version: " + versionInfo.getVersion());
final String template; final String template;
if (version.template().equals(Constants.DEFAULT_JAVA_TEMPLATE) && if (version.template().equals(Constants.DEFAULT_JAVA_TEMPLATE) &&