diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 95500085f..89d07c804 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,11 +11,11 @@ updates: interval: "daily" - package-ecosystem: "gradle" - directory: "/buildSrc" + directory: "/buildSrc/src/main/kotlin" # /buildSrc and /codegpt-telemetry use only references schedule: interval: "daily" - package-ecosystem: "gradle" - directory: "/codegpt-core" + directory: "/codegpt-treesitter" schedule: interval: "daily" diff --git a/build.gradle.kts b/build.gradle.kts index f6c9f1d1f..5ce2eaf32 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,7 +23,7 @@ fun environment(key: String) = providers.environmentVariable(key) plugins { id("codegpt.java-conventions") - id("org.jetbrains.changelog") version "2.2.0" + alias(libs.plugins.changelog) } group = properties("pluginGroup").get() @@ -50,15 +50,16 @@ dependencies { implementation(project(":codegpt-telemetry")) implementation(project(":codegpt-treesitter")) - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.16.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.2") - implementation("com.vladsch.flexmark:flexmark-all:0.64.8") { + implementation(enforcedPlatform("com.fasterxml.jackson:jackson-bom:${libs.versions.jackson.get()}")) + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") + implementation(libs.flexmark.all) { // vulnerable transitive dependency exclude(group = "org.jsoup", module = "jsoup") } - implementation("org.jsoup:jsoup:1.17.2") - implementation("org.apache.commons:commons-text:1.11.0") - implementation("com.knuddels:jtokkit:1.0.0") + implementation(libs.jsoup) + implementation(libs.commons.text) + implementation(libs.jtokkit) } tasks.register("updateSubmodules") { @@ -154,4 +155,4 @@ tasks { showStandardStreams = true } } -} \ No newline at end of file +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index a7ce63c86..006b09c96 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -8,6 +8,6 @@ repositories { } dependencies { - implementation("org.jetbrains.intellij.plugins", "gradle-intellij-plugin", "1.17.2") - implementation("org.jetbrains.kotlin", "kotlin-gradle-plugin", "1.9.22") + implementation(libs.gradle.intellij.plugin) + implementation(libs.kotlin.gradle.plugin) } diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 000000000..85123139f --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,7 @@ +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) // Allow references + } + } +} diff --git a/buildSrc/src/main/kotlin/codegpt.java-conventions.gradle.kts b/buildSrc/src/main/kotlin/codegpt.java-conventions.gradle.kts index 767f856a2..f42cd97f8 100644 --- a/buildSrc/src/main/kotlin/codegpt.java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/codegpt.java-conventions.gradle.kts @@ -28,11 +28,12 @@ checkstyle { dependencies { implementation("ee.carlrobert:llm-client:0.7.0") + testImplementation(enforcedPlatform("org.junit:junit-bom:5.10.2")) testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.2") - testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.10.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.2") - testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.2") + testImplementation("org.junit.jupiter:junit-jupiter-params") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + testRuntimeOnly("org.junit.vintage:junit-vintage-engine") } tasks { diff --git a/codegpt-telemetry/build.gradle.kts b/codegpt-telemetry/build.gradle.kts index ca2c2a3af..60546d9ec 100644 --- a/codegpt-telemetry/build.gradle.kts +++ b/codegpt-telemetry/build.gradle.kts @@ -3,5 +3,5 @@ plugins { } dependencies { - implementation("com.rudderstack.sdk.java.analytics:analytics:3.0.0") -} \ No newline at end of file + implementation(libs.analytics) +} diff --git a/codegpt-treesitter/build.gradle.kts b/codegpt-treesitter/build.gradle.kts index ed5152534..532f50f5e 100644 --- a/codegpt-treesitter/build.gradle.kts +++ b/codegpt-treesitter/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } dependencies { - implementation("io.github.bonede:tree-sitter:0.21.0") + implementation(libs.tree.sitter) implementation("io.github.bonede:tree-sitter-erlang:0.1.0") implementation("io.github.bonede:tree-sitter-elixir:0.1.1") implementation("io.github.bonede:tree-sitter-dockerfile:0.1.2") @@ -37,4 +37,4 @@ dependencies { implementation("io.github.bonede:tree-sitter-php:0.20.0") implementation("io.github.bonede:tree-sitter-typescript:0.20.3") implementation("io.github.bonede:tree-sitter-query:0.1.0") -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 8e067c496..aed14e035 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ platformPlugins = javaVersion = 17 # Gradle Releases -> https://github.com/gradle/gradle/releases -gradleVersion = 8.5 +gradleVersion = 8.7 # Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib kotlin.stdlib.default.dependency = false @@ -38,4 +38,4 @@ org.gradle.caching = true systemProp.org.gradle.unsafe.kotlin.assignment = true # Temporary workaround for Kotlin Compiler OutOfMemoryError -> https://jb.gg/intellij-platform-kotlin-oom -kotlin.incremental.useClasspathSnapshot = false \ No newline at end of file +kotlin.incremental.useClasspathSnapshot = false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..8d2e3bde0 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,30 @@ +[versions] +analytics = "3.0.0" +assertj = "3.25.3" +changelog = "2.2.0" +commons-text = "1.11.0" +flexmark = "0.64.8" +gradle-intellij-plugin-version="1.17.3" +jackson = "2.17.0" +jsoup = "1.17.2" +jtokkit = "1.0.0" +junit = "5.10.2" +kotlin = "1.9.23" +llm-client = "0.7.0" +tree-sitter = "0.22.2" + +[libraries] +analytics = { module = "com.rudderstack.sdk.java.analytics:analytics", version.ref = "analytics" } +assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" } +commons-text = { module = "org.apache.commons:commons-text", version.ref = "commons-text" } +flexmark-all = { module = "com.vladsch.flexmark:flexmark-all", version.ref = "flexmark" } +gradle-intellij-plugin = { module = "org.jetbrains.intellij.plugins:gradle-intellij-plugin", version.ref = "gradle-intellij-plugin-version" } +jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } +jtokkit = { module = "com.knuddels:jtokkit", version.ref = "jtokkit" } +junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +llm-client = { module = "ee.carlrobert:llm-client", version.ref = "llm-client" } +tree-sitter = { module = "io.github.bonede:tree-sitter", version.ref = "tree-sitter" } + +[plugins] +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c4..d64cd4917 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e0930..b82aa23a4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 0adc8e1a5..1aa94a426 100755 --- a/gradlew +++ b/gradlew @@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestProvider.java b/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestProvider.java index 328cd04be..35976cf12 100644 --- a/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestProvider.java +++ b/src/main/java/ee/carlrobert/codegpt/completions/CompletionRequestProvider.java @@ -216,10 +216,10 @@ private static Request buildCustomOpenAIChatCompletionRequest( List messages, boolean streamRequest) { var requestBuilder = new Request.Builder().url(customConfiguration.getUrl().trim()); + var credential = CredentialsStore.INSTANCE.getCredential(CUSTOM_SERVICE_API_KEY); for (var entry : customConfiguration.getHeaders().entrySet()) { String value = entry.getValue(); - var credential = CredentialsStore.INSTANCE.getCredential(CUSTOM_SERVICE_API_KEY); - if (value.contains("$CUSTOM_SERVICE_API_KEY") && credential != null) { + if (credential != null && value.contains("$CUSTOM_SERVICE_API_KEY")) { value = value.replace("$CUSTOM_SERVICE_API_KEY", credential); } requestBuilder.addHeader(entry.getKey(), value);