Core plugin¶
Add the following to the root build.gradle or build.gradle.kts to apply the plugin:
plugins {
id("com.freeletics.gradle.core").version("<latest-version>")
}
Defaults¶
Common configuration¶
The plugin applies the following common configuration:
- The Java and Kotlin toolchain are set to the
java-toolchainversion catalog version. - Kotlin’s progressive mode is enabled.
- Kotlin compiler warnings are treated as errors.
- This can be disabled by setting
fgp.kotlin.warningsAsErrors=false - It’s possible to ignore deprecation warning by setting
fgp.kotlin.suppressDeprecationWarnings=true
- This can be disabled by setting
- Several Kotlin compiler flags are set to improve the default behavior.
- All produced archives are configured to be reproducible.
Default dependencies¶
The plugins can dynamically add default dependencies to all modules. This can be enabled by creating any of the following bundles:
[bundles]
# any dependency in this bundle is automatically added to all modules as implementation dependency
default-all = [ ... ]
# any dependency in this bundle is automatically added to all modules as compileOnly dependency
default-all-compile = [ ... ]
# any dependency in this bundle is automatically added to all Android modules as implementation dependency
default-android = [ ... ]
# any dependency in this bundle is automatically added to all Android modules as compileOnly dependency
default-android-compile = [ ... ]
# any dependency in this bundle is automatically added to all modules as testImplementation dependency
default-testing = [ ... ]
# any dependency in this bundle is automatically added to all modules as testCompileOnly dependency
default-testing-compile = [ ... ]
# any dependency in this bundle is automatically added to all modules as testRuntimeOnly dependency
default-testing-runtime = [ ... ]
# any dependency in this bundle is automatically added to all modules as lintChecks dependency
default-lint = [ ... ]
Multiplatform Kotlin configuration¶
- The default hierarchy template is applied automatically.
expectandactualclasses are enabled in compiler through the-Xexpect-actual-classesoption.- Android Lint is applied to the module.
Android target configuration¶
If an Android target is added:
- The
compileSdkis set to theandroid-compileversion catalog version - The
minSdkis set to theandroid-minversion catalog version - Optionally the
buildToolsVersionis set to theandroid-buildToolsversion catalog version if it’s present in the version catalog. - If the
android-desugarjdklibslibrary is defined the version catalog core library desugaring is be enabled automatically. - Host tests are enabled.
Features¶
Explicit API¶
It’s possible to enable Kotlin’s explicit API mode directly from the DSL by calling:
freeletics {
explicitApi()
}
Experimental API opt in¶
It’s possible to opt into an experimental API for the module directly from the DSL by calling:
freeletics {
optIn("...")
}
Compose¶
To enable Jetpack Compose for the module call:
freeletics {
useCompose()
}
It’s possible to enable compose compiler reports and metrics by setting the following 2 properties. Afterwards the outputs can be found in the build folder.
fgp.compose.enableCompilerMetrics=true
fgp.compose.enableCompilerReports=true`
kotlinx.serialization¶
To enable kotlinx.serialziation for the module call:
freeletics {
useSerialization()
}
This expects the version catalog to have a kotlinx-serialization entry with the
org.jetbrains.kotlinx:kotlinx-serialization-core library.
Metro¶
To enable Metro for the module call:
freeletics {
useMetro()
}
Khonshu¶
To enable Khonshu for the module call:
freeletics {
useKhonshu()
}
Both Metro and KSP will be automatically enabled when using Khonshu.
This expects the version catalog to have the following 2 entries:
- khonshu-codegen-runtime pointing to com.freeletics.khonshu:codegen-runtime
- khonshu-codegen-compiler pointing to com.freeletics.khonshu:codegen-compiler
Poko¶
To enable Poko for the module call:
freeletics {
usePoko()
}
Kopy¶
To enable Kopy for the module call:
freeletics {
useKopy()
}
SQLDelight¶
To enable SQLDelight for the module call:
freeletics {
useSqlDelight()
}
There are 2 optional parameters for this function:
- the name for the generated database which defaults to database
- a dependency if this module depends on another module’s SQLDelight definitions
To change the used SQL dialect
add the dialect of your choice to the version catalog with an entry called sqldelight-dialect.
Room¶
To enable Room for the module call:
freeletics {
useRoom()
}
This will automatically apply KSP to the project and will use Kotlin code generation.
Optionally a schemaLocation can be provided.
This expects the version catalog to have the following 2 entries:
- androidx-room-runtime pointing to androidx.room:room-runtime
- androidx-room-compiler pointing to androidx.room:room-compiler
Burst¶
To enable Burst for the module call:
freeletics {
useBurst()
}
OSS publishing¶
Publishing to Maven Central using the gradle-maven-publish-plugin.
freeletics {
enableOssPublishing()
}
Enabling this will also apply Dokka, enable ABI validation and enable explicit API mode.
For the configuration of the POM, only the following Gradle properties need to be defined:
- GROUP
- VERSION_NAME
- POM_REPO_NAME
- POM_ARTIFACT_ID
- POM_NAME
- POM_DESCRIPTION
Internal publishing¶
Publishing to an internal repo can be enabled by calling the following function:
freeletics {
enableInternalPublishing()
}
A fgp.internalArtifacts.url gradle property needs to be defined with the URL of the remote repository. The username
and password for this repository are expected to be set through internalArtifactsUsername and internalArtifactsPassword.
Adding multiplatform targets¶
There are several functions to easily add targets to the module:
freeletics {
multiplatform {
// adds all targets that a also supported by the coroutines project
// has a `limitToComposeTargets` boolean parameter that can be set to true to only add targets supported by
// the compose runtime
addCommonTargets()
// adds jvm as a target
addJvmTarget()
// adds Android as a target
addAndroidTarget {
// Android DSL options
}
// adds `iosArm64`, `iosSimulatorArm64` as targets
// has a `includeX64` boolean parameter to also include `iosX64`
addIosTargets()
// same as above but will also configure everything to create a XCFramework
addIosTargetsWithXcFramework("frameworkName") { framework ->
// optionally configure the framework
}
}
}
Compose resources¶
Enable Compose resources for the module call:
freeletics {
multiplatform {
useComposeResources()
}
}
This will configure the Res class generation to always run and will configure the package name based on the module.
SKIE¶
To enable SKIE for the module call:
freeletics {
useSkie()
}
–8← “docs/features/multiplatform-android-1-paparazzi.md) –8← “docs/features/multiplatform-android-2-parcelize.md) –8← “docs/features/multiplatform-android-3-resources.md) –8← “docs/features/multiplatform-android-4-proguard.md)