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

Implement Jetbrains IDEs heartbeating #6152

Merged
merged 1 commit into from
Oct 14, 2021
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
5 changes: 4 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ ports:
onOpen: ignore
tasks:
- name: Java
init: leeway exec --package components/supervisor-api/java:lib --package components/gitpod-protocol/java:lib -- ./gradlew jar
init: |
leeway exec --package components/supervisor-api/java:lib --package components/gitpod-protocol/java:lib -- ./gradlew build
leeway exec --package components/ide/jetbrains/backend-plugin:plugin -- ./gradlew buildPlugin
- name: TypeScript
before: scripts/branch-namespace.sh
init: yarn --network-timeout 100000 && yarn build
Expand All @@ -59,3 +61,4 @@ vscode:
- heptio.jsonnet
- timonwong.shellcheck
- vscjava.vscode-java-pack
- fwcd.kotlin
1 change: 1 addition & 0 deletions components/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ packages:
- components/supervisor-api/typescript-grpcweb:publish
- components/supervisor-api/java:lib
- installer:app
- components/ide/jetbrains/backend-plugin:plugin
- name: docker-versions
type: docker
config:
Expand Down
2 changes: 1 addition & 1 deletion components/gitpod-protocol/java/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ packages:
- JAVA_HOME=/home/gitpod/.sdkman/candidates/java/current
config:
commands:
- ["./gradlew", "jar"]
- ["./gradlew", "build"]
19 changes: 4 additions & 15 deletions components/gitpod-protocol/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,11 @@ java {
withJavadocJar()
}

// Set env vars GITHUB_GPR_USERNAME and GITHUB_GPR_TOKEN and run:
// ./gradlew publish

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/gitpod-io/gitpod")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_GPR_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_GPR_TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
from(components.java)
mavenJava(MavenPublication) {
from components.java
}
}
}
}
5 changes: 5 additions & 0 deletions components/ide/jetbrains/backend-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gradle
.settings
.vscode
bin
build
18 changes: 18 additions & 0 deletions components/ide/jetbrains/backend-plugin/BUILD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
packages:
- name: plugin
type: generic
deps:
- components/supervisor-api/java:lib
- components/gitpod-protocol/java:lib
srcs:
- "**/*.kt"
- "build.gradle.kts"
- "gradle.properties"
- "gradle/wrapper/*"
- "gradlew"
- "settings.gradle.kts"
env:
- JAVA_HOME=/home/gitpod/.sdkman/candidates/java/current
config:
commands:
- ["./gradlew", "-PsupervisorApiProjectPath=components-supervisor-api-java--lib/", "-PgitpodProtocolProjectPath=components-gitpod-protocol-java--lib/", "buildPlugin"]
15 changes: 15 additions & 0 deletions components/ide/jetbrains/backend-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Jetbrains IDE Backend Plugin

<!-- Plugin description -->
Jetbrains IDE backend plugin to provide support for Gitpod.

When installed in the headless Jetbrains IDE running in a Gitpod workspace, this plugin monitors user activity of the client IntelliJ and sends heartbeats accordingly. Avoiding the workspace timing out.
<!-- Plugin description end -->

**Warning**: Currently, given the challenge of mimicking user activity in a local Jetbrains IDE, there are no automated integration tests testing the functionality of this plugin. Please be particularly careful and manually test your changes.

## Usage

1. Produce the plugin by running `./gradlew buildPlugin`.
2. Unzip `build/distributions/jetbrains-backend-plugin-1.0-SNAPSHOT.zip` to the `plugins/` folder of the headless Jetbrains IDE.
3. Start the headless Jetbrains IDE.
92 changes: 92 additions & 0 deletions components/ide/jetbrains/backend-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun properties(key: String) = project.findProperty(key).toString()

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.5.10"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.0"
// detekt linter - read more: https://detekt.github.io/detekt/gradle.html
id("io.gitlab.arturbosch.detekt") version "1.17.1"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}

group = properties("pluginGroup")
version = properties("version")

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

dependencies {
implementation(project(":supervisor-api"))
implementation(project(":gitpod-protocol"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.5.2")
implementation("io.ktor:ktor-client-core:1.6.3")
implementation("io.ktor:ktor-client-cio:1.6.3")
implementation("io.ktor:ktor-client-jackson:1.6.3")

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.18.1")

testImplementation(kotlin("test"))
}

// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(System.getenv("INTELLIJ_PLUGIN_PLATFORM_VERSION"))
type.set(properties("platformType"))
instrumentCode.set(false)
downloadSources.set(properties("platformDownloadSources").toBoolean())
updateSinceUntilBuild.set(true)

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

// Configure detekt plugin.
// Read more: https://detekt.github.io/detekt/kotlindsl.html
detekt {
autoCorrect = true
buildUponDefaultConfig = true

reports {
html.enabled = false
xml.enabled = false
txt.enabled = false
}
}

tasks {
withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}

withType<Detekt> {
jvmTarget = "11"
}

test {
useJUnitPlatform()
}

runPluginVerifier {
ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
}
}
30 changes: 30 additions & 0 deletions components/ide/jetbrains/backend-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version=1.0-SNAPSHOT

# IntelliJ Platform Artifacts Repositories
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html

pluginGroup = io.gitpod.ide.jetbrains.backend
pluginName = jetbrains-backend-plugin

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 213
pluginUntilBuild = 213.*

# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions.
pluginVerifierIdeVersions = 2021.3.1

platformType = IU
platformDownloadSources = true

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

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
kotlin.stdlib.default.dependency = false

supervisorApiProjectPath = ../../../supervisor-api/java
gitpodProtocolProjectPath = ../../../gitpod-protocol/java
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading