Skip to content

Commit

Permalink
Upgrade to Intellij platform gradle plugin 2.0 (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: Ashrith Kumar Peddi <iashrith@amazon.com>
  • Loading branch information
peddiashrith and Ashrith Kumar Peddi authored Sep 20, 2024
1 parent e7f7142 commit 3dab4e1
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
product: [ "IC-2022.2", "IC-2023.1", "IC-2023.2", "IC-2023.3", "IC-2024.1"]
product: [ "IC-2023.1", "IC-2023.2", "IC-2023.3", "IC-2024.1" ]
max-parallel: 5
env:
PRODUCT_NAME: ${{ matrix.product }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
product: [ "IC-2022.2", "IC-2023.1", "IC-2023.2", "IC-2023.3", "IC-2024.1" ]
product: [ "IC-2023.1", "IC-2023.2", "IC-2023.3", "IC-2024.1" ]
max-parallel: 5
env:
PRODUCT_NAME: ${{ matrix.product }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
release:
strategy:
matrix:
product: [ "IC-2022.2", "IC-2023.1", "IC-2023.2", "IC-2023.3", "IC-2024.1" ]
product: [ "IC-2023.1", "IC-2023.2", "IC-2023.3", "IC-2024.1" ]
max-parallel: 1
env:
PRODUCT_NAME: ${{ matrix.product }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build
*.iml
*.ipr
*.iws
.intellijPlatform
155 changes: 88 additions & 67 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,94 +1,95 @@
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import plugin.PluginDescriptor
import plugin.PluginDescriptor.KotlinOptions
import plugin.PlatformType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet

buildscript {
repositories {
mavenCentral()
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

plugins {
kotlin("jvm")
id("org.jetbrains.intellij") version "1.15.0"
id("org.jetbrains.intellij.platform") version "2.0.1"
}

repositories {
mavenCentral()

intellijPlatform {
defaultRepositories()
}
}

val plugins = listOf(
PluginDescriptor(
since = "222",
until = "223.*",
sdkVersion = "IC-2022.2",
platformType = PlatformType.IdeaCommunity,
sourceFolder = "IC-222",
kotlin = KotlinOptions(
apiVersion = "1.6"
),
dependencies = listOf("java", "Kotlin")
),
PluginDescriptor(
since = "231",
until = "231.*",
sdkVersion = "IC-2023.1",
platformVersion = "2023.1",
platformType = PlatformType.IdeaCommunity,
sourceFolder = "IC-231",
kotlin = KotlinOptions(
apiVersion = "1.6"
),
dependencies = listOf("java", "Kotlin")
bundledDependencies = listOf("com.intellij.java", "org.jetbrains.kotlin")
),
PluginDescriptor(
since = "232",
until = "232.*",
sdkVersion = "IC-2023.2",
platformVersion = "2023.2",
platformType = PlatformType.IdeaCommunity,
sourceFolder = "IC-232",
kotlin = KotlinOptions(
apiVersion = "1.6"
),
dependencies = listOf("java", "Kotlin")
bundledDependencies = listOf("com.intellij.java", "org.jetbrains.kotlin")
),
PluginDescriptor(
since = "233",
until = "233.*",
sdkVersion = "IC-2023.3",
platformVersion = "2023.3",
platformType = PlatformType.IdeaCommunity,
sourceFolder = "IC-233",
kotlin = KotlinOptions(
apiVersion = "1.6"
),
dependencies = listOf("java", "Kotlin")
bundledDependencies = listOf("com.intellij.java", "org.jetbrains.kotlin")
),
PluginDescriptor(
since = "241",
until = "241.*",
sdkVersion = "IC-2024.1",
platformType = PlatformType.IdeaCommunity,
sourceFolder = "IC-241",
kotlin = KotlinOptions(
apiVersion = "1.6"
),
dependencies = listOf("java", "Kotlin")
since = "241",
until = "241.*",
platformVersion = "2024.1",
platformType = PlatformType.IdeaCommunity,
sourceFolder = "IC-241",
kotlin = KotlinOptions(
apiVersion = "1.6"
),
bundledDependencies = listOf("com.intellij.java", "org.jetbrains.kotlin")
)
)

val defaultProductName = "IC-2024.1"
val defaultProductName = "IC-2023.1"
val productName = System.getenv("PRODUCT_NAME") ?: defaultProductName
val maybeGithubRunNumber = System.getenv("GITHUB_RUN_NUMBER")?.toInt()
val descriptor = plugins.first { it.sdkVersion == productName }
val descriptor = plugins.first { it.getSDKVersion() == productName }

// Import variables from gradle.properties file
val pluginGroup: String by project

// `pluginName_` variable ends with `_` because of the collision with Kotlin magic getter in the `intellij` closure.
// Read more about the issue: https://github.com/JetBrains/intellij-platform-plugin-template/issues/29
val pluginName_: String by project
val pluginVersion: String = pluginVersion(major = "2", minor = "6", patch = "1")
val pluginVersion: String = pluginVersion(major = "2", minor = "7", patch = "1")
val pluginDescriptionFile: String by project
val pluginChangeNotesFile: String by project

Expand All @@ -98,28 +99,63 @@ val packageVersion: String by project
group = pluginGroup
version = packageVersion

logger.lifecycle("Building Amazon Ion $pluginVersion for ${descriptor.platformType} ${descriptor.sdkVersion}")
logger.lifecycle("Building Amazon Ion $pluginVersion for ${descriptor.platformType} ${descriptor.platformVersion}")

dependencies {
// Kotlin runtime dependency is provided by the IntelliJ platform.
intellijPlatform {
create(descriptor.platformType.acronym, descriptor.platformVersion) // https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#setting-up-intellij-platform
bundledPlugins(descriptor.bundledDependencies)
pluginVerifier()
instrumentationTools()

testFramework(TestFrameworkType.Platform)
}

testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testCompileOnly("junit:junit:4.13")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
}

intellij {
pluginName.set(pluginName_)
version.set(descriptor.sdkVersion)
type.set(descriptor.platformType.acronym)
downloadSources.set(true)
updateSinceUntilBuild.set(false)
intellijPlatform {
pluginConfiguration {
name.set(pluginName_)
version.set(descriptor.platformVersion)
description.set(readResource(pluginDescriptionFile))
changeNotes.set(readResource(pluginChangeNotesFile))

ideaVersion {
sinceBuild.set(descriptor.since)
untilBuild.set(descriptor.until)
}
}

publishing {
token.set(System.getenv("PUBLISH_TOKEN"))

// Publish to beta unless release is specified.
if (System.getenv("PUBLISH_CHANNEL") != "release") {
channels.set(listOf("beta"))
}
}

// Plugin Dependencies -> https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
// Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
plugins.set(descriptor.dependencies)
pluginVerification {
ides {
ide(IntelliJPlatformType.IntellijIdeaCommunity, descriptor.platformVersion)
recommended()
select {
types.set(listOf(IntelliJPlatformType.IntellijIdeaCommunity))
channels.set(listOf(ProductRelease.Channel.BETA))
sinceBuild.set(descriptor.since)
untilBuild.set(descriptor.until)
}
}
}
}

sourceSets {
main {
withConvention(KotlinSourceSet::class) {
kotlin.srcDir("src/${descriptor.sourceFolder}/kotlin")
kotlin {
srcDir("src/${descriptor.sourceFolder}/kotlin")
}

resources {
Expand Down Expand Up @@ -155,25 +191,7 @@ tasks {
}

buildPlugin {
archiveClassifier.set(descriptor.sdkVersion)
}

patchPluginXml {
version.set(pluginVersion)
sinceBuild.set(descriptor.since)
untilBuild.set(descriptor.until)

pluginDescription.set(readResource(pluginDescriptionFile))
changeNotes.set(readResource(pluginChangeNotesFile))
}

publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))

// Publish to beta unless release is specified.
if (System.getenv("PUBLISH_CHANNEL") != "release") {
channels.set(listOf("beta"))
}
archiveClassifier.set(descriptor.getSDKVersion())
}
}

Expand All @@ -192,18 +210,20 @@ fun readResource(name: String) = file("resources/$name").readText()
* major: 2
* minor: 1
* patch: 1
* sdkVersion: IC-2022.2
* platformVersion: 2024.2
* platformType: IC
*
* RETURNS:
* 2.1.1+30-IC-2022.2
* 2.1.1+30-IC-2024.2
*
*
* GIVEN (local dev environment):
* GITHUB_RUN_NUMBER: null
* major: 2
* minor: 2
* patch: 34
* sdkVersion: IC-2022.3
* platformVersion: 2022.3
* platformType: IC
*
* RETURNS:
* 2.2.34+0-IC-2022.3+alpha
Expand All @@ -212,5 +232,6 @@ fun pluginVersion(major: String, minor: String, patch: String) =
listOf(
major,
minor,
maybeGithubRunNumber?.let { "$patch+$it-${descriptor.sdkVersion}" } ?: "$patch+0-${descriptor.sdkVersion}+alpha"
maybeGithubRunNumber?.let { "$patch+$it-${descriptor.getSDKVersion()}" }
?: "$patch+0-${descriptor.getSDKVersion()}+alpha"
).joinToString(".")
10 changes: 7 additions & 3 deletions buildSrc/src/main/kotlin/plugin/PluginDescriptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ data class PluginDescriptor(
val platformType: PlatformType,

/**
* The Platform SDK Version that this distribution will run on.
* The Platform Version that this distribution will run on.
*/
val sdkVersion: String,
val platformVersion: String,

/**
* Source folder which defines source code specific to this distribution.
Expand All @@ -40,7 +40,7 @@ data class PluginDescriptor(
/**
* Plugin dependencies. {@see https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html}
*/
val dependencies: List<String>
val bundledDependencies: List<String>
) {
data class KotlinOptions(
/**
Expand All @@ -49,6 +49,10 @@ data class PluginDescriptor(
*/
val apiVersion: String
)

fun getSDKVersion(): String {
return platformType.acronym + "-" + platformVersion
}
}

enum class PlatformType(val acronym: String) {
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.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 3dab4e1

Please sign in to comment.