Skip to content

Commit eebb710

Browse files
committed
Merge branch '2024.2' into 2024.3
# Conflicts: # gradle.properties # gradle/libs.versions.toml
2 parents def63cd + 17c3ac6 commit eebb710

File tree

12 files changed

+154
-39
lines changed

12 files changed

+154
-39
lines changed

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ dependencies {
4545
implementation(libs.intellij.plugin)
4646
implementation(libs.licenser.plugin)
4747
implementation(libs.changelog.plugin)
48+
implementation(libs.intellij.plugin.repository.rest.client)
4849
}

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

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

21+
import java.io.IOException
22+
import java.net.URI
23+
import java.net.http.HttpClient
24+
import java.net.http.HttpRequest
25+
import java.net.http.HttpResponse
26+
import kotlin.io.path.absolute
27+
import org.jetbrains.intellij.platform.gradle.utils.IdeServicesPluginRepositoryService
28+
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
29+
2130
plugins {
2231
id("org.jetbrains.intellij.platform")
2332
}
@@ -27,4 +36,63 @@ tasks.publishPlugin {
2736
token.set(deployToken.toString())
2837
}
2938
channels.add(properties["mcdev.deploy.channel"]?.toString() ?: "Stable")
39+
40+
// Overwrite the publish action, to properly set the until version after publishing (otherwise they ignore it).
41+
// See https://youtrack.jetbrains.com/issue/IJPL-166094/Plugins-Disable-until-build-range-check-by-default
42+
actions = listOf(Action {
43+
if (token.orNull.isNullOrEmpty()) {
44+
throw GradleException("No token specified for publishing. Make sure to specify mcdev.deploy.token.")
45+
}
46+
47+
val log = Logging.getLogger(javaClass)
48+
49+
val path = archiveFile.get().asFile.toPath().absolute()
50+
val pluginId = "com.demonwav.minecraft-dev"
51+
channels.get().forEach { channel ->
52+
log.info("Uploading plugin '$pluginId' from '$path' to '${host.get()}', channel: '$channel'")
53+
54+
try {
55+
val repositoryClient = when (ideServices.get()) {
56+
true -> PluginRepositoryFactory.createWithImplementationClass(
57+
host.get(),
58+
token.get(),
59+
"Automation",
60+
IdeServicesPluginRepositoryService::class.java,
61+
)
62+
63+
false -> PluginRepositoryFactory.create(host.get(), token.get())
64+
}
65+
@Suppress("DEPRECATION")
66+
val uploadBean = repositoryClient.uploader.upload(
67+
id = pluginId,
68+
file = path.toFile(),
69+
channel = channel.takeIf { it != "default" },
70+
notes = null,
71+
isHidden = hidden.get(),
72+
)
73+
log.info("Uploaded successfully as version ID ${uploadBean.id}")
74+
75+
val since = uploadBean.since
76+
log.info("Since is ${since}, until is ${uploadBean.until}")
77+
if (since != null && uploadBean.until.isNullOrBlank()) {
78+
val newUntil = since.substringBefore(".") + ".*"
79+
log.info("Updating until to $newUntil")
80+
val request = HttpRequest.newBuilder()
81+
.uri(URI.create("https://plugins.jetbrains.com/api/updates/${uploadBean.id}/since-until"))
82+
.header("Authorization", "Bearer ${token.get()}")
83+
.header("Content-Type", "application/json")
84+
.header("User-Agent", "Minecraft Development Plugin Publisher")
85+
.POST(HttpRequest.BodyPublishers.ofString("{\"since\":\"${uploadBean.since}\",\"until\":\"$newUntil\"}"))
86+
.build()
87+
val response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString())
88+
if (response.statusCode() < 200 || response.statusCode() >= 300) {
89+
throw IOException("Updating until failed with status code ${response.statusCode()}, ${response.body()}")
90+
}
91+
log.info("Successful with status code ${response.statusCode()}")
92+
}
93+
} catch (exception: Exception) {
94+
throw GradleException("Failed to upload plugin: ${exception.message}", exception)
95+
}
96+
}
97+
})
3098
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#
2020

2121
# suppress inspection "UnusedProperty" for whole file
22+
org.gradle.jvmargs=-Xmx1g
23+
2224
ideaVersionName = 2024.3
2325

2426
coreVersion = 1.8.4

gradle/libs.versions.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ asm = "9.6"
77
fuel = "2.3.1"
88
licenser = "0.6.1"
99
changelog = "2.2.0"
10-
intellij-plugin = "2.4.0"
10+
intellij-plugin = "2.5.0"
11+
intellij-plugin-repository-rest-client = "2.0.46"
1112
intellij-ide = "2024.3.5"
12-
idea-ext = "1.1.8"
13+
idea-ext = "1.1.10"
1314
psiPlugin = "243.7768"
1415

1516
[plugins]
@@ -20,6 +21,8 @@ licenser = { id = "org.cadixdev.licenser", version.ref = "licenser" }
2021
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
2122

2223
[libraries]
24+
intellij-plugin-repository-rest-client = { module = "org.jetbrains.intellij:plugin-repository-rest-client", version.ref = "intellij-plugin-repository-rest-client" }
25+
2326
kotlin-plugin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" }
2427
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
2528
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }

