Maven – Always download sources and javadocs
Open your settings.xml file ~/.m2/settings.xml
(create it if it doesn't exist). Add a section with the properties added. Then make sure the activeProfiles includes the new profile.
<settings>
<!-- ... other settings here ... -->
<profiles>
<profile>
<id>downloadSources</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>downloadSources</activeProfile>
</activeProfiles>
</settings>
Edit: As mentioned by Jingguo Yao, this works with Eclipse IDE only - the same can also be configured in your IDE of choice. In Elcipse via Window -> Preferences -> Maven menu, though this probably has to done at every workspace level and for fresh Eclipse installations.
Alternatively configure the maven-dependency-plugin in your pom.xml in a separate profile and run it as required - keeping it in the main build will lead to build times (needlessly elongating (not to mention space) at places like your build nodes that don't need either sources or java docs. Preferable this should configured in some org or division parent pom.xml, otherwise it has be repeated everywhere in different places
Disabling Download sources and javadoc in eclipse
Someone already filled a bug at Eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=576112
Apparently, it's fixed in M2E, but not yet released. Though, you can update on the latest snapshot as explained here:
https://github.com/eclipse-m2e/m2e-core/issues/252#issuecomment-926379620
It solved the issue for me.
Until the release in Eclipse, you must add this update-site:
https://download.eclipse.org/technology/m2e/snapshots/1.18.3/latest/
Accoriding to @Nis this is now released in the standard Eclipse update-site, so you don't need to add the preceding update-site anymore
How to download sources for a jar with Maven?
2020 Update:
The maven dependency plugin should be used whit the dependency:sources
goal:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>download-sources</id>
<goals>
<goal>sources</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
This can also be run from the command line as:
mvn dependency:sources -Dsilent=true
Executing mvn dependency:sources
will force maven to download all sources of all jars in the project, if the sources are available (are uploaded in the repository where the artifact is hosted). If you want to download javadoc the command is mvn dependency:resolve -Dclassifier=javadoc
Deprecated:
It's also possible to create a profile in your settings.xml file and include the following properties:
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
Eclipse|Maven: Can't download source code of jar package?
I believe that you are using an embedded version of maven.
There are two items you need to check:
- Check if the options in Eclipse are selected as screen bellow
The second approach is to select an external installation of maven.
Take a look in the screenshot bellow. I'm using an external installation of maven.
In the second approach maven will read the settings.xml of external installation.
How to force IntelliJ to download javadocs with Maven?
Click on the "maven projects" (make sure tool buttons are on) on the right side of intelij and then click on "Download Documentation".
Also, for future downloading you can go to the File -> Settings -> Build,execution, deployment, -> build tools -> Maven -> importing -> mark "Documentation" checkbox and apply settings
Related Topics
Getting the Class Name from a Static Method in Java
Java - How Would I Dynamically Add Swing Component to Gui on Click
What Is a Difference Between <? Super E> and <? Extends E>
How to Change the Intellij Idea Default Jdk
How to Make My String Comparison Case-Insensitive
List Versus Arraylist as Reference Type
Why Java Polymorphism Not Work in My Example
What Happens When a Duplicate Key Is Put into a Hashmap
Regex to Split Camelcase or Titlecase (Advanced)
Date Format Mapping to JSON Jackson
Allowing Java to Use an Untrusted Certificate for Ssl/Https Connection
Why Not to Start a Thread in the Constructor? How to Terminate
Aggregation Versus Composition
Spring Boot - Cannot Determine Embedded Database Driver Class for Database Type None
Difference Between @JSONignore and @JSONbackreference, @JSONmanagedreference