apache / apache/maven-plugin-tools
[MPLUGIN-426] Description annotation for Mojo and Parameters
- Dominant language
- Java
- Stars
- 64
- Forks
- 71
- Avg merge
- 12h 24m
- Merged PRs (30d)
- 32
Description
**[Benjamin Marwell](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mampf86)** opened **[MPLUGIN-426](https://issues.apache.org/jira/browse/MPLUGIN-426?redirect=false)** and commented
Hey all!
## Overview
This is actually reopening https://issues.apache.org/jira/browse/MPLUGIN-247 which was closed as won't fix.
I tried to implement a kotlin parser, but it is really hard to do so, because you cannot reuse any of the Methods from JavaAnnotationsParser.
That said, someone used messy reflections for this: https://github.com/random-maven/maven-plugin-tools-annotations/blob/35371c19004622645f87c35c2317a7c860b924a5/src/main/java/com/carrotgarden/maven/tools/Extractor.java#L57-L67
Trying this without reflection will lead you to iterate over files again and again (here's a barebone): https://github.com/bmarwell/maven-plugin-tools-kotlin-extractor/blob/main/src/main/java/org/apache/maven/tools/plugin/extractor/kotlin/KotlinKdocExtractor.java#L80-L87
Tamas' request was to have one extractor per JVM language in a separate project. But due to his current API changes, this would be a lot of work to do! https://github.com/apache/maven-plugin-tools/commit/ba8eb2dc52fb406f9e3897c9577f0bf0d4b0f0fc especially you'd have to mantain multiple versions (<3.7, >= 3.7).
## Downsides of custom extractors
1. Setting up as a user is complicated, see this example:
```java
org.apache.maven.plugins
maven-plugin-plugin
com.carrotgarden.maven
maven-plugin-tools-annotations
[1,2)
bintray
java-annotations-extra
```
1. More dependencies to update!
2. You need two versions: One for plugin-tools <3.7 and one for plugin tools >=3.7 due to API incompatiblity (new interface methods without defaults).
## Alternative: Provide `@Description` annotation
That said, just adding a description mojo with fields "description", "since", "deprecated" would be the easiest way to solve this. It is easily backwards compatible (just use javadoc if no annotation is present) and it is similar to what OpenAPI annotations do - they do not parse javadoc either. Besides, Javadoc can have a different level of detail comparing to the Mojo Descrption. So a separation might be feasible after all!
This enables plugins written in scala, kotlin and groovy (and any fancy language for the JVM in the future) to be written with full documentation, without requiring maven-plugin-plugin to have per-language extension and source code parser dependency.
---
**Affects:** 3.4, 3.5.2, 3.6.4
**Issue Links:**
- [MPLUGIN-247](https://issues.apache.org/jira/browse/MPLUGIN-247) Allow getting mojo/parameter description/since/deprecated from annotations
(_**"supercedes"**_)
**Remote Links:**
- [GitHub Pull Request #152
](https://github.com/apache/maven-plugin-tools/pull/152)
1 votes, 6 watchers
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.