Skip to content

Commit

Permalink
feat(co): split to new module for plugin size
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Aug 7, 2023
1 parent cdeff14 commit c180711
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 5 deletions.
24 changes: 24 additions & 0 deletions .idea/runConfigurations/RunCompanion.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 113 additions & 5 deletions build.gradle.kts
Expand Up @@ -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") {
Expand All @@ -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
Expand Down Expand Up @@ -371,15 +368,126 @@ project(":pycharm") {
}
}


project(":companion") {
version = prop("pluginVersion")

intellij {
pluginName.set(basePluginArchiveName)
val pluginList: MutableList<String> = 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<Jar>("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<Jar>("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<RunIdeTask> {
// 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<PublishPluginTask> {
channels.set(properties("pluginVersion").map {
listOf(it.split('-').getOrElse(1) { "default" }.split('.').first())
})
}
}
}

project(":java") {
intellij {
version.set(ideaVersion)
plugins.set(ideaPlugins)
}
dependencies {
implementation(project(":"))
implementation("com.phodal.chapi:chapi-ast-java:2.1.2")
implementation("org.archguard.scanner:feat_apicalls:2.0.1")
}
}

Expand Down
26 changes: 26 additions & 0 deletions companion/src/main/resources/META-INF/plugin.xml
@@ -0,0 +1,26 @@
<idea-plugin package="cc.unitmesh" xmlns:xi="http://www.w3.org/2001/XInclude" allow-bundled-update="true">
<id>cc.unitmesh.comp</id>
<name>Unit Companion</name>
<vendor>Phodal Huang</vendor>

<description><![CDATA[
<a href="https://plugins.jetbrains.com/plugin/21520-autodev">Homepage</a> | <a href="https://github.com/unit-mesh/auto-dev">Github</a> | <a href="https://github.com/unit-mesh/auto-dev/issues">Issues</a>.<br />
<br/>
AutoDev is a fully automated AI-assisted programming tool and an implementation of the DevTi Intellij IDE designed for use in-flight.
]]></description>

<change-notes><![CDATA[
todo
]]>
</change-notes>

<!-- please see https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html
on how to target different products -->

<xi:include href="/META-INF/autodev-core.xml" xpointer="xpointer(/idea-plugin/*)"/>

<!--suppress PluginXmlValidity -->
<content>
<module name="cc.unitmesh.idea"/>
</content>
</idea-plugin>
14 changes: 14 additions & 0 deletions companion/src/main/resources/META-INF/pluginIcon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions settings.gradle.kts
Expand Up @@ -3,6 +3,7 @@ rootProject.name = "intellij-autodev"
enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include("companion")
include("plugin")

include(
Expand Down

0 comments on commit c180711

Please sign in to comment.