Skip to content

Commit

Permalink
[WIP, ci skip] build: switch to fluxo-kmp-conf for projects setup
Browse files Browse the repository at this point in the history
Signed-off-by: Art Shendrik <artyom.shendrik@gmail.com>
  • Loading branch information
amal committed Apr 28, 2024
1 parent dba8b94 commit 104d189
Show file tree
Hide file tree
Showing 45 changed files with 492 additions and 1,143 deletions.
711 changes: 43 additions & 668 deletions .kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions benchmarks/jmh/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.jmh)
}

setupKotlin(
config = KotlinConfigSetup(
kotlinLangVersion = "latest",
javaLangTarget = "17",
optInInternal = true,
optIns = listOf("kt.fluxo.common.annotation.ExperimentalFluxoApi"),
)
)
fkcSetupKotlinApp(
optIns = listOf("kt.fluxo.common.annotation.ExperimentalFluxoApi"),
) {
kotlinLangVersion = "latest"
javaLangTarget = "latest"

setupCoroutines = true
setupDependencies = true
addStdlibDependency = true
experimentalLatestCompilation = false
}

dependencies {
// JMH, a JVM harness for building, running, and analysing nano/micro/milli/macro benchmarks
jmh(libs.jmh.core)
jmh(libs.jmh.generator.annprocess)

implementation(libs.kotlinx.coroutines.core.latest)


// Use the latest snapshot for local development to dogfood the lib.
if (isCI().get() || isRelease().get()) {
Expand Down
199 changes: 41 additions & 158 deletions build.gradle.kts
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 = "artyom.shendrik@gmail.com"

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 = "artyom.shendrik@gmail.com",
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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -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")
}
Expand Down
Loading

0 comments on commit 104d189

Please sign in to comment.