Skip to content

Commit 449ec91

Browse files
committed
feature: Add Sentry for error reporting
1 parent 4e906fe commit 449ec91

27 files changed

+209
-713
lines changed

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ jobs:
88
name: Validation
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v4
12-
- uses: gradle/actions/wrapper-validation@v4
11+
- uses: actions/checkout@v5
12+
- uses: gradle/actions/wrapper-validation@v5

.github/workflows/pr_check_target_branch.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
# Do not check out the repository here. See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
12-
- uses: Vankka/pr-target-branch-action@v2.1
12+
- uses: Vankka/pr-target-branch-action@v3
1313
env:
1414
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1515
with:
@@ -20,4 +20,3 @@ jobs:
2020
comment: |
2121
New PRs should target the `dev` branch. The base branch of this PR has been automatically changed to `dev`.
2222
Please check that there are no merge conflicts.
23-

.github/workflows/publish.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,55 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout sources
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414
with:
1515
submodules: true
1616
- name: Fetch latest submodule updates
1717
run: git submodule update --remote
1818
- name: Setup Java
19-
uses: actions/setup-java@v4
19+
uses: actions/setup-java@v5
2020
with:
2121
distribution: 'temurin'
22-
java-version: 17
22+
java-version: |
23+
8
24+
11
25+
21
2326
- name: Setup Gradle
24-
uses: gradle/actions/setup-gradle@v4
27+
uses: gradle/actions/setup-gradle@v5
2528
with:
2629
cache-read-only: true
27-
- name: Setup publish token
30+
- name: Setup tokens
2831
env:
2932
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_TOKEN }}
33+
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
3034
shell: bash
3135
run: |
3236
mkdir -p ~/.gradle/
3337
echo "GRADLE_USER_HOME=$HOME/.gradle" >> "$GITHUB_ENV"
3438
echo "mcdev.deploy.token=${JETBRAINS_TOKEN}" > ~/.gradle/gradle.properties
35-
- shell: bash
36-
run: |
37-
mkdir -p ~/.gradle/
39+
echo -e '\nmcdev.sentry.token=${SENTRY_TOKEN}\n' >> ~/.gradle/gradle.properties
3840
echo -e '\norg.gradle.jvmargs=-Xmx4G\n' >> ~/.gradle/gradle.properties
39-
- name: Publish plugin
40-
run: ./gradlew clean :publishPlugin --stacktrace
4141
- name: Get tag name
4242
id: get_tag
4343
shell: bash
4444
# Tag name is reversed from release name due to how IntelliJ parses plugin version numbers
4545
run: |
4646
tag_name="$(echo $GITHUB_REF | cut -d / -f 3)"
47-
echo ::set-output name=tag::$tag_name
47+
echo tag=$tag_name >> $GITHUB_OUTPUT
4848
version_array=(${tag_name//-/ })
49-
echo ::set-output name=release::${version_array[1]}-${version_array[0]}
49+
echo release=${version_array[1]}-${version_array[0]} >> $GITHUB_OUTPUT
50+
- name: Create Sentry release
51+
uses: getsentry/action-release@v3
52+
env:
53+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
54+
SENTRY_ORG: mcdev
55+
SENTRY_PROJECT: mcdev
56+
SENTRY_URL: https://sentry.mcdev.io
57+
with:
58+
environment: production
59+
version: ${{ steps.get_tag.outputs.release }}
60+
- name: Publish plugin
61+
run: ./gradlew clean :sentryUploadSourceBundleJava :publishPlugin --stacktrace
5062
- name: Create GitHub Release
5163
uses: softprops/action-gh-release@v2
5264
env:

.github/workflows/test.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,30 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
steps:
1919
- name: Checkout sources
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v5
2121
- name: Setup Java
22-
uses: actions/setup-java@v4
22+
uses: actions/setup-java@v5
2323
with:
2424
distribution: 'temurin'
25-
java-version: 17
25+
java-version: |
26+
8
27+
11
28+
21
2629
- uses: actions-ecosystem/action-regex-match@d50fd2e7a37d0e617aea3d7ada663bd56862b9cc
2730
id: branch-match
2831
with:
2932
text: ${{ github.ref }}
3033
regex: '^refs\/heads\/\d{4}\.\d$'
3134
- name: Setup Gradle
32-
uses: gradle/actions/setup-gradle@v4
35+
uses: gradle/actions/setup-gradle@v5
3336
with:
3437
cache-read-only: ${{ github.ref != 'refs/heads/dev' && steps.branch-match.outputs.match == '' }}
3538
- shell: bash
3639
run: |
3740
mkdir -p ~/.gradle/
3841
echo -e '\norg.gradle.jvmargs=-Xmx4G\n' >> ~/.gradle/gradle.properties
3942
- name: Build
40-
run: ./gradlew build --stacktrace
43+
run: ./gradlew :build --stacktrace
4144
- name: Upload test reports
4245
if: always()
4346
uses: actions/upload-artifact@v4

build.gradle.kts

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1919
*/
2020

21-
import org.gradle.internal.jvm.Jvm
21+
import io.sentry.android.gradle.extensions.SentryPluginExtension
22+
import org.gradle.kotlin.dsl.configure
2223
import org.jetbrains.changelog.Changelog
2324
import org.jetbrains.gradle.ext.settings
2425
import org.jetbrains.gradle.ext.taskTriggers
@@ -32,6 +33,7 @@ plugins {
3233
`mcdev-core`
3334
`mcdev-parsing`
3435
`mcdev-publishing`
36+
alias(libs.plugins.sentry) apply (System.getenv("CI") == "true")
3537
}
3638

3739
val coreVersion: String by project
@@ -43,32 +45,32 @@ val testLibs: Configuration by configurations.creating {
4345

4446
group = "com.demonwav.mcdev"
4547

46-
val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension") {
48+
val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension", Action<SourceSet> {
4749
configurations.named(compileOnlyConfigurationName) {
4850
extendsFrom(gradleToolingExtension)
4951
}
50-
}
52+
})
5153
val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSourceSet.jarTaskName) {
5254
from(gradleToolingExtensionSourceSet.output)
5355
archiveClassifier.set("gradle-tooling-extension")
5456
exclude("META-INF/plugin.xml")
5557
}
5658

