lundi 23 juillet 2018

Get annotations when exec-maven-plugin runs Main does not work

I would like to run a Main class with exec-maven-plugin and from my dependencies generate documentation like a swagger file.

The annotation that I care is javax.ws.rs.Path which has @Retention(RetentionPolicy.RUNTIME)

My Java code

final Class<?> clazz = loadClass
isAnnotationPresent(clazz); 

public static boolean isAnnotationPresent(final AnnotatedElement annotatedElement) { 
  ...  annotatedElement.getAnnotations().length  --> 0
  ...  clazz.getMethods().length() ---> works !
}

My pom.xml

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.6.0</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>java</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <executable>java</executable>
                        <workingDirectory>XXXXXXXXXXXXXXXXXXX</workingDirectory>
                        <addResourcesToClasspath>true</addResourcesToClasspath>
                        <additionalClasspathElements>true</additionalClasspathElements>
                        <includeProjectDependencies>true</includeProjectDependencies>
                        <includePluginDependencies>true</includePluginDependencies>
                        <includeProjectDependencies>true</includeProjectDependencies>

                        <mainClass>XXX.Main</mainClass>
                    </configuration>
                </plugin>





Aucun commentaire:

Enregistrer un commentaire