Add methods to also embed sources and javadoc from embedded dependencies

Introduced approach is not ideal as it introduces direct inter-project
call breaking project isolation. But proper solution requires quite a
lot of changes and should be done separately.

^KT-52811 In Progress
This commit is contained in:
Yahor Berdnikau
2023-03-22 22:54:49 +01:00
committed by Space Team
parent cdec1e6c62
commit e1bd7d7b5d
+41
View File
@@ -183,6 +183,26 @@ fun Project.sourcesJar(body: Jar.() -> Unit = {}): TaskProvider<Jar> {
return sourcesJar
}
/**
* Also embeds into final '-sources.jar' file source files from embedded dependencies.
*/
fun Project.sourcesJarWithSourcesFromEmbedded(
vararg embeddedDepSourcesJarTasks: TaskProvider<out Jar>,
body: Jar.() -> Unit = {},
): TaskProvider<Jar> {
val sourcesJarTask = sourcesJar(body)
sourcesJarTask.configure {
val archiveOperations = serviceOf<ArchiveOperations>()
embeddedDepSourcesJarTasks.forEach { embeddedSourceJarTask ->
dependsOn(embeddedSourceJarTask)
from(embeddedSourceJarTask.map { archiveOperations.zipTree(it.archiveFile) })
}
}
return sourcesJarTask
}
fun Jar.addEmbeddedSources() {
project.configurations.findByName("embedded")?.let { embedded ->
val allSources by lazy {
@@ -222,6 +242,27 @@ fun Project.javadocJar(body: Jar.() -> Unit = {}): TaskProvider<Jar> {
return javadocTask
}
/**
* Also embeds into final '-javadoc.jar' file javadoc files from embedded dependencies.
*/
fun Project.javadocJarWithJavadocFromEmbedded(
vararg embeddedDepJavadocJarTasks: TaskProvider<out Jar>,
body: Jar.() -> Unit = {},
): TaskProvider<Jar> {
val javadocJarTask = javadocJar(body)
javadocJarTask.configure {
val archiveOperations = serviceOf<ArchiveOperations>()
embeddedDepJavadocJarTasks.forEach { embeddedJavadocJarTask ->
dependsOn(embeddedJavadocJarTask)
from(embeddedJavadocJarTask.map { archiveOperations.zipTree(it.archiveFile) })
}
}
return javadocJarTask
}
fun Project.standardPublicJars() {
runtimeJar()
sourcesJar()