Skip to content
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

Migrate to Intellij Platform Gradle Plugin #224

Merged
merged 6 commits into from
Dec 30, 2024
Merged
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
57 changes: 1 addition & 56 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,69 +158,14 @@ jobs:
path: ./build/distributions/${{ needs.build.outputs.artifact }}
if-no-files-found: error

# Verify built plugin using IntelliJ Plugin Verifier tool
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyPlugin has been executed in Test stage.

# Requires build job to be passed
verify:
name: Verify
needs: build
runs-on: ubuntu-latest
steps:

# Setup Java 17 environment for the next steps
- name: Setup Java
uses: actions/[email protected]
with:
java-version: 17
distribution: 'zulu'

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

# Cache Gradle Dependencies
- name: Setup Gradle Dependencies Cache
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts', 'gradle.properties') }}

# Cache Gradle Wrapper
- name: Setup Gradle Wrapper Cache
uses: actions/cache@v3
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}

# Set environment variables
- name: Export Properties
id: properties
shell: bash
run: |
PROPERTIES="$(./gradlew properties --console=plain -q)"
IDE_VERSIONS="$(echo "$PROPERTIES" | grep "^pluginVerifierIdeVersions:" | base64)"
echo "::set-output name=ideVersions::$IDE_VERSIONS"
echo "::set-output name=pluginVerifierHomeDir::~/.pluginVerifier"
# Cache Plugin Verifier IDEs
- name: Setup Plugin Verifier IDEs Cache
uses: actions/cache@v3
with:
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
key: ${{ runner.os }}-plugin-verifier-${{ steps.properties.outputs.ideVersions }}

# Run IntelliJ Plugin Verifier action using GitHub Action
- name: Verify Plugin
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}

# Prepare a draft release for GitHub Releases page for the manual verification
# If accepted and published, release workflow would be triggered
releaseDraft:
name: Release Draft
# don't run on pull requests to avoid creating draft releases for pull requests
# only run on the main branch, to avoid cutting releases from feature branches
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/master' }}
needs: [build, verify]
needs: [build]
runs-on: ubuntu-latest
steps:

Expand Down
96 changes: 45 additions & 51 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.changelog.date
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType

fun properties(key: String) = project.findProperty(key).toString()

Expand All @@ -11,11 +12,11 @@ plugins {
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "2.0.0-Beta2"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.16.1"
id("org.jetbrains.intellij.platform") version "2.2.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "1.3.1"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.21.0"
id("io.gitlab.arturbosch.detekt") version "1.23.6"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
id("groovy")
Expand All @@ -30,9 +31,16 @@ version = properties("pluginVersion")
// Configure project's dependencies
repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
flatDir { dirs("lib") }
}
dependencies {
intellijPlatform {
create(properties("platformType"), properties("platformVersion"))
bundledPlugins(listOf("com.intellij.java", "org.intellij.intelliLang"))
}
// https://mvnrepository.com/artifact/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer
implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer")
// compile "org.jetbrains:markdown:${markdownParserVersion}"
Expand All @@ -51,17 +59,41 @@ dependencies {
}
// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
downloadSources.set(properties("platformDownloadSources").toBoolean())
updateSinceUntilBuild.set(false) // don't write information of current IntelliJ build into plugin.xml, instead use information from patchPluginXml

// Plugin Dependencies:
// https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
//
plugins.set(listOf("com.intellij.java", "org.intellij.intelliLang"))
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("pluginVersion")

description = File(projectDir, "README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

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").run { markdownToHTML(this) }

changeNotes = changelog.getLatest().toHTML()

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

pluginVerification {
ides {
properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty).forEach {
ide(IntelliJPlatformType.IntellijIdeaCommunity, it)
}
}
}

publishing {
token = System.getenv("PUBLISH_TOKEN")
channels = listOf(if ("true" == System.getenv("PRE_RELEASE")) "EAP" else "default")
}

}

// Configure detekt plugin.
Expand Down Expand Up @@ -128,44 +160,6 @@ tasks {
withType<Detekt> {
jvmTarget = "11"
}
patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set((properties("pluginSinceBuild")))
// untilBuild(pluginUntilBuild) --> don't set "untilBuild" to allow new versions to use existing plugin without changes until breaking API changes are known

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
provider {
File(projectDir, "README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

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").run { markdownToHTML(this) }
}
)

// Get the latest available change notes from the changelog file
changeNotes.set(
provider {
changelog.getLatest().toHTML()
}
)
}

runPluginVerifier {
ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
}

publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
// if release is marked as a pre-release in the GitHub release, push it to EAP
channels.set(listOf(if ("true" == System.getenv("PRE_RELEASE")) "EAP" else "default"))
}
changelog {
version.set(properties("pluginVersion"))
header.set(provider { "[${project.version}] - ${date()}" })
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ markdownParserVersion = 0.1.23

pluginGroup = org.jetbrains.plugins.template
pluginName = zenuml
pluginVersion = 2024.12.23
pluginVersion = 2025.1.1
pluginSinceBuild = 233

# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions = 2023.3
pluginVerifierIdeVersions = 2024.1

platformType = IC
platformVersion = 2023.3
platformVersion = 2024.1
platformDownloadSources = true

# Opt-out flag for bundling Kotlin standard library.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion resource/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,5 @@

</actions>

<product-descriptor code="PZENUML" release-date="20190601" release-version="20191" optional="true" />
<product-descriptor code="PZENUML" release-date="20241230" release-version="20251" optional="true" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyPlugin requires the release-version must have the same beginning with pluginVersion. (202412 and 2024.12.xx don't work, looks a potential bug in the Gradle plugin)

</idea-plugin>
Loading