I wrote my little library, commented all the methods and variables.
When I compiled jar, connected it to the project, and decompiled, all comments were gone.
How to create a jar with comments? I know about javadoc generation, I just need comments.
I wrote my little library, commented all the methods and variables.
When I compiled jar, connected it to the project, and decompiled, all comments were gone.
How to create a jar with comments? I know about javadoc generation, I just need comments.
When building a Maven project, there is a special plugin that builds javadoc at build time to add to pom.xml
<dependencies> ... <!-- Maven Javadoc Plugin Javadocs provide documentation that makes it easier for developers to know how to use a particular class. Instead of reading and understanding the actual source code, the developer can use the Javadocs instead to lookup the class attributes and methods. --> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.0.0</version> </dependency> ... </dependencies> use the plugin when building the project
<build> ... <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.0.0</version> <configuration> <docencoding>UTF-8</docencoding> </configuration> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> ... </plugins> </build> add section
<reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.0.0</version> <configuration> <docencoding>UTF-8</docencoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jxr-plugin</artifactId> <version>2.5</version> </plugin> </plugins> </reporting> this will create a documentation jar file. Further Maven it is necessary to specify to load dependences with the documentation, in Ideas in ideas it looks like this 
A similar plugin is to build an archive with the code maven-source-plugin. See the Maven documentation for details.
Source: https://ru.stackoverflow.com/questions/943978/
All Articles