Rene 答案将下载直接依赖项的源 jar,而不是所有传递依赖项的源 jar。
这是一个可以解决问题的任务:
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/' )
}
然后可以通过classifier
将javadoc
.