how to copy all source jars using gradle

前端 未结 3 1885
梦如初夏
梦如初夏 2020-12-14 23:40

We have an old playframework 1.2.x version where we copy all the jars to project/lib so playframework can consume them. We would LOVE to copy all the source jars as well so

3条回答
  •  隐瞒了意图╮
    2020-12-15 00:08

    Here eskatos solution translated in Kotlin DSL:

    tasks {
        "copySourceJars"(Copy::class) {
            val sources = configurations.runtime.resolvedConfiguration.resolvedArtifacts.map {
                with(it.moduleVersion.id) { 
                    dependencies.create(group, name, version, classifier = "sources") 
                }
            }
            from(
                configurations.detachedConfiguration(*sources.toTypedArray())
                    .resolvedConfiguration.lenientConfiguration.getFiles(Specs.SATISFIES_ALL)
            )
            into(File("some-directory"))
        }
    }
    

提交回复
热议问题