我正在使用gradle(v1.9)和IntelliJIdea(v12.1.6)。我有一个简单的java项目和一个build.gradle
文件。有一个依赖不在maven中央仓库,所以我把这些jar包放到了lib
文件夹中。
问题
对于那些在maven中央仓库的依赖项,gradle会正确地构建带有javadoc和源代码的库xml文件(位于$project/.idea/libraries)。对于本地依赖(JNativeHook),没有附加源代码或javadoc。作为比较,这两个xml文件:
带有源代码和javadoc附件
<component name="libraryTable">
<library name="jackson-core-2.2.3">
<CLASSES>
<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!/" />
</CLASSES>
<JAVADOC>
<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!/" />
</JAVADOC>
<SOURCES>
<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!/" />
</SOURCES>
</library>
</component>
没有源代码和javadoc附件
<component name="libraryTable">
<library name="JNativeHook-1.1.4">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/JNativeHook-1.1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
额外的信息
构建文件如下所示:
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) }
}
}
我的项目结构如下:
问题(简短版)
我该如何告诉gradle创建适当的javadoc和源代码条目,并将它们添加到IntelliJ使用的xml文件中?