[Gradle] Add withSourcesJar to gradle dsl
* Each target can be configured to either publish or not its sources. * For convenience withSourcesJar available also on kotlin multiplatform extension level. It then calls `withSourcesJar` for each target. ^KT-55881 In Progress
This commit is contained in:
committed by
Space Team
parent
4060cc2750
commit
1b3b83755e
+2
@@ -38,6 +38,8 @@ interface KotlinTarget : Named, HasAttributes {
|
|||||||
|
|
||||||
val publishable: Boolean
|
val publishable: Boolean
|
||||||
|
|
||||||
|
fun withSourcesJar(publish: Boolean = true)
|
||||||
|
|
||||||
val components: Set<SoftwareComponent>
|
val components: Set<SoftwareComponent>
|
||||||
|
|
||||||
fun mavenPublication(action: MavenPublication.() -> Unit) = mavenPublication(Action { action(it) })
|
fun mavenPublication(action: MavenPublication.() -> Unit) = mavenPublication(Action { action(it) })
|
||||||
|
|||||||
+4
@@ -65,6 +65,10 @@ abstract class KotlinMultiplatformExtension(project: Project) :
|
|||||||
|
|
||||||
fun metadata(configure: Action<KotlinOnlyTarget<KotlinMetadataCompilation<*>>>) = metadata { configure.execute(this) }
|
fun metadata(configure: Action<KotlinOnlyTarget<KotlinMetadataCompilation<*>>>) = metadata { configure.execute(this) }
|
||||||
|
|
||||||
|
fun withSourcesJar(publish: Boolean = true) {
|
||||||
|
targets.all { withSourcesJar(publish) }
|
||||||
|
}
|
||||||
|
|
||||||
fun <T : KotlinTarget> targetFromPreset(
|
fun <T : KotlinTarget> targetFromPreset(
|
||||||
preset: KotlinTargetPreset<T>,
|
preset: KotlinTargetPreset<T>,
|
||||||
name: String = preset.name,
|
name: String = preset.name,
|
||||||
|
|||||||
+5
@@ -67,6 +67,11 @@ abstract class AbstractKotlinTarget(
|
|||||||
override val publishable: Boolean
|
override val publishable: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
|
||||||
|
internal var publishSources: Boolean = true
|
||||||
|
override fun withSourcesJar(publish: Boolean) {
|
||||||
|
publishSources = publish
|
||||||
|
}
|
||||||
|
|
||||||
@InternalKotlinGradlePluginApi
|
@InternalKotlinGradlePluginApi
|
||||||
override val kotlinComponents: Set<KotlinTargetComponent> by lazy {
|
override val kotlinComponents: Set<KotlinTargetComponent> by lazy {
|
||||||
val mainCompilation = compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME)
|
val mainCompilation = compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME)
|
||||||
|
|||||||
+5
@@ -58,6 +58,11 @@ internal class ExternalKotlinTargetImpl internal constructor(
|
|||||||
artifactsTaskLocator.locate(this)
|
artifactsTaskLocator.locate(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var publishSources: Boolean = true
|
||||||
|
override fun withSourcesJar(publish: Boolean) {
|
||||||
|
publishSources = publish
|
||||||
|
}
|
||||||
|
|
||||||
override val artifactsTaskName: String
|
override val artifactsTaskName: String
|
||||||
get() = artifactsTask.name
|
get() = artifactsTask.name
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user