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
2223import org.jetbrains.changelog.Changelog
2324import org.jetbrains.gradle.ext.settings
2425import 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
3739val coreVersion: String by project
@@ -43,32 +45,32 @@ val testLibs: Configuration by configurations.creating {
4345
4446group = " 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+ })
5153val 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
6466val 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
8385dependencies {
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.
173175tasks.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}
180179tasks.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
186185tasks.processResources {
@@ -222,6 +221,7 @@ idea {
222221license {
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+ }
0 commit comments