Skip to content

Commit

Permalink
Merge pull request #386 from JetBrains-Research/pderakhshanfar/refact…
Browse files Browse the repository at this point in the history
…oring/gradle-ij-plugin-migration

Migrate to IntelliJ Platform V2
  • Loading branch information
pderakhshanfar authored Oct 11, 2024
2 parents fda68f4 + 033d3c2 commit 671a6d7
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 79 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ jobs:
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
./gradlew listProductsReleases # prepare list of IDEs for Plugin Verifier
# Run tests
- name: Run Tests
Expand All @@ -102,7 +100,7 @@ jobs:

# Run Verify Plugin task and IntelliJ Plugin Verifier tool
- name: Run Plugin Verification tasks
run: ./gradlew runPluginVerifier -Pplugin.verifier.home.dir=${{ steps.properties.outputs.pluginVerifierHomeDir }}
run: ./gradlew verifyPlugin

# Collect Plugin Verifier Result
- name: Collect Plugin Verifier Result
Expand Down
4 changes: 2 additions & 2 deletions .run/Run IDE for UI Tests.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="scriptParameters" value="--refresh-dependencies --stacktrace" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":runIdeForUiTests" />
<option value=":runIde" />
</list>
</option>
<option name="vmOptions" />
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ to include test generation using Grazie in the build process, you need to pass S

## Run IDE for UI tests
In IDEA, run the `Run IDE for UI Tests` configuration. Alternatively, use the following command:
`gradle runIdeForUiTests`.
`gradle runIde`.

### Including Test generation using Grazie (for JetBrains employees only!)
to include test generation using Grazie in the runIdeForUiTests process, you need to pass Space username and token as properties:
`gradle runIdeForUiTests -Dspace.username=<USERNAME> -Dspace.pass=<TOKEN>`.
`gradle runIde -Dspace.username=<USERNAME> -Dspace.pass=<TOKEN>`.

`<TOKEN>` is generated by Space, which has access to Automatically generating unit tests maven packages.

