Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ jobs:
name: Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
- uses: actions/checkout@v5
- uses: gradle/actions/wrapper-validation@v5
3 changes: 1 addition & 2 deletions .github/workflows/pr_check_target_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Do not check out the repository here. See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- uses: Vankka/pr-target-branch-action@v2.1
- uses: Vankka/pr-target-branch-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -20,4 +20,3 @@ jobs:
comment: |
New PRs should target the `dev` branch. The base branch of this PR has been automatically changed to `dev`.
Please check that there are no merge conflicts.

33 changes: 21 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,52 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: true
- name: Fetch latest submodule updates
run: git submodule update --remote
- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: true
- name: Setup publish token
- name: Setup tokens
env:
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_TOKEN }}
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
shell: bash
run: |
mkdir -p ~/.gradle/
echo "GRADLE_USER_HOME=$HOME/.gradle" >> "$GITHUB_ENV"
echo "mcdev.deploy.token=${JETBRAINS_TOKEN}" > ~/.gradle/gradle.properties
- shell: bash
run: |
mkdir -p ~/.gradle/
echo -e '\nmcdev.sentry.token=${SENTRY_TOKEN}\n' >> ~/.gradle/gradle.properties
echo -e '\norg.gradle.jvmargs=-Xmx4G\n' >> ~/.gradle/gradle.properties
- name: Publish plugin
run: ./gradlew clean :publishPlugin --stacktrace
- name: Get tag name
id: get_tag
shell: bash
# Tag name is reversed from release name due to how IntelliJ parses plugin version numbers
run: |
tag_name="$(echo $GITHUB_REF | cut -d / -f 3)"
echo ::set-output name=tag::$tag_name
echo tag=$tag_name >> $GITHUB_OUTPUT
version_array=(${tag_name//-/ })
echo ::set-output name=release::${version_array[1]}-${version_array[0]}
echo release=${version_array[1]}-${version_array[0]} >> $GITHUB_OUTPUT
- name: Create Sentry release
uses: getsentry/action-release@v3
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
SENTRY_ORG: mcdev
SENTRY_PROJECT: mcdev
SENTRY_URL: https://sentry.mcdev.io
with:
environment: production
version: ${{ steps.get_tag.outputs.release }}
- name: Publish plugin
run: ./gradlew clean :sentryUploadSourceBundleJava :publishPlugin --stacktrace
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
env:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,29 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- uses: actions-ecosystem/action-regex-match@d50fd2e7a37d0e617aea3d7ada663bd56862b9cc
id: branch-match
with:
text: ${{ github.ref }}
regex: '^refs\/heads\/\d{4}\.\d$'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: ${{ github.ref != 'refs/heads/dev' && steps.branch-match.outputs.match == '' }}
- shell: bash
run: |
mkdir -p ~/.gradle/
echo -e '\norg.gradle.jvmargs=-Xmx4G\n' >> ~/.gradle/gradle.properties
- name: Build
run: ./gradlew build --stacktrace
run: ./gradlew :build --stacktrace
env:
NO_SENTRY: "true"
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
Expand Down
60 changes: 43 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import org.gradle.internal.jvm.Jvm
import io.sentry.android.gradle.extensions.SentryPluginExtension
import org.gradle.kotlin.dsl.configure
import org.jetbrains.changelog.Changelog
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers
Expand All @@ -32,6 +33,7 @@ plugins {
`mcdev-core`
`mcdev-parsing`
`mcdev-publishing`
alias(libs.plugins.sentry) apply (System.getenv("CI") == "true" && System.getenv("NO_SENTRY") != "true")
}

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

group = "com.demonwav.mcdev"

val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension") {
val gradleToolingExtensionSourceSet: SourceSet = sourceSets.create("gradle-tooling-extension", Action<SourceSet> {
configurations.named(compileOnlyConfigurationName) {
extendsFrom(gradleToolingExtension)
}
}
})
val gradleToolingExtensionJar = tasks.register<Jar>(gradleToolingExtensionSourceSet.jarTaskName) {
from(gradleToolingExtensionSourceSet.output)
archiveClassifier.set("gradle-tooling-extension")
exclude("META-INF/plugin.xml")
}

val templatesSourceSet: SourceSet = sourceSets.create("templates") {
val templatesSourceSet: SourceSet = sourceSets.create("templates", Action<SourceSet> {
resources {
srcDir("templates")
compileClasspath += sourceSets.main.get().output
}
}
})

val templateSourceSets: List<SourceSet> = (file("templates").listFiles() ?: emptyArray()).mapNotNull { file ->
if (file.isDirectory() && (file.listFiles() ?: emptyArray()).any { it.name.endsWith(".mcdev.template.json") }) {
sourceSets.create("templates-${file.name}") {
sourceSets.create("templates-${file.name}", Action<SourceSet> {
resources {
srcDir(file)
compileClasspath += sourceSets.main.get().output
}
}
})
} else {
null
}
Expand All @@ -81,9 +83,6 @@ val externalAnnotationsJar = tasks.register<Jar>("externalAnnotationsJar") {
}

dependencies {
// Add tools.jar for the JDI API
implementation(files(Jvm.current().toolsJar))

implementation(files(gradleToolingExtensionJar))

implementation(libs.mixinExtras.expressions) {
Expand All @@ -96,6 +95,9 @@ dependencies {
implementation(libs.bundles.asm)

implementation(libs.bundles.fuel)
implementation(libs.sentry) {
exclude(group = "org.slf4j")
}

intellijPlatform {
intellijIdeaCommunity(libs.versions.intellij.ide, useInstaller = false)
Expand Down Expand Up @@ -167,20 +169,17 @@ tasks.patchPluginXml {
changeNotes = changelog.render(Changelog.OutputType.HTML)
}

// Compile classes to be loaded into the Gradle VM to Java 5 to match Groovy
// Compile classes to be loaded into the Gradle VM to Java 8
// This is for maximum compatibility, these classes will be loaded into every Gradle import on all
// projects (not just Minecraft), so we don't want to break that with an incompatible class version.
tasks.named(gradleToolingExtensionSourceSet.compileJavaTaskName, JavaCompile::class) {
val java7Compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(11)) }
javaCompiler.set(java7Compiler)
options.release.set(6)
options.bootstrapClasspath = files(java7Compiler.map { it.metadata.installationPath.file("jre/lib/rt.jar") })
options.release = 8
options.compilerArgs = listOf("-Xlint:-options")
}
tasks.withType<GroovyCompile>().configureEach {
options.compilerArgs = listOf("-proc:none")
sourceCompatibility = "1.5"
targetCompatibility = "1.5"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}

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

val projectDir = layout.projectDirectory.asFile
Expand Down Expand Up @@ -338,3 +338,29 @@ tasks.runIde {
// systemProperty("user.language", "fr")
// systemProperty("user.country", "FR")
}

if (System.getenv("CI") == "true" && System.getenv("NO_SENTRY") != "true") {
configure<SentryPluginExtension> {
includeSourceContext = true
includeDependenciesReport = true
autoInstallation {
enabled = false
}

url = "https://sentry.mcdev.io/"
org = "mcdev"
projectName = "mcdev"
authToken = providers.gradleProperty("mcdev.sentry.token")
}

// Wire together some tasks to make Gradle happy
tasks.named("generateSentryBundleIdJava") {
dependsOn(generate)
}
tasks.named("sentryCollectSourcesJava") {
dependsOn(generate)
}
tasks.checkLicenseMain {
dependsOn(tasks.named("generateSentryDebugMetaPropertiesjava"), tasks.named("collectExternalDependenciesForSentry"))
}
}
5 changes: 5 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ tasks.withType<KotlinCompile>().configureEach {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://maven.neoforged.net/releases/") {
content {
includeGroupAndSubgroups("net.neoforged")
}
}
}

dependencies {
Expand Down
28 changes: 15 additions & 13 deletions buildSrc/src/main/kotlin/mcdev-core.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@

import org.cadixdev.gradle.licenser.header.HeaderStyle
import org.gradle.accessors.dm.LibrariesForLibs
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon

plugins {
java
idea
id("org.jetbrains.kotlin.jvm")
id("org.jetbrains.intellij.platform")
id("org.cadixdev.licenser")
id("net.neoforged.licenser")
}

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

// Build numbers are used for nightlies
if (buildNumber != null) {
version = "$version-$buildNumber"
version = "$version-nightly+$buildNumber"
}

java {
Expand All @@ -59,27 +60,29 @@ kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
languageVersion = KotlinVersion.KOTLIN_2_0
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=21")
languageVersion = KotlinVersion.KOTLIN_2_2
jvmDefault = JvmDefaultMode.NO_COMPATIBILITY
freeCompilerArgs = listOf("-Xjdk-release=21")
optIn.add("kotlin.contracts.ExperimentalContracts")
}
}
tasks.withType<CompileUsingKotlinDaemon>().configureEach {
kotlinDaemonJvmArguments.add("-Xmx2G")
}

repositories {
maven("https://repo.denwav.dev/repository/maven-public/")
intellijPlatform {
defaultRepositories()
}

maven("https://maven.fabricmc.net/") {
content {
includeModule("net.fabricmc", "mapping-io")
includeModule("net.fabricmc", "fabric-loader")
}
}
mavenCentral()
maven("https://repo.spongepowered.org/maven/") {
content {
includeGroup("org.spongepowered")
Expand All @@ -96,9 +99,8 @@ repositories {
}
}

intellijPlatform {
defaultRepositories()
}
mavenCentral()
maven("https://repo.denwav.dev/repository/maven-public/")
}

val libs = the<LibrariesForLibs>()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ org.gradle.jvmargs=-Xmx1g

ideaVersionName = 2024.3

coreVersion = 1.8.6
coreVersion = 1.8.7

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