我们有一个旧的playframework 1.2.x版本,我们将所有的jar复制到project/lib,因此playframework可以使用它们.我们也很乐意复制所有源jar,以便在runnig play eclipsify时,我们可以查看所有第三方源.有没有办法用gradle做到这一点?
当我看到他们下载缓存位置时,我指的是当我运行gradle eclipse时下载的所有源jar.我们在一个项目中为我们调用了eclipsify,因此我们可以100%只使用gradle.
谢谢,迪恩
这不像预期的那样直截了当.以下代码段将java项目的所有依赖项(运行时+编译)的源jar复制到特定文件夹中:
task copySourceJars(type:Copy){
def deps = configurations.runtime.incoming.dependencies.collect{ dependency ->
dependency.artifact { artifact ->
artifact.name = dependency.name
artifact.type = 'source'
artifact.extension = 'jar'
artifact.classifier = 'sources'
}
dependency
}
from(configurations.detachedConfiguration(deps as Dependency[]).resolvedConfiguration.lenientConfiguration.getFiles(Specs.SATISFIES_ALL))
into('sourceLibs')
}
Run Code Online (Sandbox Code Playgroud)
我们在这里使用lenientConfiguration的原因是,如果无法解析源工件,我们不希望失败.可能有更优雅的方式,但我没有深入研究.
希望能帮助到你,
勒内
Rene的回答将下载直接依赖的源代码库,而不是所有传递依赖项的源代码库.
这是一个可以解决问题的任务:
task copySourceJars( type: Copy ) {
def sources = configurations.runtime.resolvedConfiguration.resolvedArtifacts.collect { artifact ->
project.dependencies.create( [
group: artifact.moduleVersion.id.group,
name: artifact.moduleVersion.id.name,
version: artifact.moduleVersion.id.version,
classifier: 'sources'
] )
}
from configurations.detachedConfiguration( sources as Dependency[] )
.resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL )
into file( 'some-directory/' )
}
Run Code Online (Sandbox Code Playgroud)
然后,可以通过更改classifier
to来为javadocs jar执行相同的操作javadoc
.
归档时间: |
|
查看次数: |
2057 次 |
最近记录: |