Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add plugin support #230

Merged
merged 82 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
5616413
Add raw working impl
buenaflor Apr 24, 2024
4b48be5
Update
buenaflor Apr 25, 2024
51130b0
Update
buenaflor Apr 25, 2024
3410510
Update
buenaflor Apr 25, 2024
2499417
Update
buenaflor May 3, 2024
e1ba06b
Update plugin
buenaflor May 4, 2024
3937b01
Update
buenaflor May 4, 2024
5438066
Update
buenaflor May 15, 2024
f6b4e7c
Update
buenaflor Jun 5, 2024
429e3b1
Update
buenaflor Jun 5, 2024
ed5dce8
Update
buenaflor Jun 5, 2024
99104d4
Updatee
buenaflor Jun 5, 2024
0dbb7f6
Update doc
buenaflor Jun 5, 2024
454f85f
Update docs
buenaflor Jun 5, 2024
5bc7070
Remove print
buenaflor Jun 5, 2024
36aab7b
Update
buenaflor Jun 5, 2024
6ef48aa
Update
buenaflor Jun 6, 2024
0bd2eb9
Update comment
buenaflor Jun 6, 2024
18f7906
Update
buenaflor Jun 6, 2024
5b7ccc0
Update
buenaflor Jun 7, 2024
8f8c587
Update
buenaflor Jun 7, 2024
764eda2
Format
buenaflor Jun 7, 2024
de523ac
Format
buenaflor Jun 7, 2024
81b5ab9
Merge branch 'main' into feat/add-plugin
buenaflor Jun 10, 2024
8fa4104
Update plugin-build/plugin/src/main/java/io/sentry/kotlin/multiplatfo…
buenaflor Jun 10, 2024
0cdeace
check if isStatic in linking
buenaflor Jun 10, 2024
6fd5837
Update plugin build dir name and ID
buenaflor Jun 10, 2024
f1e31a3
Add deps only with compileOnly
buenaflor Jun 10, 2024
392d336
Update
buenaflor Jun 10, 2024
370a396
Updaet
buenaflor Jun 10, 2024
409ec2f
Include gradle plugin version bump
buenaflor Jun 10, 2024
abcce27
Update project name
buenaflor Jun 10, 2024
6108cda
Use buildconfig
buenaflor Jun 10, 2024
5dc9130
Remove todo
buenaflor Jun 10, 2024
38db5e8
Change sentry extension name to sentryKmp
buenaflor Jun 10, 2024
fb1ca4b
Set androidNative to unsupported targets
buenaflor Jun 10, 2024
d3e2891
add symlinks
buenaflor Jun 10, 2024
a2ce288
Update
buenaflor Jun 10, 2024
f6afac1
Update
buenaflor Jun 10, 2024
50a9e26
Update'
buenaflor Jun 10, 2024
8b718e3
Update
buenaflor Jun 10, 2024
51d5136
Add CI
buenaflor Jun 11, 2024
87f7a7f
Add to craft
buenaflor Jun 11, 2024
6b0eaa5
Remove package.resolved
buenaflor Jun 11, 2024
2f26925
Format
buenaflor Jun 11, 2024
bd2c537
Update
buenaflor Jun 11, 2024
38db1a9
Update changelog
buenaflor Jun 11, 2024
1317545
Enable cocoapods sample
buenaflor Jun 11, 2024
e96287a
Update
buenaflor Jun 11, 2024
b0b1050
Remove podspec from spm sample
buenaflor Jun 11, 2024
2a5cb18
Remove
buenaflor Jun 11, 2024
0e5253d
Format
buenaflor Jun 11, 2024
20f69c2
Update
buenaflor Jun 11, 2024
e2b0937
Fix deps
buenaflor Jun 11, 2024
97eeefe
update
buenaflor Jun 11, 2024
f8a1366
update
buenaflor Jul 31, 2024
56ab206
Update Changelog
buenaflor Jul 31, 2024
080ea92
add ~> to version
buenaflor Jul 31, 2024
f17244a
Add derived data value source for caching
buenaflor Jul 31, 2024
ec6cc7b
Merge branch 'main' into feat/add-plugin
buenaflor Jul 31, 2024
02f132d
Run test during ci
buenaflor Jul 31, 2024
c446cb1
Update
buenaflor Aug 1, 2024
a34cb65
formatting{
buenaflor Aug 1, 2024
e846c9c
format
buenaflor Aug 1, 2024
2c78dfd
Skip apple specific configs if there are not apple targets
buenaflor Aug 1, 2024
bdf62f7
Fix tests
buenaflor Aug 1, 2024
87e9183
Update CI and skip linker and cocoapods if not macOS host
buenaflor Aug 1, 2024
8698be5
Format code
getsentry-bot Aug 1, 2024
c3615e0
update
buenaflor Aug 1, 2024
9de03d2
Update
buenaflor Aug 1, 2024
af6385c
update
buenaflor Aug 1, 2024
6a981a8
Add compilation test through samples
buenaflor Aug 1, 2024
a6cf258
run allTests for every sample project
buenaflor Aug 1, 2024
2ddc1cd
Update CHANGELOG.md
buenaflor Aug 1, 2024
a1f2d67
Merge branch 'main' into feat/add-plugin
buenaflor Aug 1, 2024
ca88300
Upload codecov report
buenaflor Aug 1, 2024
d140c9a
Default working directory
buenaflor Aug 1, 2024
92db2b5
Merge branch 'main' into feat/add-plugin
buenaflor Aug 1, 2024
97f9bdd
Use kover 0.7.3
buenaflor Aug 1, 2024
d48a901
Update
buenaflor Aug 2, 2024
690eb1b
Update
buenaflor Aug 5, 2024
5720a9a
Update
buenaflor Aug 5, 2024
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
12 changes: 12 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ minVersion: 1.2.1
changelogPolicy: auto
targets:
- name: maven
id: kmp
gradleCliPath: ./gradlew
mavenCliPath: scripts/mvnw
mavenSettingsPath: scripts/settings.xml
Expand All @@ -14,8 +15,19 @@ targets:
kmp:
rootDistDirRegex: /^(?!.*(?:jvm|android|ios|watchos|tvos|macos)).*$/
appleDistDirRegex: /(ios|watchos|tvos|macos)/
excludeNames: /sentry-kotlin-multiplatform-gradle-plugin.*$/
- name: maven
id: plugin
gradleCliPath: ./gradlew
mavenCliPath: scripts/mvnw
mavenSettingsPath: scripts/settings.xml
mavenRepoId: ossrh
mavenRepoUrl: https://oss.sonatype.org/service/local/staging/deploy/maven2/
android: false
includeNames: /sentry-kotlin-multiplatform-gradle-plugin.*$/
- name: github
- name: registry
sdks:
maven:io.sentry:sentry-kotlin-multiplatform:
# maven:io.sentry:sentry-kotlin-multiplatform-gradle-plugin:

3 changes: 2 additions & 1 deletion .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ jobs:
distribution: temurin

- name: Analyze
run: ./gradlew apiCheck detekt
run:
./gradlew apiCheck detekt spotlessCheck
75 changes: 75 additions & 0 deletions .github/workflows/kotlin-multiplatform-gradle-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: "Plugin: sentry-kotlin-multiplatform"
on:
push:
branches:
- main
- release/**
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: macos-latest-xlarge
defaults:
run:
working-directory: sentry-kotlin-multiplatform-gradle-plugin

steps:
- uses: actions/checkout@v4

- name: JDK setup
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: Cached Konan
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 #v3
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-konan-

- name: Cached Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a

- name: Build
run: |
./gradlew build
./gradlew koverXmlReport

- name: Upload coverage to Codecov
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # pin@v4
with:
name: sentry-kotlin-multiplatform-gradle-plugin
token: ${{ secrets.CODECOV_TOKEN }}

archive-distribution:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: JDK setup
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: Cached Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a

- name: DistZip
run: |
cd sentry-kotlin-multiplatform-gradle-plugin && ./gradlew distZip
buenaflor marked this conversation as resolved.
Show resolved Hide resolved

- name: Archive packages
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
if-no-files-found: error
path: |
./*/build/distributions/*.zip
19 changes: 19 additions & 0 deletions .github/workflows/kotlin-multiplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ jobs:
name: sentry-kotlin-multiplatform
token: ${{ secrets.CODECOV_TOKEN }}

test-samples:
runs-on: macos-latest-xlarge

steps:
- uses: actions/checkout@v4

- name: JDK setup
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: Cached Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a

- name: Test samples
run: |
./gradlew allTests -p sentry-samples

archive-distribution:
runs-on: macos-latest-xlarge

Expand Down
2 changes: 1 addition & 1 deletion .run/iosApp-spm.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="iosApp-spm" type="KmmRunConfiguration" factoryName="iOS Application" CONFIG_VERSION="1" EXEC_TARGET_ID="27607109-90E2-4A98-8165-C0FF206F6E6D" XCODE_PROJECT="$PROJECT_DIR$/sentry-samples/kmp-app-spm/iosApp.xcodeproj" XCODE_CONFIGURATION="Debug" XCODE_SCHEME="iosApp">
<configuration default="false" name="iosApp-spm" type="KmmRunConfiguration" factoryName="iOS Application" CONFIG_VERSION="1" EXEC_TARGET_ID="EA7F395B-4B34-4EEA-8D00-85297FF4E3BD" XCODE_PROJECT="$PROJECT_DIR$/sentry-samples/kmp-app-spm/iosApp.xcodeproj" XCODE_CONFIGURATION="Debug" XCODE_SCHEME="iosApp">
<method v="2">
<option name="com.jetbrains.kmm.ios.BuildIOSAppTask" enabled="true" />
</method>
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

### Features

- New Sentry KMP Gradle plugin ([#230](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/230))
- Install via `plugins { id("io.sentry.kotlin.multiplatform.gradle") version "{version}" }`
- Enables auto installing of the KMP SDK to commonMain (if all targets are supported)
- Enables auto installing of the required Sentry Cocoa SDK with Cocoapods (if Cocoapods plugin is enabled)
- Configures linking for SPM (needed if you want to compile a dynamic framework)
- Configure via the `sentryKmp` configuration block in your build file

### Dependencies

- Bump Kotlin version from v1.9.21 to v1.9.23 ([#250](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/250))
Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ spotless {

kotlin {
target("**/*.kt")
targetExclude("**/generated/**/*.kt")
ktlint()
}
kotlinGradle {
target("**/*.kts")
targetExclude("**/generated/**/*.kts")
ktlint()
}
}
Expand Down Expand Up @@ -115,3 +117,8 @@ val detektProjectBaseline by tasks.registering(io.gitlab.arturbosch.detekt.Detek
include("**/*.kt")
detektExcludes()
}

// Configure tasks so it is also run for the plugin
tasks.getByName("detekt") {
gradle.includedBuild("sentry-kotlin-multiplatform-gradle-plugin").task(":detekt")
}
2 changes: 1 addition & 1 deletion scripts/build-jvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ -z "$1" ]; then
fi

PROJECT_NAME="$1"
./gr

./gradlew "testDebugUnitTest" \
"testReleaseUnitTest" \
"publishAndroidReleasePublicationToMavenLocal" \
Expand Down
2 changes: 2 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ OLD_VERSION="$1"
NEW_VERSION="$2"

GRADLE_FILEPATH="gradle.properties"
PLUGIN_GRADLE_FILEPATH="sentry-kotlin-multiplatform-gradle-plugin/gradle.properties"

# Replace `versionName` with the given version
VERSION_NAME_PATTERN="versionName"
perl -pi -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $GRADLE_FILEPATH
perl -pi -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $PLUGIN_GRADLE_FILEPATH
100 changes: 100 additions & 0 deletions sentry-kotlin-multiplatform-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import com.vanniktech.maven.publish.MavenPublishPluginExtension
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.detekt)
`java-gradle-plugin`
alias(libs.plugins.vanniktech.publish)
id("distribution")
alias(libs.plugins.buildConfig)
alias(libs.plugins.kover)
}

version = property("versionName").toString()

group = property("group").toString()

dependencies {
compileOnly(kotlin("stdlib"))
compileOnly(gradleApi())
compileOnly(kotlin("gradle-plugin"))

testImplementation(kotlin("gradle-plugin"))
testImplementation(libs.junit)
testImplementation(libs.junit.params)
testImplementation(libs.mockk)
}

tasks.test {
useJUnitPlatform()
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

tasks.withType<KotlinCompile> { kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() } }

gradlePlugin {
plugins {
create(property("id").toString()) {
id = property("id").toString()
implementationClass = property("implementationClass").toString()
}
}
}

val publish = extensions.getByType(MavenPublishPluginExtension::class.java)
// signing is done when uploading files to MC
// via gpg:sign-and-deploy-file (release.kts)
publish.releaseSigningEnabled = false

tasks.named("distZip").configure {
dependsOn("publishToMavenLocal")
this.doLast {
val distributionFilePath =
"${project.layout.buildDirectory.asFile.get().path}${sep}distributions${sep}${project.name}-${project.version}.zip"
val file = File(distributionFilePath)
if (!file.exists()) {
throw IllegalStateException("Distribution file: $distributionFilePath does not exist")
}
if (file.length() == 0L) {
throw IllegalStateException("Distribution file: $distributionFilePath is empty")
}
}
}

