[英]How do I define the source location for a file based dependency in gradle
我有一个gradle构建脚本,它定义了文件依赖性。
dependencies {
testCompile files('lib/test/wibble-1.0.jar')
}
我有一个要添加到依赖项的库的源jar,以便在eclipse中可以导航到源。 如何将该信息添加到依赖项?
为未从Maven存储库解析的工件添加源Jar时,需要对eclipse.classpath
一些脚本编写(请参阅Gradle Build Language Reference中的EclipseClasspath
)。 它可能看起来像这样:
import org.gradle.plugins.ide.eclipse.model.*
eclipse {
classpath {
file {
whenMerged { Classpath classpath ->
classpath.entries.each { ClasspathEntry entry ->
if (entry instanceof AbstractLibrary && entry.library.file == file("lib/test/wibble-1.0.jar")) {
entry.sourcePath = fileReferenceFactory.fromFile(file("lib/test/wibble-1.0-sources.jar"))
}
}
}
}
}
}
您可以对此代码进行一般化,以在lib
目录中添加所有遵循某些命名约定的源Jar。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.