Skip to content

Commit

Permalink
feat: sync with platform plugin template
Browse files Browse the repository at this point in the history
  • Loading branch information
cvette committed Aug 20, 2023
1 parent 465d91e commit 9fbb307
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 81 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ on:

jobs:

# Run Gradle Wrapper Validation Action to verify the wrapper's checksum
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks
# Build plugin and provide the artifact for the next workflow jobs
# Prepare environment and build the plugin
build:
name: Build
runs-on: ubuntu-latest
Expand All @@ -33,12 +31,13 @@ jobs:
changelog: ${{ steps.properties.outputs.changelog }}
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
steps:

# Free GitHub Actions Environment Disk Space
- name: Maximize Build Space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
large-packages: false

# Check out current repository
- name: Fetch Sources
Expand All @@ -58,6 +57,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Set environment variables
- name: Export Properties
Expand Down Expand Up @@ -120,6 +121,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Run tests
- name: Run Tests
Expand All @@ -137,7 +140,7 @@ jobs:
- name: Upload Code Coverage Report
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/build/reports/kover/xml/report.xml
files: ${{ github.workspace }}/build/reports/kover/report.xml

# Run Qodana inspections and provide report
inspectCode:
Expand Down Expand Up @@ -170,7 +173,7 @@ jobs:
# Run plugin structure verification along with IntelliJ Plugin Verifier
verify:
name: Verify plugin
needs: [ build, test, inspectCode ]
needs: [ build ]
runs-on: ubuntu-latest
steps:

Expand All @@ -188,6 +191,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Cache Plugin Verifier IDEs
- name: Setup Plugin Verifier IDEs Cache
Expand All @@ -213,7 +218,7 @@ jobs:
releaseDraft:
name: Release draft
if: github.event_name != 'pull_request'
needs: [ build, verify ]
needs: [ build, test, inspectCode, verify ]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Set environment variables
- name: Export Properties
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

# Run IDEA prepared for UI testing
- name: Run IDE
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
.qodana
.gradle
build/
src/gen
classes
build/
out/
Binary file added .idea/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
132 changes: 65 additions & 67 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@ fun environment(key: String) = providers.environmentVariable(key)

plugins {
id("idea")
// Java support
id("java")
id("java-library")
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.15.0"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "2.1.2"
// gradle-grammar-kit-plugin - read more: https://github.com/JetBrains/gradle-grammar-kit-plugin
id("org.jetbrains.grammarkit") version "2022.3.1"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"

alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin
alias(libs.plugins.gradleGrammarkitPlugin) // Gradle Grammar-Kit 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").get()
version = properties("pluginVersion").get()


// Configure project's dependencies
repositories {
mavenCentral()
Expand All @@ -49,68 +45,68 @@ sourceSets {
// 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"))
pluginName = properties("pluginName")
version = properties("platformVersion")
type = properties("platformType")

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) })
plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) }
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
groups.set(emptyList())
repositoryUrl.set(properties("pluginRepositoryUrl"))
groups.empty()
repositoryUrl = properties("pluginRepositoryUrl")
}

// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath.set(file(".qodana").canonicalPath)
reportPath.set(file("build/reports/inspections").canonicalPath)
saveReport.set(true)
showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false)
cachePath = provider { file(".qodana").canonicalPath }
reportPath = provider { file("build/reports/inspections").canonicalPath }
saveReport = true
showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false)
}

grammarKit {
jflexRelease.set(properties("jFlexVersion"))
grammarKitRelease.set(properties("grammarKitVersion"))
jflexRelease = properties("jFlexVersion")
grammarKitRelease = properties("grammarKitVersion")
}

val generateEelLexer = task<GenerateLexerTask>("GenerateEelLexer") {
sourceFile.set(file("src/main/grammars/EelLexer.flex"))
targetDir.set("src/gen/de/vette/idea/neos/lang/eel/parser")
targetClass.set("EelLexer")
purgeOldFiles.set(true)
sourceFile = file("src/main/grammars/EelLexer.flex")
targetDir = "src/gen/de/vette/idea/neos/lang/eel/parser"
targetClass = "EelLexer"
purgeOldFiles = true
}