readme.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ Minecraft Development for IntelliJ
1111
<td align="right"><b>Main Build</b></td>
1212
<td colspan="2"><a href="https://ci.mcdev.io/viewType.html?buildTypeId=MinecraftDev_Build"><img src="https://ci.mcdev.io/app/rest/builds/buildType:(id:MinecraftDev_Build)/statusIcon.svg" alt="Teamcity Build Status" /></a></td>
1313
</tr>
14-
<tr>
15-
<td align="left">2024.1</td>
16-
<td align="left"><a href="https://ci.mcdev.io/viewType.html?buildTypeId=MinecraftDev_Nightly_20241"><img src="https://ci.mcdev.io/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20241)/statusIcon.svg" alt="2024.1 Nightly Status" /></a></td>
17-
</tr>
1814
<tr>
1915
<td align="left">2024.2</td>
2016
<td align="left"><a href="https://ci.mcdev.io/viewType.html?buildTypeId=MinecraftDev_Nightly_20242"><img src="https://ci.mcdev.io/app/rest/builds/buildType:(id:MinecraftDev_Nightly_20242)/statusIcon.svg" alt="2024.2 Nightly Status" /></a></td>
@@ -35,7 +31,7 @@ Minecraft Development for IntelliJ
3531
</tr>
3632
</table>
3733

38-
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.8.1-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
34+
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.8.4-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
3935
----------------------
4036

4137
<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>

src/main/kotlin/platform/fabric/reference/FabricReferenceContributor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class FabricReferenceContributor : PsiReferenceContributor() {
5858

5959
registrar.registerReferenceProvider(
6060
stringInModJson.isPropertyValue("accessWidener"),
61-
ResourceFileReference("access widener '%s'", Regex("(.+)\\.accesswidener")),
61+
ResourceFileReference("access widener '%s'", Regex("(.+)\\.(accesswidener|aw)")),
6262
)
6363

6464
registrar.registerReferenceProvider(

src/main/kotlin/platform/mixin/handlers/InjectAnnotationHandler.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.demonwav.mcdev.platform.mixin.util.callbackInfoReturnableType
2727
import com.demonwav.mcdev.platform.mixin.util.callbackInfoType
2828
import com.demonwav.mcdev.platform.mixin.util.getGenericReturnType
2929
import com.demonwav.mcdev.platform.mixin.util.hasAccess
30+
import com.demonwav.mcdev.platform.mixin.util.isFabricMixin
3031
import com.demonwav.mcdev.platform.mixin.util.toPsiType
3132
import com.demonwav.mcdev.util.Parameter
3233
import com.demonwav.mcdev.util.findModule
@@ -131,6 +132,10 @@ class InjectAnnotationHandler : InjectorAnnotationHandler() {
131132
return listOf(MethodSignature(result, PsiTypes.voidType()))
132133
}
133134

135+
override fun canAlwaysBeStatic(method: PsiMethod): Boolean {
136+
return method.isFabricMixin
137+
}
138+
134139
override val allowCoerce = true
135140

136141
override val mixinExtrasExpressionContextType = ExpressionContext.Type.INJECT

src/main/kotlin/platform/mixin/handlers/InjectorAnnotationHandler.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import com.intellij.openapi.project.Project
4545
import com.intellij.psi.PsiAnnotation
4646
import com.intellij.psi.PsiElement
4747
import com.intellij.psi.PsiEllipsisType
48+
import com.intellij.psi.PsiMethod
4849
import com.intellij.psi.PsiType
4950
import com.intellij.psi.util.PsiModificationTracker
5051
import com.llamalad7.mixinextras.expression.impl.point.ExpressionContext
@@ -171,6 +172,10 @@ abstract class InjectorAnnotationHandler : MixinAnnotationHandler {
171172
return "Cannot resolve any target instructions in target class"
172173
}
173174

175+
open fun canAlwaysBeStatic(method: PsiMethod): Boolean {
176+
return true
177+
}
178+
174179
open val allowCoerce = false
175180

176181
override val isEntryPoint = true

src/main/kotlin/platform/mixin/inspection/MixinCancellableInspection.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class MixinCancellableInspection : MixinInspection() {
6565
} ?: return
6666

6767
val ciType = (ciParam.type as? PsiClassType)?.resolve() ?: return
68-
val searchingFor = ciType.findMethodsByName("setReturnValue", false).firstOrNull()
69-
?: ciType.findMethodsByName("cancel", false).firstOrNull()
70-
?: return
68+
val searchingFor = ciType.findMethodsByName("setReturnValue", false) +
69+
ciType.findMethodsByName("cancel", true)
70+
searchingFor.ifEmpty { return }
7171

7272
var mayUseCancel = false
7373
var definitelyUsesCancel = false
@@ -78,7 +78,7 @@ class MixinCancellableInspection : MixinInspection() {
7878
mayUseCancel = true
7979
}
8080
val methodCall = parent as? PsiReferenceExpression ?: continue
81-
if (methodCall.references.any { it.isReferenceTo(searchingFor) }) {
81+
if (methodCall.references.any { reference -> searchingFor.any(reference::isReferenceTo) }) {
8282
definitelyUsesCancel = true
8383
break
8484
}

src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,19 @@ class InvalidInjectorMethodSignatureInspection : MixinInspection() {
133133
),
134134
)
135135
} else if (!shouldBeStatic && modifiers.hasModifierProperty(PsiModifier.STATIC)) {
136-
reportedStatic = true
137-
holder.registerProblem(
138-
modifiers.findKeyword(PsiModifier.STATIC) ?: identifier,
139-
"Method must not be static",
140-
QuickFixFactory.getInstance().createModifierListFix(
141-
modifiers,
142-
PsiModifier.STATIC,
143-
false,
144-
false,
145-
),
146-
)
136+
if (!handler.canAlwaysBeStatic(method)) {
137+
reportedStatic = true
138+
holder.registerProblem(
139+
modifiers.findKeyword(PsiModifier.STATIC) ?: identifier,
140+
"Method must not be static",
141+
QuickFixFactory.getInstance().createModifierListFix(
142+
modifiers,
143+
PsiModifier.STATIC,
144+
false,
145+
false,
146+
),
147+
)
148+
}
147149
}
148150
}
149151

0 commit comments

Comments
 (0)