Shorthand provides a more concise syntax for some common tasks in the Gradle kotlin DSL.
There are two ways to install Shorthand: via the buildscript
block or via the pluginManagement
block.
Put this at the top of your build.gradle.kts
:
buildscript {
repositories {
maven(url = "https://jitpack.io")
}
dependencies {
classpath(group = "dev.strixpyrr", name = "shorthand", version = "0.0.5")
}
}
Put this somewhere in your settings.gradle.kts
:
pluginManagement {
repositories {
gradlePluginPortal()
maven(url = "https://jitpack.io")
}
plugins {
id("dev.strixpyrr.shorthand") version "0.0.5"
}
}
Then apply it using the plugins
DSL:
plugins {
id("dev.strixpyrr.shorthand")
}
// Before
tasks {
compileKotlin {
freeCompilerArgs =
listOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xjvm-default=all"
)
}
}
// After
tasks {
compileKotlin {
freeCompilerArgs {
optIn(RequiresOptIn)
jvmDefault = JvmDefaultMode.All
}
}
}
// Before
tasks {
jar {
archiveClassifier.set("...")
val classifier = archiveClassifier.get()
}
}
// After
tasks {
jar {
archiveClassifier("...")
val classifier = archiveClassifier()
}
}
// Before
subprojects {
apply(plugin = "org.jetbrains.kotlin.multiplatform")
apply(plugin = "maven-publish")
}
// After
subprojects {
applyPlugins {
kotlin("multiplatform")
id("maven-publish")
}
}
if (!isJitpack) {
signing {
useGpgCmd()
// ...
}
}