Skip to content

Commit

Permalink
[BCE-38723] - Added new logs infrastructure and button + new build ti…
Browse files Browse the repository at this point in the history
…me updates
  • Loading branch information
ChananM committed Sep 10, 2024
1 parent 7b9385b commit ec2d756
Show file tree
Hide file tree
Showing 54 changed files with 556 additions and 304 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.gradle
.idea
.intellijPlatform
build
.DS_Store
bin
1 change: 1 addition & 0 deletions .intellijPlatform/self-update.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-09-10
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@

# checkov-jetbrains-idea Changelog

## [1.0.22] - 2024-09-10

### Added

- Added a new 'show logs' button in the plugin panel that opens the plugin log file

### Misc

- Upgraded gradle version to 8.10.1
- Migrated the IntelliJ platform plugin to version 2.0.1

## [1.0.21] - 2024-08-29

### Added

- Added the following data to Prisma Cloid analytics
- Added the following data to Prisma Cloud analytics

- Extension version
- VS Code version
Expand Down
137 changes: 87 additions & 50 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask

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

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.9.25"
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.17.4"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "1.3.1"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "10.2.0"
id("java") // Java support
alias(libs.plugins.kotlin) // Kotlin support
alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
kotlin("plugin.serialization") version "1.9.25"
}

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

kotlin {
jvmToolchain(17)
}

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

dependencies {
Expand All @@ -37,20 +39,51 @@ dependencies {
implementation("commons-io:commons-io:2.11.0")
implementation("io.github.java-diff-utils:java-diff-utils:4.12")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
implementation("org.slf4j:slf4j-api:2.0.16")
implementation("ch.qos.logback:logback-classic:1.5.6")
testImplementation(libs.junit)
testImplementation(libs.jupiterApi)
testRuntimeOnly("org.junit.jupiter:junit-jupiter:5.8.1")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.9.0")
}

// Configure gradle-intellij-plugin plugin.
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
intellijPlatform {
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))

// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })

instrumentationTools()
pluginVerifier()
zipSigner()
testFramework(TestFrameworkType.Platform)
}
}

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty))
intellijPlatform {
pluginConfiguration {
name = properties("pluginName")
version = properties("pluginVersion")
ideaVersion {
sinceBuild = properties("pluginSinceBuild")
untilBuild = properties("pluginUntilBuild")
}
val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}
}
}

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
Expand All @@ -67,6 +100,16 @@ qodana {
showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false)
}

kover {
reports {
total {
xml {
onCheck = true
}
}
}
}

tasks {
// Set the JVM compatibility versions
properties("javaVersion").let {
Expand All @@ -79,18 +122,11 @@ tasks {
}
}

withType<BaseKtLintCheckTask>().configureEach {
enabled = false
}

wrapper {
gradleVersion = properties("gradleVersion")
}

patchPluginXml {
version.set(properties("pluginVersion"))
sinceBuild.set(properties("pluginSinceBuild"))
untilBuild.set("")
// 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 @@ -103,22 +139,6 @@ tasks {
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
)

// Get the latest available change notes from the changelog file
changeNotes.set(provider {
changelog.run {
getOrNull(properties("pluginVersion")) ?: getLatest()
}.toHTML()
})
}

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

signPlugin {
Expand All @@ -128,7 +148,7 @@ tasks {
}

publishPlugin {
dependsOn("patchChangelog")
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:
Expand All @@ -144,8 +164,25 @@ tasks {
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
}
}
}

runPluginVerifier {
ideVersions.set(listOf("IC-2020.3.4", "IC-2021.1.3", "IC-2021.2.4", "IC-2024.1.6"))
intellijPlatformTesting {
runIde {
register("runIdeForUiTests") {
task {
jvmArgumentProviders += CommandLineArgumentProvider {
listOf(
"-Drobot-server.port=8082",
"-Dide.mac.message.dialogs.as.sheets=false",
"-Djb.privacy.policy.text=<!--999.999-->",
"-Djb.consents.confirmation.enabled=false",
)
}
}

plugins {
robotServerPlugin()
}
}
}
}
10 changes: 7 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@

pluginGroup = com.github.bridgecrewio.prismajetbrainsidea
pluginName = prismacloud-jetbrains-idea
pluginVersion=1.0.21
pluginSinceBuild=241
pluginVersion=1.0.22
# 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=2020.3.4, 2021.1.3, 2021.2.4, 2024.1.6

platformType = IC
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=203
pluginUntilBuild=242
platformVersion=2024.1.6
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 =
# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins=

# Opt-out flag for bundling Kotlin standard library.
# See https://kotlinlang.org/docs/reference/using-gradle.html#dependency-on-the-standard-library for details.
Expand All @@ -24,4 +28,4 @@ kotlin.stdlib.default.dependency = false
javaVersion=17

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion=7.6.4
gradleVersion=8.10.1
22 changes: 22 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[versions]
# libraries
junit = "4.13.2"
jupiterApi = "5.8.1"

# plugins
changelog = "2.2.1"
intelliJPlatform = "2.0.1"
kotlin = "1.9.25"
kover = "0.8.3"
qodana = "0.1.13"

[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
jupiterApi = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "jupiterApi" }

[plugins]
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }
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.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
21 changes: 21 additions & 0 deletions src/main/java/com/bridgecrew/log/LoggerService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.bridgecrew.log;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.FileAppender;
import com.intellij.openapi.components.Service;
import org.slf4j.LoggerFactory;

@Service
public final class LoggerService {

public String getLogFilePath() {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
ch.qos.logback.classic.Logger rootLogger = loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
Appender<?> appender = rootLogger.getAppender("FILE");
if (appender instanceof FileAppender<?> fileAppender) {
return fileAppender.getFile();
}
return null;
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/bridgecrew/util/ApplicationServiceUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.bridgecrew.util;

import com.intellij.openapi.application.ApplicationManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApplicationServiceUtil {

private final static Logger logger = LoggerFactory.getLogger(ApplicationServiceUtil.class);

public static <T> T getService(Class<T> clazz) {
T service = ApplicationManager.getApplication().getService(clazz);
if (service == null) {
String message = String.format("Could not find service %s", clazz.getSimpleName());
logger.error(message);
throw new IllegalArgumentException(message);
}
return service;
}
}
Loading

0 comments on commit ec2d756

Please sign in to comment.