val sep = File.separator

distributions {
main {
contents {
from("build${sep}libs")
from("build${sep}publications${sep}maven")
}
}
}

buildConfig {
useKotlinOutput()
packageName("io.sentry")
className("BuildConfig")

buildConfigField(
"String",
"SentryCocoaVersion",
provider { "\"${project.property("sentryCocoaVersion")}\"" }
)
}

detekt { config.setFrom(rootProject.files("../config/detekt/detekt.yml")) }

tasks.withType<Detekt>().configureEach {
reports {
html.required.set(true)
html.outputLocation.set(file("build/reports/detekt.html"))
}
}
6 changes: 6 additions & 0 deletions sentry-kotlin-multiplatform-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id=io.sentry.kotlin.multiplatform.gradle
implementationClass=io.sentry.kotlin.multiplatform.gradle.SentryPlugin
versionName=0.7.1
group=io.sentry
# TODO: Update update-cocoa.sh so the cocoa version is auto updated as well
sentryCocoaVersion=8.26.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[versions]
detekt = "1.23.6"
kotlin = "1.9.23"
pluginPublish = "1.2.1"
buildConfig = "5.3.5"
vanniktechPublish = "0.18.0"
kover = "0.7.3"

[plugins]
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt"}
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"}
pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "pluginPublish"}
vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechPublish"}
buildConfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildConfig"}
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover"}

[libraries]
junit = "org.junit.jupiter:junit-jupiter-api:5.10.3"
junit-params = "org.junit.jupiter:junit-jupiter-params:5.10.3"
mockk = "io.mockk:mockk:1.13.12"
1 change: 1 addition & 0 deletions sentry-kotlin-multiplatform-gradle-plugin/gradle/wrapper
1 change: 1 addition & 0 deletions sentry-kotlin-multiplatform-gradle-plugin/gradlew
1 change: 1 addition & 0 deletions sentry-kotlin-multiplatform-gradle-plugin/gradlew.bat
15 changes: 15 additions & 0 deletions sentry-kotlin-multiplatform-gradle-plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}

rootProject.name = "sentry-kotlin-multiplatform-gradle-plugin"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.sentry.kotlin.multiplatform.gradle

import org.gradle.api.Project
import org.gradle.api.provider.Property
import javax.inject.Inject

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

/**
* Enable auto-installation of the Sentry dependencies through [CocoapodsAutoInstallExtension]
* 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 commonMain: SourceSetAutoInstallExtension =
objects.newInstance(SourceSetAutoInstallExtension::class.java, project)
}
Loading
Loading