User: joe Date: 28 Apr 25 15:34 Revision: 1a3500d1354270394c32118b14dae93c09b8c9cd Summary: Force the until build on marketplace when publishing TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9961&personal=false Index: buildSrc/build.gradle.kts =================================================================== --- buildSrc/build.gradle.kts (revision b526891bfdca0c6ac298adb3633e0d4f14f389e7) +++ buildSrc/build.gradle.kts (revision 1a3500d1354270394c32118b14dae93c09b8c9cd) @@ -45,4 +45,5 @@ implementation(libs.intellij.plugin) implementation(libs.licenser.plugin) implementation(libs.changelog.plugin) + implementation(libs.intellij.plugin.repository.rest.client) } Index: buildSrc/src/main/kotlin/mcdev-publishing.gradle.kts =================================================================== --- buildSrc/src/main/kotlin/mcdev-publishing.gradle.kts (revision b526891bfdca0c6ac298adb3633e0d4f14f389e7) +++ buildSrc/src/main/kotlin/mcdev-publishing.gradle.kts (revision 1a3500d1354270394c32118b14dae93c09b8c9cd) @@ -1,3 +1,12 @@ +import java.io.IOException +import java.net.URI +import java.net.http.HttpClient +import java.net.http.HttpRequest +import java.net.http.HttpResponse +import kotlin.io.path.absolute +import org.jetbrains.intellij.platform.gradle.utils.IdeServicesPluginRepositoryService +import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory + /* * Minecraft Development for IntelliJ * @@ -27,4 +36,63 @@ token.set(deployToken.toString()) } channels.add(properties["mcdev.deploy.channel"]?.toString() ?: "Stable") + + // Overwrite the publish action, to properly set the until version after publishing (otherwise they ignore it). + // See https://youtrack.jetbrains.com/issue/IJPL-166094/Plugins-Disable-until-build-range-check-by-default + actions = listOf(Action { + if (token.orNull.isNullOrEmpty()) { + throw GradleException("No token specified for publishing. Make sure to specify mcdev.deploy.token.") -} + } + + val log = Logging.getLogger(javaClass) + + val path = archiveFile.get().asFile.toPath().absolute() + val pluginId = "com.demonwav.minecraft-dev" + channels.get().forEach { channel -> + log.info("Uploading plugin '$pluginId' from '$path' to '${host.get()}', channel: '$channel'") + + try { + val repositoryClient = when (ideServices.get()) { + true -> PluginRepositoryFactory.createWithImplementationClass( + host.get(), + token.get(), + "Automation", + IdeServicesPluginRepositoryService::class.java, + ) + + false -> PluginRepositoryFactory.create(host.get(), token.get()) + } + @Suppress("DEPRECATION") + val uploadBean = repositoryClient.uploader.upload( + id = pluginId, + file = path.toFile(), + channel = channel.takeIf { it != "default" }, + notes = null, + isHidden = hidden.get(), + ) + log.info("Uploaded successfully as version ID ${uploadBean.id}") + + val since = uploadBean.since + log.info("Since is ${since}, until is ${uploadBean.until}") + if (since != null && uploadBean.until.isNullOrBlank()) { + val newUntil = since.substringBefore(".") + ".*" + log.info("Updating until to $newUntil") + val request = HttpRequest.newBuilder() + .uri(URI.create("https://plugins.jetbrains.com/api/updates/${uploadBean.id}/since-until")) + .header("Authorization", "Bearer ${token.get()}") + .header("Content-Type", "application/json") + .header("User-Agent", "Minecraft Development Plugin Publisher") + .POST(HttpRequest.BodyPublishers.ofString("{\"since\":\"${uploadBean.since}\",\"until\":\"$newUntil\"}")) + .build() + val response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()) + if (response.statusCode() < 200 || response.statusCode() >= 300) { + throw IOException("Updating until failed with status code ${response.statusCode()}, ${response.body()}") + } + log.info("Successful with status code ${response.statusCode()}") + } + } catch (exception: Exception) { + throw GradleException("Failed to upload plugin: ${exception.message}", exception) + } + } + }) +} Index: gradle.properties =================================================================== --- gradle.properties (revision b526891bfdca0c6ac298adb3633e0d4f14f389e7) +++ gradle.properties (revision 1a3500d1354270394c32118b14dae93c09b8c9cd) @@ -19,9 +19,11 @@ # # suppress inspection "UnusedProperty" for whole file +org.gradle.jvmargs=-Xmx1g + ideaVersionName = 2024.2 -coreVersion = 1.8.4 +coreVersion = 1.8.5 # Silences a build-time warning because we are bundling our own kotlin library kotlin.stdlib.default.dependency = false Index: gradle/libs.versions.toml =================================================================== --- gradle/libs.versions.toml (revision b526891bfdca0c6ac298adb3633e0d4f14f389e7) +++ gradle/libs.versions.toml (revision 1a3500d1354270394c32118b14dae93c09b8c9cd) @@ -7,9 +7,10 @@ fuel = "2.3.1" licenser = "0.6.1" changelog = "2.2.0" -intellij-plugin = "2.4.0" +intellij-plugin = "2.5.0" +intellij-plugin-repository-rest-client = "2.0.46" intellij-ide = "2024.2" -idea-ext = "1.1.8" +idea-ext = "1.1.10" psiPlugin = "242.4697" [plugins] @@ -20,6 +21,8 @@ changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } [libraries] +intellij-plugin-repository-rest-client = { module = "org.jetbrains.intellij:plugin-repository-rest-client", version.ref = "intellij-plugin-repository-rest-client" } + kotlin-plugin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" } kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }