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 {
@@ -217,6 +216,7 @@ idea {
217216license {
218217 val endings = listOf (" java" , " kt" , " kts" , " groovy" , " gradle.kts" , " xml" , " properties" , " html" , " flex" , " bnf" )
219218 exclude(" META-INF/plugin.xml" ) // https://youtrack.jetbrains.com/issue/IDEA-345026
219+ exclude(" sentry-debug-meta.properties" , " sentry-external-modules.txt" )
220220 include(endings.map { " **/*.$it " })
221221
222222 val projectDir = layout.projectDirectory.asFile
@@ -333,3 +333,29 @@ tasks.runIde {
333333 // systemProperty("user.language", "fr")
334334 // systemProperty("user.country", "FR")
335335}
336+
337+ if (System .getenv(" CI" ) == " true" && System .getenv(" NO_SENTRY" ) != " true" ) {
338+ configure<SentryPluginExtension > {
339+ includeSourceContext = true
340+ includeDependenciesReport = true
341+ autoInstallation {
342+ enabled = false
343+ }
344+
345+ url = " https://sentry.mcdev.io/"
346+ org = " mcdev"
347+ projectName = " mcdev"
348+ authToken = providers.gradleProperty(" mcdev.sentry.token" )
349+ }
350+
351+ // Wire together some tasks to make Gradle happy
352+ tasks.named(" generateSentryBundleIdJava" ) {
353+ dependsOn(generate)
354+ }
355+ tasks.named(" sentryCollectSourcesJava" ) {
356+ dependsOn(generate)
357+ }
358+ tasks.checkLicenseMain {
359+ dependsOn(tasks.named(" generateSentryDebugMetaPropertiesjava" ), tasks.named(" collectExternalDependenciesForSentry" ))
360+ }
361+ }
0 commit comments