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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build
.gradle
*.iml
.intellijPlatform
.idea
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [Unreleased]

### Added
- Upgrade the intellij plugin to version 2.x to support all future new IDEA releases

## [1.0.5] - 2025-04-18

### Added
Expand Down
120 changes: 69 additions & 51 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,80 +1,98 @@
import org.jetbrains.changelog.markdownToHTML

fun properties(key: String) = providers.gradleProperty(key).get()
import org.jetbrains.changelog.Changelog

plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.9.0"
id("org.jetbrains.intellij") version "1.16.0"
id("org.jetbrains.intellij.platform") version "2.9.0"
id("org.jetbrains.changelog") version "2.2.0"
}

group = "com.onepiece.wj"
version = properties("plugin.version")
version = providers.gradleProperty("plugin.version").get()

repositories {
maven(url = "https://maven.aliyun.com/repository/public/")
mavenCentral()
// ✅ 关键
intellijPlatform { defaultRepositories() }
}

// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version.set("2023.2.3")
type.set("IU") // Target IDE Platform
downloadSources.set(true)
// Read this: https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
plugins.set(listOf("com.intellij.java", "com.intellij.lang.jsgraphql:4.0.2"))
instrumentCode.set(false)
intellijPlatform {
pluginConfiguration {
ideaVersion {
sinceBuild = "232"
untilBuild = provider { null } // 开放式兼容
}

// (可选)把 README 中的描述注入 plugin.xml
description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
}
}

// (可选)从 changelog 生成 changeNotes
val cl = project.changelog
changeNotes = providers.gradleProperty("plugin.version").map { pv ->
with(cl) {
renderItem(
(getOrNull(pv) ?: getUnreleased()).withHeader(false).withEmptySections(false),
Changelog.OutputType.HTML
)
}
}
}

signing {
certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN")
privateKey = providers.environmentVariable("PRIVATE_KEY")
password = providers.environmentVariable("PRIVATE_KEY_PASSWORD")
}

publishing {
token = providers.environmentVariable("PUBLISH_TOKEN")
}

// (可选)IDE 兼容性验证:跑推荐矩阵
pluginVerification {
ides { recommended() }
}
}

changelog {
// groups.empty()
repositoryUrl = properties("plugin.repository.url")
version = properties("plugin.version")
// 2.x 的依赖 DSL
dependencies {
intellijPlatform {
// 目标平台(开发/运行基线)
create("IU", "2023.2.3")
// 捆绑插件
bundledPlugins("com.intellij.java")
// 市场插件
plugins("com.intellij.lang.jsgraphql:4.0.2")
// (可选)工具
instrumentationTools()
pluginVerifier()
zipSigner()
}
}

tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}

patchPluginXml {
sinceBuild.set("232")
untilBuild.set("251.*")
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription = """
${extractPluginDesc("README.md")}

${extractPluginDesc("README_zh.md")}
""".trimIndent()
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
}
}

fun extractPluginDesc(fileName: String) =
providers.fileContents(layout.projectDirectory.file(fileName)).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
}
}.get()
// ✅ 正确的位置:changelog 扩展的属性放在这里
changelog {
version = providers.gradleProperty("plugin.version").get()
repositoryUrl = providers.gradleProperty("plugin.repository.url").get()
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ org.gradle.configuration-cache = true
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching = true

plugin.version = 1.0.5
plugin.version = 1.0.6

plugin.repository.url = https://github.com/8btc-OnePiece/plugin-graphql-java-tools
20 changes: 20 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[versions]
# libraries
junit = "4.13.2"

# plugins
changelog = "2.2.1"
intelliJPlatform = "2.1.0"
kotlin = "1.9.25"
kover = "0.8.3"
qodana = "2024.2.3"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists