From c18071142f33bc6ccde02fc94632f28920fbe2a6 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Mon, 7 Aug 2023 21:59:39 +0800 Subject: [PATCH] feat(co): split to new module for plugin size --- .idea/runConfigurations/RunCompanion.xml | 24 ++++ build.gradle.kts | 118 +++++++++++++++++- .../src/main/resources/META-INF/plugin.xml | 26 ++++ .../main/resources/META-INF/pluginIcon.svg | 14 +++ settings.gradle.kts | 1 + 5 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 .idea/runConfigurations/RunCompanion.xml create mode 100644 companion/src/main/resources/META-INF/plugin.xml create mode 100644 companion/src/main/resources/META-INF/pluginIcon.svg diff --git a/.idea/runConfigurations/RunCompanion.xml b/.idea/runConfigurations/RunCompanion.xml new file mode 100644 index 0000000000..6ea4471c7f --- /dev/null +++ b/.idea/runConfigurations/RunCompanion.xml @@ -0,0 +1,24 @@ + + + + + + + false + true + false + false + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index bcf0768980..6bb1af285b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -327,8 +327,6 @@ project(":") { implementation(libs.bundles.markdown) implementation("org.jetbrains:markdown:0.2.0.pre-55") -// implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.9.1") - implementation(libs.kotlinx.serialization.json) // jackson-module-kotlin implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.2") { @@ -343,7 +341,6 @@ project(":") { exclude(module = "jackson-annotations") } - implementation("com.phodal.chapi:chapi-domain:2.1.2") implementation("com.knuddels:jtokkit:0.6.1") // junit @@ -371,6 +368,119 @@ project(":pycharm") { } } + +project(":companion") { + version = prop("pluginVersion") + + intellij { + pluginName.set(basePluginArchiveName) + val pluginList: MutableList = mutableListOf("Git4Idea") + if (baseIDE == "idea") { + pluginList += javaPlugins + } + plugins.set(pluginList) + } + + dependencies { + implementation(project(":")) + implementation(project(":java")) + + implementation("com.phodal.chapi:chapi-domain:2.1.2") + implementation("com.phodal.chapi:chapi-ast-java:2.1.2") + implementation("org.archguard.scanner:feat_apicalls:2.0.1") + } + + // Collects all jars produced by compilation of project modules and merges them into singe one. + // We need to put all plugin manifest files into single jar to make new plugin model work + val mergePluginJarTask = task("mergePluginJars") { + duplicatesStrategy = DuplicatesStrategy.FAIL + archiveBaseName.set(basePluginArchiveName) + + exclude("META-INF/MANIFEST.MF") + exclude("**/classpath.index") + + val pluginLibDir by lazy { + val sandboxTask = tasks.prepareSandbox.get() + sandboxTask.destinationDir.resolve("${sandboxTask.pluginName.get()}/lib") + } + + val pluginJars by lazy { + pluginLibDir.listFiles().orEmpty().filter { + it.isPluginJar() + } + } + + destinationDirectory.set(project.layout.dir(provider { pluginLibDir })) + + doFirst { + for (file in pluginJars) { + from(zipTree(file)) + } + } + + doLast { + delete(pluginJars) + } + } + + // Add plugin sources to the plugin ZIP. + // gradle-intellij-plugin will use it as a plugin sources if the plugin is used as a dependency + val createSourceJar = task("createSourceJar") { + for (prj in pluginProjects) { + from(prj.kotlin.sourceSets.main.get().kotlin) { + include("**/*.java") + include("**/*.kt") + } + } + + destinationDirectory.set(layout.buildDirectory.dir("libs")) + archiveBaseName.set(basePluginArchiveName) + archiveClassifier.set("src") + } + + tasks { + buildPlugin { +// dependsOn(createSourceJar) +// from(createSourceJar) { into("lib/src") } + // Set proper name for final plugin zip. + // Otherwise, base name is the same as gradle module name + archiveBaseName.set(basePluginArchiveName) + } + + runIde { enabled = true } + + prepareSandbox { + finalizedBy(mergePluginJarTask) + enabled = true + } + + buildSearchableOptions { + // Force `mergePluginJarTask` be executed before `buildSearchableOptions` + // Otherwise, `buildSearchableOptions` task can't load the plugin and searchable options are not built. + // Should be dropped when jar merging is implemented in `gradle-intellij-plugin` itself + dependsOn(mergePluginJarTask) + enabled = false + } + + withType { + // Default args for IDEA installation + jvmArgs("-Xmx768m", "-XX:+UseG1GC", "-XX:SoftRefLRUPolicyMSPerMB=50") + // Disable plugin auto reloading. See `com.intellij.ide.plugins.DynamicPluginVfsListener` + jvmArgs("-Didea.auto.reload.plugins=false") + // Don't show "Tip of the Day" at startup + jvmArgs("-Dide.show.tips.on.startup.default.value=false") + // uncomment if `unexpected exception ProcessCanceledException` prevents you from debugging a running IDE + // jvmArgs("-Didea.ProcessCanceledException=disabled") + } + + withType { + channels.set(properties("pluginVersion").map { + listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) + }) + } + } +} + project(":java") { intellij { version.set(ideaVersion) @@ -378,8 +488,6 @@ project(":java") { } dependencies { implementation(project(":")) - implementation("com.phodal.chapi:chapi-ast-java:2.1.2") - implementation("org.archguard.scanner:feat_apicalls:2.0.1") } } diff --git a/companion/src/main/resources/META-INF/plugin.xml b/companion/src/main/resources/META-INF/plugin.xml new file mode 100644 index 0000000000..ee6c55ec94 --- /dev/null +++ b/companion/src/main/resources/META-INF/plugin.xml @@ -0,0 +1,26 @@ + + cc.unitmesh.comp + Unit Companion + Phodal Huang + + Homepage | Github | Issues.
+
+ AutoDev is a fully automated AI-assisted programming tool and an implementation of the DevTi Intellij IDE designed for use in-flight. + ]]>
+ + + + + + + + + + + + +
diff --git a/companion/src/main/resources/META-INF/pluginIcon.svg b/companion/src/main/resources/META-INF/pluginIcon.svg new file mode 100644 index 0000000000..c8927a0a72 --- /dev/null +++ b/companion/src/main/resources/META-INF/pluginIcon.svg @@ -0,0 +1,14 @@ + + + + ai-copilot + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 90e471be57..2d4df04452 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,6 +3,7 @@ rootProject.name = "intellij-autodev" enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") +include("companion") include("plugin") include(