Skip to content

Commit

Permalink
Support different IntelliJ versions (#165)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Sebastiano Poggi <[email protected]>
  • Loading branch information
Walingar and rock3r authored Oct 11, 2023
1 parent 5ec2652 commit b6f1597
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 38 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ jobs:
assemble:
runs-on: ubuntu-latest

strategy:
matrix:
supported-ij-version:
- 232
# - 233

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
Expand All @@ -20,11 +26,17 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run :assemble task
run: ./gradlew assemble
run: ./gradlew assemble -Psupported.ij.version=${{ matrix.supported-ij-version }}

checks:
runs-on: ubuntu-latest

strategy:
matrix:
supported-ij-version:
- 232
# - 233

steps:
- uses: actions/checkout@v3

Expand All @@ -39,11 +51,11 @@ jobs:
run: chmod +x gradlew

- name: Run :check task
run: ./gradlew check --continue
run: ./gradlew check -Psupported.ij.version=${{ matrix.supported-ij-version }} --continue

- name: Merge SARIF reports
# Necessary because upload-sarif only takes up to 15 SARIF files and we have more
run: ./gradlew :mergeSarifReports
run: ./gradlew :mergeSarifReports -Psupported.ij.version=${{ matrix.supported-ij-version }}
if: ${{ always() }}

- uses: github/codeql-action/upload-sarif@v2
Expand Down
33 changes: 30 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on:
push:
branches: [ main ]
jobs:
publish:
name: Publish
publish-core:
name: Publish Jewel Core
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
Expand All @@ -17,7 +18,33 @@ jobs:
- name: Setup Gradle
run: chmod +x gradlew
- name: Run Gradle
run: ./gradlew publishAllPublicationsToSpaceRepository
# supported.ij.version is needed here for project configuration and won't be used during publishing
run: ./gradlew publishMainPublicationsToSpaceRepository -Psupported.ij.version=232
env:
MAVEN_SPACE_USERNAME: ${{secrets.MAVEN_SPACE_USERNAME}}
MAVEN_SPACE_PASSWORD: ${{secrets.MAVEN_SPACE_PASSWORD}}

publish-ide:
name: Publish Jewel IDE part
needs: publish-core
runs-on: ubuntu-latest

strategy:
matrix:
supported-ij-version:
- 232
# - 233

steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
run: chmod +x gradlew
- name: Run Gradle
run: ./gradlew publishIdeMainPublicationsToSpaceRepository -Psupported.ij.version=${{ matrix.supported-ij-version }}
env:
MAVEN_SPACE_USERNAME: ${{secrets.MAVEN_SPACE_USERNAME}}
MAVEN_SPACE_PASSWORD: ${{secrets.MAVEN_SPACE_PASSWORD}}
26 changes: 26 additions & 0 deletions buildSrc/src/main/kotlin/IdeaConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.gradle.api.Project

enum class SupportedIJVersion {
IJ_232,
IJ_233
}

fun Project.supportedIJVersion(): SupportedIJVersion {
val prop = localProperty("supported.ij.version")
?: rootProject.property("supported.ij.version")
?: error(
"'supported.ij.version' gradle property is missing. " +
"Please, provide it using local.properties file or -Psupported.ij.version argument in CLI"
)

return when (prop) {
"232" -> SupportedIJVersion.IJ_232
"233" -> SupportedIJVersion.IJ_233
else -> {
error(
"Invalid 'supported.ij.version' with value '$prop' is provided. " +
"It should be in set of these values: ('232', '233')"
)
}
}
}
12 changes: 12 additions & 0 deletions buildSrc/src/main/kotlin/LocalProperties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import org.gradle.api.Project
import java.util.Properties

internal fun Project.localProperty(propertyName: String): String? {
val localPropertiesFile = rootProject.file("local.properties")
if (!localPropertiesFile.exists()) {
return null
}
val properties = Properties()
localPropertiesFile.inputStream().use { properties.load(it) }
return properties.getProperty(propertyName)
}
35 changes: 35 additions & 0 deletions buildSrc/src/main/kotlin/PublishConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@file:Suppress("UnstableApiUsage")

import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPom
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.maven

internal fun PublishingExtension.configureJewelRepositories() {
repositories {
maven("https://packages.jetbrains.team/maven/p/kpm/public") {
name = "Space"
credentials {
username = System.getenv("MAVEN_SPACE_USERNAME")
password = System.getenv("MAVEN_SPACE_PASSWORD")
}
}
}
}

internal fun MavenPom.configureJewelPom() {
name = "Jewel"
description = "A theme for Compose for Desktop that implements the IntelliJ Platform look and feel."
url = "https://github.com/JetBrains/jewel"
licenses {
license {
name = "Apache License 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
scm {
connection = "scm:git:https://github.com/JetBrains/jewel.git"
developerConnection = "scm:git:https://github.com/JetBrains/jewel.git"
url = "https://github.com/JetBrains/jewel"
}
}
43 changes: 43 additions & 0 deletions buildSrc/src/main/kotlin/jewel-ij-publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@file:Suppress("UnstableApiUsage")

import SupportedIJVersion.IJ_232
import SupportedIJVersion.IJ_233

plugins {
kotlin("jvm")
`maven-publish`
id("org.jetbrains.dokka")
}

val sourcesJar by tasks.registering(Jar::class) {
from(kotlin.sourceSets.main.map { it.kotlin })
archiveClassifier = "sources"
destinationDirectory = layout.buildDirectory.dir("artifacts")
}

val javadocJar by tasks.registering(Jar::class) {
from(tasks.dokkaHtml)
archiveClassifier = "javadoc"
destinationDirectory = layout.buildDirectory.dir("artifacts")
}

publishing {
configureJewelRepositories()

publications {
register<MavenPublication>("IdeMain") {
from(components["kotlin"])
artifact(javadocJar)
artifact(sourcesJar)
val ijVersionRaw = when (supportedIJVersion()) {
IJ_232 -> "232"
IJ_233 -> "233"
}
version = "${project.version}-ij-$ijVersionRaw"
artifactId = "jewel-${project.name}"
pom {
configureJewelPom()
}
}
}
}
26 changes: 3 additions & 23 deletions buildSrc/src/main/kotlin/jewel-publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ val javadocJar by tasks.registering(Jar::class) {
}

publishing {
repositories {
maven("https://packages.jetbrains.team/maven/p/kpm/public") {
name = "Space"
credentials {
username = System.getenv("MAVEN_SPACE_USERNAME")
password = System.getenv("MAVEN_SPACE_PASSWORD")
}
}
}
configureJewelRepositories()

publications {
register<MavenPublication>("main") {
from(components["kotlin"])
Expand All @@ -36,20 +29,7 @@ publishing {
version = project.version.toString()
artifactId = "jewel-${project.name}"
pom {
name = "Jewel"
description = "intelliJ theming system in for Compose."
url = "https://github.com/JetBrains/jewel"
licenses {
license {
name = "Apache License 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
scm {
connection = "scm:git:https://github.com/JetBrains/jewel.git"
developerConnection = "scm:git:https://github.com/JetBrains/jewel.git"
url = "https://github.com/JetBrains/jewel"
}
configureJewelPom()
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
composeDesktop = "1.5.2"
coroutines = "1.7.3"
detekt = "1.23.1"
idea = "232.8660.185"
idea232 = "232.8660.185"
idea233 = "233.9102.97-EAP-SNAPSHOT"
ideaGradlePlugin = "1.15.0"
javaSarif = "2.0"
kotlinSarif = "0.4.0"
Expand All @@ -19,9 +20,14 @@ javaSarif = { module = "com.contrastsecurity:java-sarif", version.ref = "javaSar
kotlinSarif = { module = "io.github.detekt.sarif4k:sarif4k", version.ref = "kotlinSarif" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
ij-platform-ide-core = { module = "com.jetbrains.intellij.platform:ide-core", version.ref = "idea" }
ij-platform-ide-impl = { module = "com.jetbrains.intellij.platform:ide-impl", version.ref = "idea" }
ij-platform-core-ui = { module = "com.jetbrains.intellij.platform:core-ui", version.ref = "idea" }

ij-platform-ide-core-232 = { module = "com.jetbrains.intellij.platform:ide-core", version.ref = "idea232" }
ij-platform-ide-impl-232 = { module = "com.jetbrains.intellij.platform:ide-impl", version.ref = "idea232" }
ij-platform-core-ui-232 = { module = "com.jetbrains.intellij.platform:core-ui", version.ref = "idea232" }

ij-platform-ide-core-233 = { module = "com.jetbrains.intellij.platform:ide-core", version.ref = "idea233" }
ij-platform-ide-impl-233 = { module = "com.jetbrains.intellij.platform:ide-impl", version.ref = "idea233" }
ij-platform-core-ui-233 = { module = "com.jetbrains.intellij.platform:core-ui", version.ref = "idea233" }
semVer = { module = "net.swiftzer.semver:semver", version.ref = "semVer" }
simpleXml = { module = "org.simpleframework:simple-xml", version.ref = "simpleXml" }

Expand All @@ -33,7 +39,8 @@ dokka-gradlePlugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", versi
kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" }

[bundles]
idea = ["ij-platform-ide-core", "ij-platform-ide-impl", "ij-platform-core-ui"]
idea232 = ["ij-platform-ide-core-232", "ij-platform-ide-impl-232", "ij-platform-core-ui-232"]
idea233 = ["ij-platform-ide-core-233", "ij-platform-ide-impl-233", "ij-platform-core-ui-233"]

[plugins]
composeDesktop = { id = "org.jetbrains.compose", version.ref = "composeDesktop" }
Expand Down
18 changes: 15 additions & 3 deletions ide-laf-bridge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import SupportedIJVersion.*

plugins {
jewel
`jewel-publish`
`jewel-ij-publish`
alias(libs.plugins.composeDesktop)
}

dependencies {
api(projects.intUi.intUiStandalone) {
exclude(group = "org.jetbrains.kotlinx")
}
compileOnly(libs.bundles.idea)
when (supportedIJVersion()) {
IJ_232 -> {
api(projects.ideLafBridge.ideLafBridge232)
compileOnly(libs.bundles.idea232)
}

IJ_233 -> {
api(projects.ideLafBridge.ideLafBridge233)
compileOnly(libs.bundles.idea233)
}
}

testImplementation(compose.desktop.uiTestJUnit4)
testImplementation(compose.desktop.currentOs) {
exclude(group = "org.jetbrains.compose.material")
}
}
}
15 changes: 15 additions & 0 deletions ide-laf-bridge/ide-laf-bridge-232/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
jewel
`jewel-ij-publish`
alias(libs.plugins.composeDesktop)
}

dependencies {
api(projects.intUi.intUiStandalone)
compileOnly(libs.bundles.idea232)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
publication.artifactId = "jewel-ide-laf-bridge-platform-specific"
enabled = supportedIJVersion() == SupportedIJVersion.IJ_232
}
15 changes: 15 additions & 0 deletions ide-laf-bridge/ide-laf-bridge-233/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
jewel
`jewel-ij-publish`
alias(libs.plugins.composeDesktop)
}

dependencies {
api(projects.intUi.intUiStandalone)
compileOnly(libs.bundles.idea233)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
publication.artifactId = "jewel-ide-laf-bridge-platform-specific"
enabled = supportedIJVersion() == SupportedIJVersion.IJ_233
}
8 changes: 7 additions & 1 deletion samples/ide-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SupportedIJVersion.*

plugins {
jewel
alias(libs.plugins.composeDesktop)
Expand All @@ -8,7 +10,11 @@ plugins {
intellij {
pluginName.set("Jewel Demo")
plugins.set(listOf("org.jetbrains.kotlin"))
version.set("2023.2.1")
val versionRaw = when (supportedIJVersion()) {
IJ_232 -> libs.versions.idea232.get()
IJ_233 -> libs.versions.idea233.get()
}
version.set(versionRaw)
}

// TODO remove this once the IJ Gradle plugin fixes their repositories bug
Expand Down
Loading

0 comments on commit b6f1597

Please sign in to comment.