Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
root = true

[*.{kt,kts}]
# ktlint 1.x defaults to the new ktlint_official code style, which would reformat
# most of the codebase (multiline expression wrapping, trailing commas, signature
# wrapping). Pin the pre-1.x style until a dedicated style-migration PR adopts
# ktlint_official deliberately.
ktlint_code_style = intellij_idea
# ktlint 1.x adds trailing commas by default regardless of code style; the
# codebase doesn't use them.
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
# ktlint 1.x also enables stricter naming rules by default. The codebase relies on
# ktlint enables strict naming rules by default. The codebase relies on
# backtick-wrapped test function names and constant-style vals that predate
# these rules, so keep them disabled to match existing conventions.
ktlint_standard_function-naming = disabled
Expand Down
39 changes: 14 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.diffplug.spotless.LineEnding
import com.vanniktech.maven.publish.MavenPublishPlugin
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import org.jetbrains.dokka.gradle.DokkaTask
import java.util.zip.ZipFile

Expand Down Expand Up @@ -113,7 +114,7 @@ private fun Project.validateKotlinMultiplatformCoreArtifacts() {
"wasm-js",
"linuxx64",
"linuxarm64",
"mingwx64"
"mingwx64",
)

val artifactPaths =
Expand All @@ -122,7 +123,7 @@ private fun Project.validateKotlinMultiplatformCoreArtifacts() {
addAll(
platforms.map { platform ->
distributionDir.resolve("$baseFileName-$platform-$version.zip")
}
},
)
}

Expand All @@ -131,7 +132,7 @@ private fun Project.validateKotlinMultiplatformCoreArtifacts() {
"javadoc",
"sources",
"module",
"pom-default.xml"
"pom-default.xml",
)

