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

chore: update gradle intellij platform plugin & nx #2257

Merged
merged 6 commits into from
Sep 18, 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
12 changes: 11 additions & 1 deletion .github/workflows/ci_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,19 @@ jobs:
check-latest: true
cache: yarn
- run: yarn install --immutable
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
cache: gradle
- name: Workspace Lint
run: |
npx nx-cloud record -- npx nx format:check
npx nx-cloud record -- ./gradlew projectReportAll
npx nx-cloud record -- npx nx show projects --verbose
npx nx-cloud record -- npx nx format:check --verbose --skip-nx-cache
npx nx-cloud record -- ./gradlew ktfmtCheck
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Thumbs.db
.gradle
.qodana
apps/intellij/bin/
.intellijPlatform


# WDIO
**/.wdio-vscode-service
Expand All @@ -70,4 +72,4 @@ apps/vscode-e2e/.screenshots
.nx/cache
.nx/workspace-data
**/cypress/downloads
migrations.json
migrations.json
6 changes: 5 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module.exports = {
addons: ['@storybook/addon-knobs', '@storybook/addon-mdx-gfm'],
addons: [
'@storybook/addon-knobs',
'@storybook/addon-mdx-gfm',
'@chromatic-com/storybook',
],
framework: {
name: '@storybook/angular',
options: {},
Expand Down
234 changes: 122 additions & 112 deletions apps/intellij/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

fun isWindows(): Boolean {
return System.getProperty("os.name").lowercase().startsWith("windows")
}

val nxlsRoot = "${rootDir}/dist/apps/nxls"

buildDir = file("${rootDir}/dist/apps/intellij")

fun properties(key: String) = project.findProperty(key).toString()
layout.buildDirectory = file("${rootDir}/dist/apps/intellij")

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.9.22"
id("org.jetbrains.kotlin.jvm") version "2.0.20"
// Kotlin serialization
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.22"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.17.2"
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.20"
// Gradle IntelliJ Platform Plugin
id("org.jetbrains.intellij.platform") version "2.0.1"

// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.0.0"
Expand All @@ -31,10 +30,16 @@ plugins {
id("com.ncorti.ktfmt.gradle") version "0.11.0"
}

group = properties("pluginGroup")
group = providers.gradleProperty("pluginGroup").get()

version = providers.gradleProperty("version").get()

// Configure project's dependencies
repositories { mavenCentral() }
repositories {
mavenCentral()

intellijPlatform { defaultRepositories() }
}

configurations.all {
exclude("org.slf4j", "slf4j-api")
Expand All @@ -46,42 +51,128 @@ configurations.all {
}

dependencies {
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:0.21.0")
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.1")

val ktorVersion = "2.3.8"
val ktorVersion = "2.3.12"
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
implementation("io.ktor:ktor-client-logging:$ktorVersion")

implementation("io.github.z4kn4fein:semver:1.4.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.2")

implementation("io.github.z4kn4fein:semver:2.0.0")

intellijPlatform {
intellijIdeaUltimate(providers.gradleProperty("platformVersion"))

bundledPlugins(
providers.gradleProperty("platformPlugins").map { plugins ->
plugins.split(',').map(String::trim).filter(String::isNotEmpty)
}
)
pluginVerifier()
zipSigner()
instrumentationTools()
}
}

ktfmt { kotlinLangStyle() }

// Set the JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for
// 2022.2+.
kotlin { jvmToolchain(17) }

// Configure Gradle IntelliJ Plugin - read more:
// https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(
properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)
)
intellijPlatform {
projectName = providers.gradleProperty("pluginName").get()

pluginConfiguration {
version = providers.gradleProperty("version").get()
ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild").get()
untilBuild = providers.gradleProperty("pluginUntilBuild").get()
}
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 =
providers.gradleProperty("version").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}
}
signing {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
publishing {
token.set(System.getenv("PUBLISH_TOKEN"))
// version 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
// val channel: String =
// properties("pluginVersion").split('-').getOrElse(1) { "default"
// }.split('.').first()
// channels.set(listOf(channel))
}
pluginVerification { ides { recommended() } }
}

intellijPlatformTesting {
runIde {
create("runIntelliJLatest") {
version = "243.12818.47"
prepareSandboxTask {
from(nxlsRoot) {
include("**/*.js")
include("**/package.json")
include("**/*.map")
into(intellijPlatform.projectName.map { "$it/nxls" }.get())
}
doLast {
exec {
workingDir =
File(
destinationDir,
intellijPlatform.projectName.map { "$it/nxls" }.get(),
)
commandLine = buildCommands() + "npm install --force"
}
}
}
}
}
}

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

// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
Expand All @@ -96,7 +187,7 @@ qodana {
kover.xmlReport { onCheck.set(true) }

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions { jvmTarget = "17" }
compilerOptions { jvmTarget.set(JvmTarget.JVM_17) }
}

tasks {
Expand All @@ -107,110 +198,29 @@ tasks {
include("**/*.js")
include("**/package.json")
include("**/*.map")
into("${rootProject.name}/nxls")
into(intellijPlatform.projectName.map { "$it/nxls" }.get())
}

doLast {
exec {
logger.warn("rootproject ${rootProject.name}")
logger.warn("Working dir: $workingDir")
logger.warn("Working dir: $destinationDir")

workingDir =
File(
destinationDir,
rootProject.name + "/nxls",
)
File(destinationDir, intellijPlatform.projectName.map { "$it/nxls" }.get())
commandLine = buildCommands() + "npm install --force"
}
}
}

patchPluginXml {
version.set(properties("version"))
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(
file("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")
.let { markdownToHTML(it) }
)

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

// 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")
}

runIde { maxHeapSize = "6g" }

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"))
// version 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
// val channel: String =
// properties("pluginVersion").split('-').getOrElse(1) { "default"
// }.split('.').first()
// channels.set(listOf(channel))
}

jar {
dependsOn("copyGenerateUiV2Artifacts")

archiveBaseName.set("nx-console")
}

instrumentedJar {
dependsOn("copyGenerateUiV2Artifacts")
}
instrumentedJar { dependsOn("copyGenerateUiV2Artifacts") }
}

tasks.register<Copy>("copyGenerateUiV2Artifacts") {
from("${rootDir}/dist/apps/generate-ui-v2")
include("*.js", "*.css")
into("${buildDir}/resources/main/generate_ui_v2")
into(layout.buildDirectory.file("resources/main/generate_ui_v2"))
}

tasks.register<DefaultTask>("publish") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.angular2.cli.config.AngularProject
class NxAngularProject(
override val name: String,
private val ngProject: AngularJsonProject,
private val workspaceFolder: VirtualFile
private val workspaceFolder: VirtualFile,
) : AngularProject(workspaceFolder) {

override val rootDir
Expand Down Expand Up @@ -72,7 +72,7 @@ class NxAngularProject(
}

@Suppress("MemberVisibilityCanBePrivate")
/*override*/ fun resolveFile(filePath: String?): VirtualFile? {
fun resolveFile(filePath: String?): VirtualFile? {
return filePath?.let { path ->
rootDir.takeIf { it.isValid }?.findFileByRelativePath(path)
?: workspaceFolder.takeIf { it.isValid }?.findFileByRelativePath(path)
Expand Down
Loading
Loading