51

I click "download sources and documentation" in Intellij Idea Community Edition 12.1.4 and get error that sources can not be downloaded. But when I try:

mvn dependency:sources

All sources are downloaded.

What is the problem?

P.S. I have checked that Idea use the same maven that use in console. There are not any "off line" mode buttons triggered in Idea.

Cherry
  • 31,309
  • 66
  • 224
  • 364
  • Try to get more information from your IDE. The error "sources can not be downloaded" isn't helpful. – Aaron Digulla Sep 13 '13 at 07:41
  • 2
    It might be worth looking what .IntelliJIdea12\system\log\idea.log says when you attempt to download a source. Do you need to setup a proxy in IntelliJ so that it can download sources from external maven repository ? – Ashutosh Jindal Sep 13 '13 at 11:15
  • @AshutoshJindal good call, sounds like a proxy issue. – vikingsteve Sep 13 '13 at 19:05
  • .IdeaIC12\system\log\idea.log does not contains any error or log information about error. I checked it after get an error and no thing changes. What do you mean by proxy issue? dependency:sources work correct but I did not configure any proxy with maven. Where I can see maven configuration about that and where I must put/copy analog configuration parameters to intellij idea? – Cherry Sep 18 '13 at 12:04
  • Please mark ingara's answer as correct. Confirmed with IDEA 13.1.3 – Leszek Gruchała Jun 04 '14 at 13:55

10 Answers10

64

In Intellij 2017.x, 2016.x, 15.x, 14.x the given solution does not work as the option is removed.

The problem can be solved by changing JDK for Importer to a latest JDK instead of User Internal JRE which was 1.6.0 by default on Mac

The setting JDK For Importer can be found in:

Preferences -> Build, Execution,Deployment -> Build Tools -> Maven -> Importing

Chakra
  • 1,260
  • 1
  • 14
  • 12
29

Running IDEA version 12.1.6 and I have the same issue.

When I uncheck the following option it does work:

Settings > Maven > Importing > Use Maven3 to import project

Shiva
  • 6,677
  • 4
  • 36
  • 61
ingara
  • 471
  • 5
  • 9
16

I had the same issue with IntelliJ IDEA 2016.1.3 and Maven 3.2.1. No solution mentioned here was working. In my case a newer Maven version fixed the issue. With Maven 3.3.9 IDEA can now download the sources.

xtermi2
  • 470
  • 5
  • 10
  • 1
    I am using IntelliJ IDEA community version 2016.2 and also maven 3.3.9, but it is still not always working. When I hit "Download Source", status bar shows "Downloading maven sources", but after download is completed, it doesn't jump to the source code. I hit "Download Source" once again but remains the same. I have to restart IDEA to make it work. – Bruce Sun Aug 01 '16 at 04:41
  • 1
    Fixed it for me, I changed the bundled maven which was at version 3.0.5 to version 3.3.9 and it worked. – jgeerts Sep 01 '16 at 14:19
  • Worked for me as well after I switched to the version that is maintained by brew, which is 3.3.9 as of today. I had to restart IDE to make sure it works – Maksim Sep 19 '16 at 18:49
  • In my case I had to change "Maven Home Directory" in IDEA settings. It was pointing to the old version that didn't exist. – Slava Semushin Sep 23 '16 at 21:25
6

"I had the same issue with IntelliJ IDEA 2016.1.3 and Maven 3.2.1. No solution mentioned here was working. In my case a newer Maven version fixed the issue. With Maven 3.3.9 IDEA can now download the sources."

anything's already in the former answers...

  • download sources in your repo mvn dependency:sources
  • F4 on the class you want to check the sources out
  • locate the source jar in your local repository

maybe it is not a full IDE solution, but hope it solves your issue

kj6682
  • 71
  • 1
  • 2
  • In some reason clicking on "Download Sources" in IntelliJ didn't open the sources for me automatically, so clicking on "F4" opened the sources, thanks. But it's weird that previously I didn't need to press F4... – AbstractVoid Mar 16 '21 at 17:13
4

Had the same issue with IntelliJ 2016.2.4. As user526177 posted udating the Maven version fixes it but for my needs switching to the bundled Maven 2 was just fine and fixed the issue.

Screenshot (can't embed yet due to rank)

Kwyjibo
  • 41
  • 2
  • Switching to Maven2 (bundled) was the only thing that worked for me... with latest Maven installed (Maven 3.3.9) and IntelliJ Ultimate 2016.3.2. – Renato Jan 10 '17 at 14:48
3

I use IDEA 2017.1.3, I just change the Maven home directory option(Preferences -> Build, Execution,Deployment -> Build Tools -> Maven -> Maven home directory) of default Maven 3 to Maven 2, I believe it's the same solution for newer version of IDEA just like the selected answer. And it works for me.

1

I had this issue, and sources weren't being downloaded since I needed credentials from my project's specific settings.xml.

To fix (Intellij 2018.1.2):

File -> Settings -> Build, Execution, Deployment -> Maven

and provide the appropriate settings.xml in the 'User settings file' section

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • A custom settings.xml was my problem too. Once I removed it (temporarily), intellij was able to download source documentation. – jmrah Jun 13 '18 at 14:21
0

I solve this by use jdk 1.8 in MAVEN -> RUNNER -> JRE .my idea version is 2016.2

mark
  • 1
0

I changed the java version in pom.xml to match my jdk's version and it worked for me.

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

     <!--earlier this was 1.8-->
    <java.version>10</java.version>

</properties>
0

It's necessary to check availability of repositories.

For example, if you use corporate repository but don't use VPN just right now. In this case maven can't download sources (of open-source project) if one of your repositories isn't accessible.

You can comment specific <repository> in your pom.xml file.

Oleg Poltoratskii
  • 667
  • 11
  • 10