artifactPaths.forEach { artifactFile ->
Expand Down Expand Up @@ -167,7 +168,7 @@ private fun Project.validateKotlinMultiplatformCoreArtifacts() {
val actualKlibFiles = entries.count { it.contains("klib") }
if (actualKlibFiles != expectedNumOfKlibFiles) {
throw GradleException(
"❌ Expected $expectedNumOfKlibFiles klib files in ${artifactFile.name}, but found $actualKlibFiles"
"❌ Expected $expectedNumOfKlibFiles klib files in ${artifactFile.name}, but found $actualKlibFiles",
)
} else {
println("✅ Found $expectedNumOfKlibFiles klib files in ${artifactFile.name}")
Expand Down Expand Up @@ -199,37 +200,18 @@ subprojects {
}
}

// Keep ktlint 1.x on the pre-1.0 formatting conventions (see .editorconfig for the
// rationale). Spotless does not reliably forward the ij_* properties from
// .editorconfig to ktlint, so pass them explicitly.
val ktlintEditorConfigOverride =
mapOf(
"ktlint_code_style" to "intellij_idea",
"ij_kotlin_allow_trailing_comma" to "false",
"ij_kotlin_allow_trailing_comma_on_call_site" to "false",
"ktlint_standard_argument-list-wrapping" to "disabled",
"ktlint_standard_chain-method-continuation" to "disabled",
"ktlint_standard_class-signature" to "disabled",
"ktlint_standard_condition-wrapping" to "disabled",
"ktlint_standard_function-expression-body" to "disabled",
"ktlint_standard_function-signature" to "disabled",
"ktlint_standard_multiline-expression-wrapping" to "disabled",
"ktlint_standard_function-naming" to "disabled",
"ktlint_standard_property-naming" to "disabled"
)

spotless {
lineEndings = LineEnding.UNIX

kotlin {
target("**/*.kt")
targetExclude("**/generated/**/*.kt")
ktlint().editorConfigOverride(ktlintEditorConfigOverride)
ktlint()
}
kotlinGradle {
target("**/*.kts")
targetExclude("**/generated/**/*.kts")
ktlint().editorConfigOverride(ktlintEditorConfigOverride)
ktlint()
}
}

Expand All @@ -244,6 +226,8 @@ detekt {

fun SourceTask.detektExcludes() {
exclude("**/build/**")
exclude("**/.kotlin/**")
exclude("**/.gradle/**")
exclude("**/*.kts")
exclude("**/buildSrc/**")
exclude("**/*Test*/**")
Expand All @@ -259,6 +243,11 @@ tasks.withType<Detekt>().configureEach {
detektExcludes()
}

tasks.withType<DetektCreateBaselineTask>().configureEach {
setSource(files(project.projectDir))
detektExcludes()
}

/** Task for generating a Detekt baseline.xml */
val detektProjectBaseline by tasks.registering(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask::class) {
buildUponDefaultConfig.set(true)
Expand Down
50 changes: 27 additions & 23 deletions buildSrc/src/main/java/Publication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,38 @@ import java.io.File

private val sep: String = File.separator

fun DistributionContainer.configureForMultiplatform(project: Project, buildPublishDir: String) {
fun DistributionContainer.configureForMultiplatform(
project: Project,
buildPublishDir: String,
) {
val version = project.property("versionName").toString()
if (version.isEmpty()) {
throw GradleException("DistZip: version name is empty")
}
val projectName = project.name
val platforms = mapOf(
"main" to projectName,
"android" to "$projectName-android",
"jvm" to "$projectName-jvm",
"iosarm64" to "$projectName-iosarm64",
"iossimulatorarm64" to "$projectName-iossimulatorarm64",
"iosx64" to "$projectName-iosx64",
"macosarm64" to "$projectName-macosarm64",
"macosx64" to "$projectName-macosx64",
"tvosarm64" to "$projectName-tvosarm64",
"tvossimulatorarm64" to "$projectName-tvossimulatorarm64",
"tvosx64" to "$projectName-tvosx64",
"watchosarm32" to "$projectName-watchosarm32",
"watchosarm64" to "$projectName-watchosarm64",
"watchossimulatorarm64" to "$projectName-watchossimulatorarm64",
"watchosx64" to "$projectName-watchosx64",
"js" to "$projectName-js",
"wasm-js" to "$projectName-wasm-js",
"mingwx64" to "$projectName-mingwx64",
"linuxarm64" to "$projectName-linuxarm64",
"linuxx64" to "$projectName-linuxx64"
)
val platforms =
mapOf(
"main" to projectName,
"android" to "$projectName-android",
"jvm" to "$projectName-jvm",
"iosarm64" to "$projectName-iosarm64",
"iossimulatorarm64" to "$projectName-iossimulatorarm64",
"iosx64" to "$projectName-iosx64",
"macosarm64" to "$projectName-macosarm64",
"macosx64" to "$projectName-macosx64",
"tvosarm64" to "$projectName-tvosarm64",
"tvossimulatorarm64" to "$projectName-tvossimulatorarm64",
"tvosx64" to "$projectName-tvosx64",
"watchosarm32" to "$projectName-watchosarm32",
"watchosarm64" to "$projectName-watchosarm64",
"watchossimulatorarm64" to "$projectName-watchossimulatorarm64",
"watchosx64" to "$projectName-watchosx64",
"js" to "$projectName-js",
"wasm-js" to "$projectName-wasm-js",
"mingwx64" to "$projectName-mingwx64",
"linuxarm64" to "$projectName-linuxarm64",
"linuxx64" to "$projectName-linuxx64",
)

platforms.forEach { (distName, projectName) ->
val distribution = maybeCreate(distName)
Expand Down
6 changes: 6 additions & 0 deletions config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>MaxLineLength:ManualFrameworkPathSearchValueSource.kt$ManualFrameworkPathSearchValueSource$abstract</ID>
<ID>MaxLineLength:SentryAttributes.kt$SentryAttributes.Companion$public</ID>
<ID>MaxLineLength:SentryLogConverters.apple.kt$is SentryAttributeValue.BooleanValue -> SentryStructuredLogAttribute(boolean = attrValue.value as Boolean)</ID>
<ID>MaxLineLength:SentryPlatformOptions.android.kt$internal actual fun SentryOptions.toPlatformOptionsConfiguration(): PlatformOptionsConfiguration</ID>
<ID>MaxLineLength:SentryPlatformOptions.ios.kt$internal actual fun SentryOptions.toPlatformOptionsConfiguration(): PlatformOptionsConfiguration</ID>
<ID>MaxLineLength:SentryPlatformOptions.jvm.kt$internal actual fun SentryOptions.toPlatformOptionsConfiguration(): PlatformOptionsConfiguration</ID>
<ID>MaxLineLength:SentryPlatformOptions.tvwatchmacos.kt$internal actual fun SentryOptions.toPlatformOptionsConfiguration(): PlatformOptionsConfiguration</ID>
<ID>SwallowedException:CocoaScopeProvider.kt$CocoaScopeProvider$e: Throwable</ID>
<ID>SwallowedException:SentryLevel.kt$SentryLevel.Companion$throwable: Throwable</ID>
<ID>TooGenericExceptionCaught:CocoaScopeProvider.kt$CocoaScopeProvider$e: Throwable</ID>
Expand Down
6 changes: 3 additions & 3 deletions sentry-kotlin-multiplatform-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ listOf("compileClasspath", "testCompileClasspath", "testRuntimeClasspath").forEa
attributes {
attribute(
TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE,
JavaVersion.VERSION_17.majorVersion.toInt()
JavaVersion.VERSION_17.majorVersion.toInt(),
)
}
}
Expand Down Expand Up @@ -114,12 +114,12 @@ buildConfig {
buildConfigField(
"String",
"SentryCocoaVersion",
provider { "\"${project.property("sentryCocoaVersion")}\"" }
provider { "\"${project.property("sentryCocoaVersion")}\"" },
)
buildConfigField(
"String",
"SentryKmpVersion",
provider { "\"${project.property("versionName")}\"" }
provider { "\"${project.property("versionName")}\"" },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ import org.gradle.api.provider.Property
import javax.inject.Inject

@Suppress("UnnecessaryAbstractClass")
abstract class AutoInstallExtension @Inject constructor(project: Project) {
private val objects = project.objects
abstract class AutoInstallExtension
@Inject
constructor(
project: Project,
) {
private val objects = project.objects

/**
* Enable auto-installation of the Sentry dependencies through [CocoapodsAutoInstallExtension],
* [Spm4KmpAutoInstallExtension] and [SourceSetAutoInstallExtension].
*
* Disabling this will prevent the plugin from auto installing any dependency.
*
* Defaults to true.
*/
val enabled: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
/**
* Enable auto-installation of the Sentry dependencies through [CocoapodsAutoInstallExtension],
* [Spm4KmpAutoInstallExtension] and [SourceSetAutoInstallExtension].
*
* Disabling this will prevent the plugin from auto installing any dependency.
*
* Defaults to true.
*/
val enabled: Property<Boolean> = objects.property(Boolean::class.java).convention(true)

val cocoapods: CocoapodsAutoInstallExtension =
objects.newInstance(CocoapodsAutoInstallExtension::class.java, project)
val cocoapods: CocoapodsAutoInstallExtension =
objects.newInstance(CocoapodsAutoInstallExtension::class.java, project)

val spm: Spm4KmpAutoInstallExtension =
objects.newInstance(Spm4KmpAutoInstallExtension::class.java, project)
val spm: Spm4KmpAutoInstallExtension =
objects.newInstance(Spm4KmpAutoInstallExtension::class.java, project)

val commonMain: SourceSetAutoInstallExtension =
objects.newInstance(SourceSetAutoInstallExtension::class.java, project)
}
val commonMain: SourceSetAutoInstallExtension =
objects.newInstance(SourceSetAutoInstallExtension::class.java, project)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
class CocoaFrameworkLinker(
private val logger: Logger,
private val pathResolver: FrameworkPathResolver,
private val binaryLinker: FrameworkLinker
private val binaryLinker: FrameworkLinker,
) {
fun configure(appleTargets: List<KotlinNativeTarget>) {
appleTargets.forEach { target ->
try {
logger.info(
"Start resolving Sentry Cocoa framework paths for target: ${target.name}"
"Start resolving Sentry Cocoa framework paths for target: ${target.name}",
)
processTarget(target)
logger.lifecycle("Successfully configured Sentry Cocoa framework linking for target: ${target.name}")
Expand All @@ -42,7 +42,7 @@ class CocoaFrameworkLinker(

internal class FrameworkLinkingException(
message: String,
cause: Throwable? = null
cause: Throwable? = null,
) : GradleException(message, cause)

/**
Expand All @@ -56,17 +56,18 @@ internal class FrameworkLinkingException(
* @return Set of possible architecture folder names for the given target.
* Returns empty set if target is not supported.
*/
internal fun KotlinNativeTarget.toSentryFrameworkArchitecture(): Set<String> = buildSet {
when (name) {
"iosSimulatorArm64", "iosX64" -> addAll(SentryCocoaFrameworkArchitectures.IOS_SIMULATOR_AND_X64)
"iosArm64" -> addAll(SentryCocoaFrameworkArchitectures.IOS_ARM64)
"macosArm64", "macosX64" -> addAll(SentryCocoaFrameworkArchitectures.MACOS_ARM64_AND_X64)
"tvosSimulatorArm64", "tvosX64" -> addAll(SentryCocoaFrameworkArchitectures.TVOS_SIMULATOR_AND_X64)
"tvosArm64" -> addAll(SentryCocoaFrameworkArchitectures.TVOS_ARM64)
"watchosArm32", "watchosArm64" -> addAll(SentryCocoaFrameworkArchitectures.WATCHOS_ARM)
"watchosSimulatorArm64", "watchosX64" -> addAll(SentryCocoaFrameworkArchitectures.WATCHOS_SIMULATOR_AND_X64)
internal fun KotlinNativeTarget.toSentryFrameworkArchitecture(): Set<String> =
buildSet {
when (name) {
"iosSimulatorArm64", "iosX64" -> addAll(SentryCocoaFrameworkArchitectures.IOS_SIMULATOR_AND_X64)
"iosArm64" -> addAll(SentryCocoaFrameworkArchitectures.IOS_ARM64)
"macosArm64", "macosX64" -> addAll(SentryCocoaFrameworkArchitectures.MACOS_ARM64_AND_X64)
"tvosSimulatorArm64", "tvosX64" -> addAll(SentryCocoaFrameworkArchitectures.TVOS_SIMULATOR_AND_X64)
"tvosArm64" -> addAll(SentryCocoaFrameworkArchitectures.TVOS_ARM64)
"watchosArm32", "watchosArm64" -> addAll(SentryCocoaFrameworkArchitectures.WATCHOS_ARM)
"watchosSimulatorArm64", "watchosX64" -> addAll(SentryCocoaFrameworkArchitectures.WATCHOS_SIMULATOR_AND_X64)
}
}
}

internal object SentryCocoaFrameworkArchitectures {
val IOS_SIMULATOR_AND_X64 = setOf("ios-arm64_x86_64-simulator")
Expand All @@ -78,15 +79,16 @@ internal object SentryCocoaFrameworkArchitectures {
val WATCHOS_SIMULATOR_AND_X64 = setOf("watchos-arm64_i386_x86_64-simulator")

// Used for tests
val all = setOf(
IOS_SIMULATOR_AND_X64,
IOS_ARM64,
MACOS_ARM64_AND_X64,
TVOS_SIMULATOR_AND_X64,
TVOS_ARM64,
WATCHOS_ARM,
WATCHOS_SIMULATOR_AND_X64
)
val all =
setOf(
IOS_SIMULATOR_AND_X64,
IOS_ARM64,
MACOS_ARM64_AND_X64,
TVOS_SIMULATOR_AND_X64,
TVOS_ARM64,
WATCHOS_ARM,
WATCHOS_SIMULATOR_AND_X64,
)
}

internal fun KotlinMultiplatformExtension.appleTargets() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@ import org.gradle.api.provider.Property
import javax.inject.Inject

@Suppress("UnnecessaryAbstractClass")
abstract class CocoapodsAutoInstallExtension @Inject constructor(project: Project) {
private val objects = project.objects
abstract class CocoapodsAutoInstallExtension
@Inject
constructor(
project: Project,
) {
private val objects = project.objects

/**
* Enable auto-installation of the Sentry Cocoa SDK pod.
*
* If the cocoapods plugin is applied and no existing Sentry pod configuration exists, the
* Sentry-Cocoa SDK pod will be installed.
*
* Defaults to true.
*/
val enabled: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
/**
* Enable auto-installation of the Sentry Cocoa SDK pod.
*
* If the cocoapods plugin is applied and no existing Sentry pod configuration exists, the
* Sentry-Cocoa SDK pod will be installed.
*
* Defaults to true.
*/
val enabled: Property<Boolean> = objects.property(Boolean::class.java).convention(true)

/**
* Overrides default Sentry Cocoa version.
*
* Defaults to the version used in the latest KMP SDK.
*/
val sentryCocoaVersion: Property<String> =
objects.property(String::class.java).convention("~> ${BuildConfig.SentryCocoaVersion}")
}
/**
* Overrides default Sentry Cocoa version.
*
* Defaults to the version used in the latest KMP SDK.
*/
val sentryCocoaVersion: Property<String> =
objects.property(String::class.java).convention("~> ${BuildConfig.SentryCocoaVersion}")
}
Loading
Loading