-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP, ci skip] build: switch to
fluxo-kmp-conf
for projects setup
Signed-off-by: Art Shendrik <[email protected]>
- Loading branch information
Showing
45 changed files
with
492 additions
and
1,143 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,162 +1,53 @@ | ||
@file:Suppress("SuspiciousCollectionReassignment", "SpreadOperator") | ||
@file:Suppress("SpreadOperator") | ||
|
||
import java.net.URL | ||
|
||
buildscript { | ||
dependencies { | ||
classpath(libs.plugin.kotlinx.atomicfu) | ||
classpath(libs.kotlin.gradle.api) | ||
classpath(libs.kotlin.atomicfu) | ||
} | ||
} | ||
|
||
plugins { | ||
id("fluxo-setup") | ||
alias(libs.plugins.android.lib) apply false | ||
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.kotlin.dokka) apply false | ||
alias(libs.plugins.kotlin.jvm) apply false | ||
alias(libs.plugins.kotlin.multiplatform) apply false | ||
alias(libs.plugins.kotlinx.binCompatValidator) apply false | ||
alias(libs.plugins.fluxo.bcv.js) apply false | ||
alias(libs.plugins.kotlin.dokka) apply false | ||
alias(libs.plugins.kotlinx.kover) | ||
alias(libs.plugins.deps.guard) | ||
alias(libs.plugins.deps.versions) | ||
alias(libs.plugins.task.tree) | ||
alias(libs.plugins.fluxo.bcv.js) apply false | ||
alias(libs.plugins.fluxo.kmp.conf) | ||
} | ||
|
||
setupDefaults( | ||
multiplatformConfigurator = { | ||
// TODO: Enable the default target hierarchy: | ||
// https://kotlinlang.org/docs/whatsnew1820.html#new-approach-to-source-set-hierarchy | ||
// @OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
// targetHierarchy.default() | ||
// Setup project defaults. | ||
fkcSetupRaw { | ||
explicitApi() | ||
|
||
explicitApi() | ||
// Default KMP setup. | ||
defaults { | ||
allDefaultTargets() | ||
} | ||
|
||
android() | ||
jvm() | ||
if (project.isGenericCompilationEnabled) { | ||
js(IR) { | ||
// Earlier required for generation of TypeScript declaration files | ||
// https://kotlinlang.org/docs/js-ir-compiler.html#preview-generation-of-typescript-declaration-files-d-ts | ||
binaries.executable() | ||
projectName = "Fluxo" | ||
description = "Kotlin Multiplatform MVI / MVVM+ framework" | ||
githubProject = "fluxo-kt/fluxo" | ||
group = "io.github.fluxo-kt" | ||
|
||
compilations.all { | ||
kotlinOptions { | ||
moduleKind = "es" | ||
useEsClasses = true | ||
sourceMap = true | ||
metaInfo = true | ||
} | ||
} | ||
nodejs() | ||
browser() | ||
// TODO: Set developer info. | ||
// developerId = "amal" | ||
// developerName = "Artyom Shendrik" | ||
// developerEmail = "[email protected]" | ||
|
||
generateTypeScriptDefinitions() | ||
} | ||
} | ||
enableSpotless = true | ||
|
||
if (Compilations.isGenericEnabled) { | ||
linuxX64() | ||
} | ||
if (Compilations.isWindowsEnabled) { | ||
mingwX64() | ||
} | ||
if (Compilations.isDarwinEnabled) { | ||
iosCompat() | ||
watchosCompat() | ||
tvosCompat() | ||
macosCompat() | ||
} | ||
experimentalLatestCompilation = true | ||
allWarningsAsErrors = true | ||
useIndyLambdas = false | ||
optInInternal = true | ||
optIns = listOf( | ||
"kotlin.js.ExperimentalJsExport", | ||
) | ||
|
||
// Configure a separate test where code runs in worker thread | ||
// https://kotlinlang.org/docs/compiler-reference.html#generate-worker-test-runner-trw | ||
val backgroundNativeTest = false | ||
if (backgroundNativeTest) { | ||
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithTests<*>>().all { | ||
binaries { | ||
test("background", listOf(DEBUG)) { | ||
freeCompilerArgs += "-trw" | ||
} | ||
} | ||
testRuns { | ||
@Suppress("UNUSED_VARIABLE") | ||
val background by creating { | ||
setExecutionSourceFrom(binaries.getTest("background", DEBUG)) | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
androidConfig = AndroidConfigSetup( | ||
minSdkVersion = libs.versions.androidMinSdk.get().toInt(), | ||
compileSdkVersion = libs.versions.androidCompileSdk.get().toInt(), | ||
targetSdkVersion = libs.versions.androidTargetSdk.get().toInt(), | ||
buildToolsVersion = libs.versions.androidBuildTools.get(), | ||
configurator = { | ||
if (this is com.android.build.gradle.LibraryExtension) { | ||
// Optimize code with R8 for android release aar | ||
// TODO: On-device tests for aar | ||
buildTypes { | ||
release { | ||
isMinifyEnabled = true | ||
proguardFile(rootProject.file("rules.pro")) | ||
} | ||
} | ||
} | ||
}, | ||
), | ||
kotlinConfig = KotlinConfigSetup( | ||
optInInternal = true, | ||
warningsAsErrors = true, | ||
alwaysIndyLambdas = false, | ||
addStdlibDependency = true, | ||
setupCoroutines = false, | ||
optIns = listOf( | ||
"kotlin.js.ExperimentalJsExport", | ||
), | ||
), | ||
publicationConfig = run { | ||
val version = libs.versions.fluxo.get() | ||
val isSnapshot = version.contains("SNAPSHOT", ignoreCase = true) | ||
val scmTag = if (isSnapshot) scmTag().orNull ?: "main" else "v$version" | ||
val url = "https://github.com/fluxo-kt/fluxo" | ||
val publicationUrl = "$url/tree/$scmTag" | ||
PublicationConfig( | ||
// https://central.sonatype.org/publish/publish-gradle/ | ||
// https://central.sonatype.org/publish/publish-guide/#initial-setup | ||
// https://central.sonatype.org/publish/requirements/coordinates/#choose-your-coordinates | ||
// https://github.com/jonashackt/github-actions-release-maven | ||
// https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-creating-your-first-library-1bp8 | ||
group = "io.github.fluxo-kt", | ||
version = version, | ||
projectName = "Fluxo", | ||
projectDescription = "Kotlin Multiplatform MVI / MVVM+ framework", | ||
projectUrl = url, | ||
publicationUrl = publicationUrl, | ||
scmUrl = "scm:git:git://github.com/fluxo-kt/fluxo.git", | ||
scmTag = scmTag, | ||
developerId = "amal", | ||
developerName = "Artyom Shendrik", | ||
developerEmail = "[email protected]", | ||
signingKey = signingKey(), | ||
signingPassword = envOrPropValue("SIGNING_PASSWORD"), | ||
repositoryUserName = envOrPropValue("OSSRH_USER"), | ||
repositoryPassword = envOrPropValue("OSSRH_PASSWORD"), | ||
project = project, | ||
) | ||
}, | ||
binaryCompatibilityValidatorConfig = BinaryCompatibilityValidatorConfig( | ||
disableForNonRelease = true, | ||
), | ||
) | ||
|
||
setupVerification() | ||
|
||
// TODO: Configure universally via convenience plugin | ||
dependencyGuard { | ||
configuration("classpath") | ||
// TODO: BinaryCompatibilityValidatorConfig.disableForNonRelease = true | ||
} | ||
|
||
koverReport { | ||
|
@@ -175,7 +66,8 @@ koverReport { | |
} | ||
html { | ||
onCheck = !isCI && isRelease | ||
setReportDir(layout.buildDirectory.dir("reports/kover-merged-report-html")) // change report directory | ||
// change report directory | ||
setReportDir(layout.buildDirectory.dir("reports/kover-merged-report-html")) | ||
} | ||
|
||
verify { | ||
|
@@ -213,7 +105,7 @@ koverReport { | |
// Inline DSL with coverage not detected in release mode. | ||
if (isRelease) "kt.fluxo.core.FluxoKt*" else null, | ||
if (isRelease) "kt.fluxo.core.dsl.MigrationKt*" else null, | ||
).toTypedArray() | ||
).toTypedArray(), | ||
) | ||
|
||
if (isRelease) { | ||
|
@@ -222,37 +114,27 @@ koverReport { | |
"*Inline*", | ||
// No real need for a deprecated methods' coverage. | ||
"*Deprecated*", | ||
// JvmSynthetic used as a marker for migration helpers hidden from non-kotlin usage and not supposed for coverage. | ||
// JvmSynthetic used as a marker | ||
// for migration helpers hidden from non-kotlin usage | ||
// and not supposed for coverage. | ||
"*Synthetic*", | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (hasProperty("buildScan")) { | ||
buildScan { | ||
termsOfServiceUrl = "https://gradle.com/terms-of-service" | ||
termsOfServiceAgree = "yes" | ||
} | ||
} | ||
|
||
val pinnedDeps = libs.bundles.pinned.get().associate { | ||
it.module to it.versionConstraint.toString() | ||
} | ||
allprojects { | ||
if (pinnedDeps.isNotEmpty()) { | ||
configurations.all { | ||
resolutionStrategy.eachDependency { | ||
val version = pinnedDeps[requested.module] | ||
if (version != null) { | ||
useVersion(version) | ||
because("security recommendations or other considerations") | ||
} | ||
// Exclude unused DOM API. | ||
configurations.all { | ||
resolutionStrategy.eachDependency { | ||
if (requested.module.name == "kotlin-dom-api-compat") { | ||
useTarget(libs.kotlin.stdlib.js) | ||
} | ||
} | ||
} | ||
|
||
// FIXME: Setup automatically. | ||
plugins.withType<org.jetbrains.dokka.gradle.DokkaPlugin> { | ||
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach { | ||
dokkaSourceSets { | ||
|
@@ -263,6 +145,7 @@ allprojects { | |
|
||
sourceLink { | ||
localDirectory.set(rootDir) | ||
@Suppress("DEPRECATION") | ||
remoteUrl.set(URL("https://github.com/fluxo-kt/fluxo/blob/main")) | ||
remoteLineSuffix.set("#L") | ||
} | ||
|
Oops, something went wrong.