KotlinTarget

Represents a target platform for which Kotlin code is built.

This abstraction allows for the configuration of tasks, dependencies, and other settings specific to the platform on which the code is intended to run.

By default, a Kotlin target contains two KotlinCompilations: one for production and one for test source code.

Examples of accessing the Kotlin target:

  • In Kotlin/JVM or Kotlin/Android projects:

kotlin {
target {
// Configure JVM or Android target specifics here
}
}
  • In Kotlin Multiplatform projects:

kotlin {
jvm { // Creates JVM target
// Configure JVM target specifics here
}

linuxX64 {
// Configure Kotlin native target for Linux X86_64 here
}
}

To learn more about the different targets in Kotlin, see Targets.

Inheritors

Properties

Link copied to clipboard

The name of the configuration that is used when compiling against the API of this Kotlin target.

Link copied to clipboard

The name of the task responsible for assembling the final artifact for this target.

Link copied to clipboard
Link copied to clipboard

Represents a collection of Gradle software components associated with this Kotlin target.

Link copied to clipboard

Retrieves the disambiguation classifier for the Kotlin target.

Link copied to clipboard
abstract override val extras: MutableExtras
Link copied to clipboard

Represents the type of Kotlin platform associated with the target.

Link copied to clipboard
abstract val project: Project

The Gradle Project associated with the entity.

Link copied to clipboard
abstract val publishable: Boolean

Indicates whether the Kotlin target is publishable.

Link copied to clipboard

The name of the configuration containing elements that are strictly required at runtime by this Kotlin target.

Link copied to clipboard

The name of the configuration that represents the variant that carries the original source code in packaged form.

Link copied to clipboard
abstract val targetName: String

The name of the target in the Kotlin build configuration.

Functions

Link copied to clipboard
open fun attributes(configure: AttributeContainer.() -> Unit)
open fun attributes(configure: Action<AttributeContainer>)

Configures the attributes associated with this target.

Link copied to clipboard
Link copied to clipboard
open fun mavenPublication(action: MavenPublication.() -> Unit)

Configures the Maven publication for this Kotlin target.

Link copied to clipboard
abstract fun withSourcesJar(publish: Boolean = true)

Configures the publication of sources.