Skip to content

适配最新版本IDEA,修复新版本IDEA报错信息和调整deepl的参数调整为json #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ jobs:
- name: Gradle Wrapper Validation
uses: gradle/[email protected]

# Setup Java 11 environment for the next steps
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17

# Set environment variables
- name: Export Properties
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

# Setup Java 11 environment for the next steps
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17

# Set environment variables
- name: Export Properties
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
uses: actions/checkout@v4

# Setup Java 11 environment for the next steps
# Setup Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17

# Run IDEA prepared for UI testing
- name: Run IDE
run: ${{ matrix.runIde }}

# Wait for IDEA to be started
- name: Health Check
uses: jtalk/url-health-check-action@v3
uses: jtalk/url-health-check-action@v4
with:
url: http://127.0.0.1:8082
max-attempts: 15
Expand Down
289 changes: 194 additions & 95 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,124 +1,223 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.date
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.TestFrameworkType

fun properties(key: String) = project.findProperty(key).toString()
//fun properties(key: String) = project.findProperty(key).toString()
fun properties(key: String) = providers.gradleProperty(key)
fun propertiesGet(key: String) = properties(key).get()

plugins {
// Java support
id("java")
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.13.3"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.1.2"
id("java")
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
}

group = properties("pluginGroup")
version = properties("pluginVersion")
group = propertiesGet("pluginGroup")
version = propertiesGet("pluginVersion")

// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(21)
}

// Configure project's dependencies
repositories {
mavenCentral()
maven("https://developer.huawei.com/repo/")
maven("https://www.jitpack.io")
maven("https://maven.aliyun.com/repository/public")
maven("https://maven.aliyun.com/repository/central")
maven("https://maven.aliyun.com/repository/google")
maven("https://mirrors.tencent.com/nexus/repository/gradle-plugins/")
maven("https://maven.aliyun.com/repository/grails-core")
maven("https://www.jetbrains.com/intellij-repository/releases") // IntelliJ 官方仓库
maven("https://maven.aliyun.com/repository/gradle-plugin")
maven("https://plugins.gradle.org/m2/") // 官方插件仓库
gradlePluginPortal()
mavenCentral()

// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
intellijPlatform {
defaultRepositories()
}
}

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
dependencies {
// https://mvnrepository.com/artifact/org.junit/junit-bom
testImplementation(platform("org.junit:junit-bom:5.13.0-M2"))
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
testImplementation(libs.opentest4j)

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
}
// 声明 IntelliJ IDEA Community 依赖
intellijPlatform {
androidStudio("2024.3.1.14")
bundledPlugin("org.jetbrains.android")

/*create(properties("platformType"), properties("platformVersion"))

// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
bundledPlugins(properties("platformBundledPlugins").map { it.split(',') })

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(properties("platformPlugins").map { it.split(',') })*/

testFramework(TestFrameworkType.Platform)

}

// https://mvnrepository.com/artifact/com.google.auto.service/auto-service-annotations
compileOnly("com.google.auto.service:auto-service-annotations:1.1.1")
// https://mvnrepository.com/artifact/com.google.auto.service/auto-service
annotationProcessor("com.google.auto.service:auto-service:1.1.1")

// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation("com.google.code.gson:gson:2.12.1")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

// https://mvnrepository.com/artifact/com.aliyun/tea-openapi
implementation("com.aliyun:tea-openapi:0.3.7") {
exclude(group = "com.squareup.okhttp3", module = "okhttp")
}
// https://mvnrepository.com/artifact/com.aliyun/alimt20181012
implementation("com.aliyun:alimt20181012:1.4.0") {
exclude("com.squareup.okhttp3", "okhttp") // 排除旧版
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
header.set(provider { "${version.get()} (${date()})" })
repositoryUrl.set(properties("pluginRepositoryUrl"))
}

tasks {
// Set the JVM compatibility versions
properties("javaVersion").let {
withType<JavaCompile> {
sourceCompatibility = it
targetCompatibility = it
options.encoding = "UTF-8"
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("platformVersion")

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
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)
}
}

val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes = properties("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}

ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}

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

publishing {
token = providers.environmentVariable("PUBLISH_TOKEN")
// The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels = properties("pluginVersion")
.map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
}
}

wrapper {
gradleVersion = properties("gradleVersion")
}
pluginVerification {
ides {
// local(file("D:\\Program Files\\Android\\Android Studio"))
// ide(IntelliJPlatformType.AndroidStudio, "2024.3.1")
// local(file("D:\\Program Files\\JetBrains\\IntelliJ IDEA 2024.3.5\\bin\\idea64.exe"))
// local(file("D:\\Program Files\\Android\\Android Studio\\bin\\studio64.exe"))
recommended()
}
}

patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
}

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"
// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.empty()
repositoryUrl.set(properties("pluginRepositoryUrl"))
header.set(provider { "${version.get()} (${date()})" })
}

if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
kover {
reports {
total {
xml {
onCheck = true
}
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
)

// Get the latest available change notes from the changelog file
changeNotes.set(provider {
with(changelog) {
renderItem(
getOrNull(properties("pluginVersion")) ?: getLatest(),
Changelog.OutputType.HTML,
)
}
})
}

test {
useJUnitPlatform()
}

// Configure UI tests plugin
// Read more: https://github.com/JetBrains/intellij-ui-test-robot
runIdeForUiTests {
systemProperty("robot-server.port", "8082")
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")
}

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

publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
}
}
}

dependencies {
// https://github.com/google/auto/tree/master/service
compileOnly("com.google.auto.service:auto-service-annotations:1.1.1")
annotationProcessor("com.google.auto.service:auto-service:1.1.1")
tasks {

// Set the JVM compatibility versions
propertiesGet("javaVersion").let {
withType<JavaCompile> {
sourceCompatibility = it
targetCompatibility = it
options.encoding = "UTF-8"
}
}

implementation("com.google.code.gson:gson:2.10.1")
implementation("com.aliyun:alimt20181012:1.0.3")
test {
useJUnitPlatform()
}

testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.3")
wrapper {
gradleVersion = propertiesGet("gradleVersion")
}

publishPlugin {
dependsOn("patchChangelog")
}
}

intellijPlatformTesting {
runIde {
register("runIdeForUiTests") {
task {
jvmArgumentProviders += CommandLineArgumentProvider {
listOf(
"-Drobot-server.port=8082",
"-Dide.mac.message.dialogs.as.sheets=false",
"-Djb.privacy.policy.text=<!--999.999-->",
"-Djb.consents.confirmation.enabled=false",
)
}
}

plugins {
robotServerPlugin()
}
}
}
testIde
testIdeUi
testIdePerformance
}
Loading