By default, mvn deploy will only package and deploy class JAR to Nexus. To deploy the source code too, we need to add the following plugin into pom.xml:-
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin>
Now, mvn deploy will deploy both class JAR and source code JAR to Nexus:-
In IntelliJ, when jumping into a class from the JAR, we are given the option to “Download Sources” or “Attach Sources…”.
For some reason, in order for “Download Sources” to work, we need to uncheck “Use Maven3 to import project”.
Now, when we click on “Download Sources”, it will download the sources directly from Nexus and display the source code.
Leave a Reply