Expand Down
118 changes: 72 additions & 46 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.tasks.RunIdeTask
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease
import org.jetbrains.intellij.platform.gradle.tasks.RunIdeTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileOutputStream
import java.net.URL
Expand All @@ -25,7 +28,9 @@ plugins {
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.9.0"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.15.0"
id("org.jetbrains.intellij.platform") version "2.1.0"
// Gradle IntelliJ Plugin Migration Help (uncomment it for migration tips)
// id("org.jetbrains.intellij.platform.migration") version "2.1.0"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.1.2"
// Gradle Qodana Plugin
Expand All @@ -37,6 +42,11 @@ version = properties("pluginVersion")
// Configure project's dependencies
repositories {
mavenCentral()
// this part is mandatory for all modules for platform version 2:
// See https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html#default-repositories
intellijPlatform {
defaultRepositories()
}
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
maven("https://www.jetbrains.com/intellij-repository/snapshots")

Expand Down Expand Up @@ -66,6 +76,13 @@ if (spaceCredentialsProvided()) {
usingSourceSet(hasGrazieAccess)
}

// Add the dependencies for the new source set
dependencies {
add(hasGrazieAccess.implementationConfigurationName, kotlin("stdlib"))
add(hasGrazieAccess.implementationConfigurationName, "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
add(hasGrazieAccess.implementationConfigurationName, "org.jetbrains.research:grazie-test-generation:$grazieTestGenerationVersion")
}

tasks.register("checkCredentials") {
configurations.detachedConfiguration(
dependencies.create("org.jetbrains.research:grazie-test-generation:$grazieTestGenerationVersion"),
Expand All @@ -77,7 +94,7 @@ if (spaceCredentialsProvided()) {
}

// add build of new source set as the part of UI testing
tasks.prepareUiTestingSandbox.configure {
tasks.prepareTestSandbox.configure {
dependsOn(hasGrazieAccess.jarTaskName)
from(tasks.getByName(hasGrazieAccess.jarTaskName).outputs.files.asPath) { into("TestSpark/lib") }

Expand All @@ -99,6 +116,20 @@ if (spaceCredentialsProvided()) {
}

dependencies {
// Check platform V2 documentation for more details: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
intellijPlatform {
// make a custom version of IDEA
create(properties("platformType"), properties("platformVersion"))
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
bundledPlugins(providers.gradleProperty("platformPlugins").map { it.split(',') })

pluginVerifier()
zipSigner()
instrumentationTools()

testFramework(TestFrameworkType.Bundled)
}

implementation(files("lib/evosuite-${properties("evosuiteVersion")}.jar"))
implementation(files("lib/standalone-runtime.jar"))
implementation(files("lib/jacocoagent.jar"))
Expand Down Expand Up @@ -169,23 +200,41 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-test:1.8.0")

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")

if (spaceCredentialsProvided()) {
// Dependencies for hasGrazieAccess variant
"hasGrazieAccessImplementation"(kotlin("stdlib"))
"hasGrazieAccessImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
"hasGrazieAccessImplementation"("org.jetbrains.research:grazie-test-generation:$grazieTestGenerationVersion")
}
}

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
// Configure Gradle IntelliJ Plugin - read more: // Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("pluginVersion")

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

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
publishing {
token = System.getenv("PUBLISH_TOKEN")
channels = listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())
}
// Set the ides on which the plugin verification is executed.
// See https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginVerification-ides
pluginVerification {
ides {
recommended()
select {
types = listOf(IntelliJPlatformType.IntellijIdeaUltimate)
channels = listOf(ProductRelease.Channel.RELEASE)
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}
}
freeArgs = listOf(
"-mute",
"TemplateWordInPluginId,ForbiddenPluginIdPrefix"
)
}
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
Expand Down Expand Up @@ -232,11 +281,13 @@ tasks {
}
}

patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set(properties("pluginUntilBuild"))
signPlugin {
certificateChain.set(providers.environmentVariable("CERTIFICATE_CHAIN"))
privateKey.set(providers.environmentVariable("PRIVATE_KEY"))
password.set(providers.environmentVariable("PRIVATE_KEY_PASSWORD"))
}

patchPluginXml {
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
Expand All @@ -260,33 +311,8 @@ tasks {
)
}

// 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")
systemProperty("idea.trust.all.projects", "true")
systemProperty("ide.show.tips.on.startup.default.value", "false")
systemProperty("jb.consents.confirmation.enabled", "false")
systemProperty("ide.mac.file.chooser.native", "false")
systemProperty("apple.laf.useScreenMenuBar", "false")
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN").trimIndent())
privateKey.set(System.getenv("PRIVATE_KEY").trimIndent())
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
dependsOn("patchChangelog")
token.set(System.getenv("PUBLISH_TOKEN"))
// 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://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
}
}

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ evosuiteVersion = 1.0.5
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 241
pluginUntilBuild = 241.*
pluginUntilBuild = 242.*

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IC
platformVersion = 2024.1
platformVersion = 2024.2.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java, org.jetbrains.kotlin, maven, gradle
platformPlugins = com.intellij.java, org.jetbrains.kotlin, org.jetbrains.idea.maven, com.intellij.gradle

# Java language level used to compile sources and to generate the files for - Java 17 is required since 2023.1
javaVersion = 17

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.2.1
gradleVersion = 8.10.2

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
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.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
27 changes: 16 additions & 11 deletions java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
plugins {
kotlin("jvm")
id("org.jetbrains.intellij")
id("org.jetbrains.intellij.platform")
}

repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}

dependencies {
intellijPlatform {
create(rootProject.properties["platformType"].toString(), rootProject.properties["platformVersion"].toString())
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
bundledPlugins(listOf("com.intellij.java"))

instrumentationTools()
}
implementation(kotlin("stdlib"))

implementation(project(":langwrappers")) // Interfaces that cover language-specific logic
implementation(project(":core"))
}

intellij {
rootProject.properties["platformVersion"]?.let { version.set(it.toString()) }
plugins.set(listOf("java"))
intellijPlatform {
pluginConfiguration {
rootProject.properties["platformVersion"]?.let { version = it.toString() }
}
}

tasks.named("verifyPlugin") { enabled = false }
tasks.named("runIde") { enabled = false }
tasks.named("runPluginVerifier") { enabled = false }

tasks {
buildSearchableOptions {
enabled = false
}
}
tasks.named("prepareJarSearchableOptions") { enabled = false }

kotlin {
jvmToolchain(rootProject.properties["jvmToolchainVersion"].toString().toInt())
Expand Down
22 changes: 17 additions & 5 deletions kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
plugins {
kotlin("jvm")
id("org.jetbrains.intellij")
id("org.jetbrains.intellij.platform")
}

repositories {
mavenCentral()
intellijPlatform {
defaultRepositories()
}
}

dependencies {

intellijPlatform {
create(rootProject.properties["platformType"].toString(), rootProject.properties["platformVersion"].toString())
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
bundledPlugins(listOf("com.intellij.java", "org.jetbrains.kotlin"))

instrumentationTools()
}
implementation(kotlin("stdlib"))

implementation(project(":langwrappers")) // Interfaces that cover language-specific logic
implementation(project(":core"))
}

intellij {
rootProject.properties["platformVersion"]?.let { version.set(it.toString()) }
plugins.set(listOf("java", "org.jetbrains.kotlin"))
intellijPlatform {
pluginConfiguration {
rootProject.properties["platformVersion"]?.let { version = it.toString() }
}
}

tasks.named("verifyPlugin") { enabled = false }
tasks.named("runIde") { enabled = false }
tasks.named("runPluginVerifier") { enabled = false }
tasks.named("prepareJarSearchableOptions") { enabled = false }

tasks {
buildSearchableOptions {
Expand Down
Loading

0 comments on commit 671a6d7

Please sign in to comment.