val generateAfxLexer = task<GenerateLexerTask>("GenerateAfxLexer") {
sourceFile.set(file("src/main/grammars/AfxLexer.flex"))
targetDir.set("src/gen/de/vette/idea/neos/lang/afx/parser")
targetClass.set("AfxLexer")
purgeOldFiles.set(true)
sourceFile = file("src/main/grammars/AfxLexer.flex")
targetDir = "src/gen/de/vette/idea/neos/lang/afx/parser"
targetClass = "AfxLexer"
purgeOldFiles = true
}

val generateFusionLexer = task<GenerateLexerTask>("GenerateFusionLexer") {
sourceFile.set(file("src/main/grammars/FusionLexer.flex"))
targetDir.set("src/gen/de/vette/idea/neos/lang/fusion/parser")
targetClass.set("FusionLexer")
purgeOldFiles.set(true)
sourceFile = file("src/main/grammars/FusionLexer.flex")
targetDir = "src/gen/de/vette/idea/neos/lang/fusion/parser"
targetClass = "FusionLexer"
purgeOldFiles = true
}

val generateEelParser = task<GenerateParserTask>("GenerateEelParser") {
sourceFile.set(file("src/main/grammars/EelParser.bnf"))
targetRoot.set("src/gen")
pathToParser.set("/de/vette/idea/neos/lang/eel/parser/EelParser.java")
pathToPsiRoot.set("/de/vette/idea/neos/lang/core/psi")
purgeOldFiles.set(true)
sourceFile = file("src/main/grammars/EelParser.bnf")
targetRoot = "src/gen"
pathToParser = "/de/vette/idea/neos/lang/eel/parser/EelParser.java"
pathToPsiRoot = "/de/vette/idea/neos/lang/core/psi"
purgeOldFiles = true
}

val generateFusionParser = task<GenerateParserTask>("GenerateFusionParser") {
sourceFile.set(file("src/main/grammars/FusionParser.bnf"))
targetRoot.set("src/gen")
pathToParser.set("/de/vette/idea/neos/lang/fusion/parser/FusionParser.java")
pathToPsiRoot.set("/de/vette/idea/neos/lang/core/psi")
purgeOldFiles.set(true)
sourceFile = file("src/main/grammars/FusionParser.bnf")
targetRoot = "src/gen"
pathToParser = "/de/vette/idea/neos/lang/fusion/parser/FusionParser.java"
pathToPsiRoot = "/de/vette/idea/neos/lang/core/psi"
purgeOldFiles = true
}

tasks {
Expand All @@ -128,25 +124,26 @@ tasks {
}

patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
version = properties("pluginVersion")
sinceBuild = properties("pluginSinceBuild")
untilBuild = 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 -->"

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) }
)
pluginDescription = 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.set(properties("pluginVersion").map { pluginVersion ->
changeNotes = properties("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
Expand All @@ -155,7 +152,7 @@ tasks {
Changelog.OutputType.HTML,
)
}
})
}
}

// Configure UI tests plugin
Expand All @@ -168,16 +165,17 @@ tasks {
}

signPlugin {
certificateChain.set(environment("CERTIFICATE_CHAIN"))
privateKey.set(environment("PRIVATE_KEY"))
password.set(environment("PRIVATE_KEY_PASSWORD"))
certificateChain = environment("CERTIFICATE_CHAIN")
privateKey = environment("PRIVATE_KEY")
password = environment("PRIVATE_KEY_PASSWORD")
}

publishPlugin {
dependsOn("patchChangelog")
token.set(environment("PUBLISH_TOKEN"))
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
token = environment("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://jetbrains.org/intellij/sdk/docs/tutorials/build_system/deployment.html#specifying-a-release-channel
channels.set(properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) }) }
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels = properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) }
}
}
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
annotations = "24.0.1"

# plugins
kotlin = "1.9.0"
changelog = "2.1.2"
gradleIntelliJPlugin = "1.15.0"
gradleGrammarkitPlugin = "2022.3.1"
qodana = "0.1.13"
kover = "0.7.3"

Expand All @@ -15,6 +15,6 @@ annotations = { group = "org.jetbrains", name = "annotations", version.ref = "an
[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
gradleGrammarkitPlugin = { id = "org.jetbrains.grammarkit", version.ref = "gradleGrammarkitPlugin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
2 changes: 2 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# https://www.jetbrains.com/help/qodana/qodana-yaml.html

version: 1.0
linter: jetbrains/qodana-jvm-community:latest
projectJDK: 17
profile:
name: qodana.recommended
exclude:
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0"
}

rootProject.name = "Intellij Neos"

0 comments on commit 9fbb307

Please sign in to comment.