57-
val templatesSourceSet: SourceSet = sourceSets.create("templates") {
59+
val templatesSourceSet: SourceSet = sourceSets.create("templates", Action<SourceSet> {
5860
resources {
5961
srcDir("templates")
6062
compileClasspath += sourceSets.main.get().output
6163
}
62-
}
64+
})
6365

6466
val templateSourceSets: List<SourceSet> = (file("templates").listFiles() ?: emptyArray()).mapNotNull { file ->
6567
if (file.isDirectory() && (file.listFiles() ?: emptyArray()).any { it.name.endsWith(".mcdev.template.json") }) {
66-
sourceSets.create("templates-${file.name}") {
68+
sourceSets.create("templates-${file.name}", Action<SourceSet> {
6769
resources {
6870
srcDir(file)
6971
compileClasspath += sourceSets.main.get().output
7072
}
71-
}
73+
})
7274
} else {
7375
null
7476
}
@@ -81,9 +83,6 @@ val externalAnnotationsJar = tasks.register<Jar>("externalAnnotationsJar") {
8183
}
8284

8385
dependencies {
84-
// Add tools.jar for the JDI API
85-
implementation(files(Jvm.current().toolsJar))
86-
8786
implementation(files(gradleToolingExtensionJar))
8887

8988
implementation(libs.mixinExtras.expressions) {
@@ -96,6 +95,9 @@ dependencies {
9695
implementation(libs.bundles.asm)
9796

9897
implementation(libs.bundles.fuel)
98+
implementation(libs.sentry) {
99+
exclude(group = "org.slf4j")
100+
}
99101

100102
intellijPlatform {
101103
intellijIdeaCommunity(libs.versions.intellij.ide, useInstaller = false)
@@ -171,10 +173,12 @@ tasks.patchPluginXml {
171173
// This is for maximum compatibility, these classes will be loaded into every Gradle import on all
172174
// projects (not just Minecraft), so we don't want to break that with an incompatible class version.
173175
tasks.named(gradleToolingExtensionSourceSet.compileJavaTaskName, JavaCompile::class) {
174-
val java7Compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(11)) }
175-
javaCompiler.set(java7Compiler)
176-
options.release.set(6)
177-
options.bootstrapClasspath = files(java7Compiler.map { it.metadata.installationPath.file("jre/lib/rt.jar") })
176+
val java8Compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(8)) }
177+
javaCompiler.set(java8Compiler)
178+
sourceCompatibility = "1.5"
179+
targetCompatibility = "1.5"
180+
options.release.unset()
181+
options.bootstrapClasspath = files(java8Compiler.map { it.metadata.installationPath.file("jre/lib/rt.jar") })
178182
options.compilerArgs = listOf("-Xlint:-options")
179183
}
180184
tasks.withType<GroovyCompile>().configureEach {
@@ -222,6 +226,7 @@ idea {
222226
license {
223227
val endings = listOf("java", "kt", "kts", "groovy", "gradle.kts", "xml", "properties", "html", "flex", "bnf")
224228
exclude("META-INF/plugin.xml") // https://youtrack.jetbrains.com/issue/IDEA-345026
229+
exclude("sentry-debug-meta.properties", "sentry-external-modules.txt")
225230
include(endings.map { "**/*.$it" })
226231

227232
val projectDir = layout.projectDirectory.asFile
@@ -338,3 +343,29 @@ tasks.runIde {
338343
// systemProperty("user.language", "fr")
339344
// systemProperty("user.country", "FR")
340345
}
346+
347+
if (System.getenv("CI") == "true") {
348+
configure<SentryPluginExtension> {
349+
includeSourceContext = true
350+
includeDependenciesReport = true
351+
autoInstallation {
352+
enabled = false
353+
}
354+
355+
url = "https://sentry.mcdev.io/"
356+
org = "mcdev"
357+
projectName = "mcdev"
358+
authToken = providers.gradleProperty("mcdev.sentry.token")
359+
}
360+
361+
// Wire together some tasks to make Gradle happy
362+
tasks.named("generateSentryBundleIdJava") {
363+
dependsOn(generate)
364+
}
365+
tasks.named("sentryCollectSourcesJava") {
366+
dependsOn(generate)
367+
}
368+
tasks.checkLicenseMain {
369+
dependsOn(tasks.named("generateSentryDebugMetaPropertiesjava"), tasks.named("collectExternalDependenciesForSentry"))
370+
}
371+
}

buildSrc/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ tasks.withType<KotlinCompile>().configureEach {
3535
repositories {
3636
mavenCentral()
3737
gradlePluginPortal()
38+
maven("https://maven.neoforged.net/releases/") {
39+
content {
40+
includeGroupAndSubgroups("net.neoforged")
41+
}
42+
}
3843
}
3944

4045
dependencies {

buildSrc/src/main/kotlin/mcdev-core.gradle.kts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020

2121
import org.cadixdev.gradle.licenser.header.HeaderStyle
2222
import org.gradle.accessors.dm.LibrariesForLibs
23+
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
2324
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2425
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
25-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
26+
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon
2627

2728
plugins {
2829
java
2930
idea
3031
id("org.jetbrains.kotlin.jvm")
3132
id("org.jetbrains.intellij.platform")
32-
id("org.cadixdev.licenser")
33+
id("net.neoforged.licenser")
3334
}
3435

3536
val ideaVersionName: String by project
@@ -40,7 +41,7 @@ version = "$ideaVersionName-$coreVersion"
4041

4142
// Build numbers are used for nightlies
4243
if (buildNumber != null) {
43-
version = "$version-$buildNumber"
44+
version = "$version-nightly+$buildNumber"
4445
}
4546

4647
java {
@@ -59,27 +60,29 @@ kotlin {
5960
jvmToolchain {
6061
languageVersion.set(JavaLanguageVersion.of(21))
6162
}
62-
}
63-
64-
tasks.withType<KotlinCompile>().configureEach {
6563
compilerOptions {
6664
jvmTarget = JvmTarget.JVM_21
67-
languageVersion = KotlinVersion.KOTLIN_2_0
68-
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=21")
65+
languageVersion = KotlinVersion.KOTLIN_2_2
66+
jvmDefault = JvmDefaultMode.NO_COMPATIBILITY
67+
freeCompilerArgs = listOf("-Xjdk-release=21")
6968
optIn.add("kotlin.contracts.ExperimentalContracts")
7069
}
70+
}
71+
tasks.withType<CompileUsingKotlinDaemon>().configureEach {
7172
kotlinDaemonJvmArguments.add("-Xmx2G")
7273
}
7374

7475
repositories {
75-
maven("https://repo.denwav.dev/repository/maven-public/")
76+
intellijPlatform {
77+
defaultRepositories()
78+
}
79+
7680
maven("https://maven.fabricmc.net/") {
7781
content {
7882
includeModule("net.fabricmc", "mapping-io")
7983
includeModule("net.fabricmc", "fabric-loader")
8084
}
8185
}
82-
mavenCentral()
8386
maven("https://repo.spongepowered.org/maven/") {
8487
content {
8588
includeGroup("org.spongepowered")
@@ -96,9 +99,8 @@ repositories {
9699
}
97100
}
98101

99-
intellijPlatform {
100-
defaultRepositories()
101-
}
102+
mavenCentral()
103+
maven("https://repo.denwav.dev/repository/maven-public/")
102104
}
103105

104106
val libs = the<LibrariesForLibs>()

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ org.gradle.jvmargs=-Xmx1g
2323

2424
ideaVersionName = 2024.3
2525

26-
coreVersion = 1.8.6
26+
coreVersion = 1.8.7
2727

2828
# Silences a build-time warning because we are bundling our own kotlin library
2929
kotlin.stdlib.default.dependency = false

gradle/libs.versions.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[versions]
2-
kotlin = "2.0.20"
2+
kotlin = "2.2.20"
33
coroutines = "1.9.0-RC.2"
44
junit = "5.10.2"
55
junit-platform = "1.10.2"
66
asm = "9.6"
77
fuel = "2.3.1"
8-
licenser = "0.6.1"
8+
licenser = "0.7.5"
99
changelog = "2.2.0"
1010
intellij-plugin = "2.5.0"
1111
intellij-plugin-repository-rest-client = "2.0.46"
@@ -17,8 +17,9 @@ psiPlugin = "243.7768"
1717
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
1818
intellij-platform = { id = "org.jetbrains.intellij.platform", version.ref = "intellij-plugin" }
1919
idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "idea-ext" }
20-
licenser = { id = "org.cadixdev.licenser", version.ref = "licenser" }
20+
licenser = { id = "net.neoforged.licenser", version.ref = "licenser" }
2121
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
22+
sentry = "io.sentry.jvm.gradle:5.8.0"
2223

2324
[libraries]
2425
intellij-plugin-repository-rest-client = { module = "org.jetbrains.intellij:plugin-repository-rest-client", version.ref = "intellij-plugin-repository-rest-client" }
@@ -28,7 +29,7 @@ kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.re
2829
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
2930

3031
intellij-plugin = { module = "org.jetbrains.intellij.platform:org.jetbrains.intellij.platform.gradle.plugin", version.ref = "intellij-plugin" }
31-
licenser-plugin = { module = "org.cadixdev.licenser:org.cadixdev.licenser.gradle.plugin", version.ref = "licenser" }
32+
licenser-plugin = { module = "net.neoforged.licenser:net.neoforged.licenser.gradle.plugin", version.ref = "licenser" }
3233
changelog-plugin = { module = "org.jetbrains.changelog:org.jetbrains.changelog.gradle.plugin", version.ref = "changelog" }
3334

3435
coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }
@@ -57,6 +58,8 @@ gson = "com.google.code.gson:gson:2.10.1"
5758
fuel = { module = "com.github.kittinunf.fuel:fuel", version.ref = "fuel" }
5859
fuel-coroutines = { module = "com.github.kittinunf.fuel:fuel-coroutines", version.ref = "fuel" }
5960

61+
sentry = "io.sentry:sentry:8.22.0"
62+
6063
# Testing
6164
test-mixin = "org.spongepowered:mixin:0.8.5"
6265
test-spigotapi = "org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT"

gradle/wrapper/gradle-wrapper.jar

1.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)