这个问题询问如何使用Gradle构建SourceJar。如何使用Gradle Kotlin DSL进行相同的操作?
Gradle代码如下:
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
from(tasks["javadoc"])
不再可用,因为它解析为一个没有任何get(int)
操作的TaskProvider<TaskReportTask>
。 - bentolorval javadocJar by creating(Jar::class) { val javadoc by tasks; from(javadoc); classifier = "javadoc"; }
。 - madheadsourceSets["main"]
的调用? - bentolorval main by sourcesets
:) - madheadval sourcesJar by tasks.creating(Jar :: class){ val sourceSets: SourceSetContainer by project; from(sourceSets ["main"] .allJava); classifier = "sources";}
。虽然我不喜欢它,但它似乎有效。 - madhead