title: Gradle: Attach source and javadoc to local file in IntelliJIdea
body: <p>I am using gradle (v1.9) and IntelliJIdea (v12.1.6). I have a simple java project and a <code>build.gradle</code> file. One dependency is not on maven central, so I have placed the jars in the <code>lib</code> folder.</p>
  
  <h1>Problem</h1>
  
  <p>For the dependencies that are on maven central, gradle builds the library xml files correcly with javadoc and source (located in $project/.idea/libraries). For the local dependency (JNativeHook), no such source or javadoc is attached. As a comparison, the two xml files:</p>
  
  <p><strong>With source and javadoc attachment</strong></p>
  
  <pre><code>&lt;component name="libraryTable"&gt;
    &lt;library name="jackson-core-2.2.3"&gt;
      &lt;CLASSES&gt;
        &lt;root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.3/1a0113da2cab5f4c216b4e5e7c1dbfaa67087e14/jackson-core-2.2.3.jar!/" /&gt;
      &lt;/CLASSES&gt;
      &lt;JAVADOC&gt;
        &lt;root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.3/6021971970a43ae0c22f378cfb5813af869caab/jackson-core-2.2.3-javadoc.jar!/" /&gt;
      &lt;/JAVADOC&gt;
      &lt;SOURCES&gt;
        &lt;root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.2.3/b1c4a6c3c26dfc425efd53c00217868b60d07de9/jackson-core-2.2.3-sources.jar!/" /&gt;
      &lt;/SOURCES&gt;
    &lt;/library&gt;
  &lt;/component&gt;
  </code></pre>
  
  <p><strong>Without source and javadoc attachment</strong></p>
  
  <pre><code>&lt;component name="libraryTable"&gt;
    &lt;library name="JNativeHook-1.1.4"&gt;
      &lt;CLASSES&gt;
        &lt;root url="jar://$PROJECT_DIR$/lib/JNativeHook-1.1.4.jar!/" /&gt;
      &lt;/CLASSES&gt;
      &lt;JAVADOC /&gt;
      &lt;SOURCES /&gt;
    &lt;/library&gt;
  &lt;/component&gt;
  </code></pre>
  
  <h1>Additional information</h1>
  
  <p>The build file looks like this:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'idea'
  idea {
      module {
          downloadJavadoc = true
          downloadSources = true
      }
  }
  
  repositories {
      mavenCentral()
      flatDir(dirs: 'lib')
  }
  
  dependencies {
      // Will be fetched from mavenCentral()
      compile 'com.fasterxml.jackson.core:jackson-core:2.2.3'
      // Will be fetched from the 'lib' directory (see second repository)
      compile 'org.jnativehook:JNativeHook:1.1.4'
  }
  
  sourceCompatibility = 1.7
  version = '0.1'
  jar {
      manifest {
          attributes 'Implementation-Title': 'ScreenShotter',
                     'Implementation-Version': version,
                     'Main-Class': 'de.fau.screenshotter.ScreenShotter'
      }
      from {
          configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
      }
  }
  </code></pre>
  
  <p>My project structure looks like this:</p>
  
  <p><img src="https://abload.de/img/unbenanntlgemu.png"></p>
  
  <h1>Question (tldr;)</h1>
  
  <p>How can I tell gradle to create the appropriate javadoc and source entries and add them to the xml files that IntelliJ uses?</p>