Skip to content

Commit 4c99f04

Browse files
committed
feat: Add Sentry for error reporting
1 parent 4e906fe commit 4c99f04

28 files changed

+201
-717
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: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,52 @@ 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: 21
2323
- name: Setup Gradle
24-
uses: gradle/actions/setup-gradle@v4
24+
uses: gradle/actions/setup-gradle@v5
2525
with:
2626
cache-read-only: true
27-
- name: Setup publish token
27+
- name: Setup tokens
2828
env:
2929
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_TOKEN }}
30+
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
3031
shell: bash
3132
run: |
3233
mkdir -p ~/.gradle/
3334
echo "GRADLE_USER_HOME=$HOME/.gradle" >> "$GITHUB_ENV"
3435
echo "mcdev.deploy.token=${JETBRAINS_TOKEN}" > ~/.gradle/gradle.properties
35-
- shell: bash
36-
run: |
37-
mkdir -p ~/.gradle/
36+
echo -e '\nmcdev.sentry.token=${SENTRY_TOKEN}\n' >> ~/.gradle/gradle.properties
3837
echo -e '\norg.gradle.jvmargs=-Xmx4G\n' >> ~/.gradle/gradle.properties
39-
- name: Publish plugin
40-
run: ./gradlew clean :publishPlugin --stacktrace
4138
- name: Get tag name
4239
id: get_tag
4340
shell: bash
4441
# Tag name is reversed from release name due to how IntelliJ parses plugin version numbers
4542
run: |
4643
tag_name="$(echo $GITHUB_REF | cut -d / -f 3)"
47-
echo ::set-output name=tag::$tag_name
44+
echo tag=$tag_name >> $GITHUB_OUTPUT
4845
version_array=(${tag_name//-/ })
49-
echo ::set-output name=release::${version_array[1]}-${version_array[0]}
46+
echo release=${version_array[1]}-${version_array[0]} >> $GITHUB_OUTPUT
47+
- name: Create Sentry release
48+
uses: getsentry/action-release@v3
49+
env:
50+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
51+
SENTRY_ORG: mcdev
52+
SENTRY_PROJECT: mcdev
53+
SENTRY_URL: https://sentry.mcdev.io
54+
with:
55+
environment: production
56+
version: ${{ steps.get_tag.outputs.release }}
57+
- name: Publish plugin
58+
run: ./gradlew clean :sentryUploadSourceBundleJava :publishPlugin --stacktrace
5059
- name: Create GitHub Release
5160
uses: softprops/action-gh-release@v2
5261
env:

.github/workflows/test.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,29 @@ 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: 21
2626
- uses: actions-ecosystem/action-regex-match@d50fd2e7a37d0e617aea3d7ada663bd56862b9cc
2727
id: branch-match
2828
with:
2929
text: ${{ github.ref }}
3030
regex: '^refs\/heads\/\d{4}\.\d$'
3131
- name: Setup Gradle
32-
uses: gradle/actions/setup-gradle@v4
32+
uses: gradle/actions/setup-gradle@v5
3333
with:
3434
cache-read-only: ${{ github.ref != 'refs/heads/dev' && steps.branch-match.outputs.match == '' }}
3535
- shell: bash
3636
run: |
3737
mkdir -p ~/.gradle/
3838
echo -e '\norg.gradle.jvmargs=-Xmx4G\n' >> ~/.gradle/gradle.properties
3939
- name: Build
40-
run: ./gradlew build --stacktrace
40+
run: ./gradlew :build --stacktrace
41+
env:
42+
NO_SENTRY: "true"
4143
- name: Upload test reports
4244
if: always()
4345
uses: actions/upload-artifact@v4

build.gradle.kts

Lines changed: 43 additions & 17 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" && System.getenv("NO_SENTRY") != "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)
@@ -167,20 +169,17 @@ tasks.patchPluginXml {
167169
changeNotes = changelog.render(Changelog.OutputType.HTML)
168170
}
169171

170-
// Compile classes to be loaded into the Gradle VM to Java 5 to match Groovy
172+
// Compile classes to be loaded into the Gradle VM to Java 8
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+
options.release = 8
178177
options.compilerArgs = listOf("-Xlint:-options")
179178
}
180179
tasks.withType<GroovyCompile>().configureEach {
181180
options.compilerArgs = listOf("-proc:none")
182-
sourceCompatibility = "1.5"
183-
targetCompatibility = "1.5"
181+
sourceCompatibility = "1.8"
182+
targetCompatibility = "1.8"
184183
}
185184

186185
tasks.processResources {
@@ -222,6 +221,7 @@ idea {
222221
license {
223222
val endings = listOf("java", "kt", "kts", "groovy", "gradle.kts", "xml", "properties", "html", "flex", "bnf")
224223
exclude("META-INF/plugin.xml") // https://youtrack.jetbrains.com/issue/IDEA-345026
224+
exclude("sentry-debug-meta.properties", "sentry-external-modules.txt")
225225
include(endings.map { "**/*.$it" })
226226

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

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

0 commit comments

Comments
 (0)