Failing to add a dependency on a plugin available in the file system

已回答

I have 2 local plugins and I've been trying to set up one of them as a dependency for the other one. Following these instructions I encountered a problem.

build.gradle.kts:

intellij {
    version.set("2023.1.1")
    type.set("IC") // Target IDE Platform
    plugins.set(listOf("com.intellij.java"))
    // add my local plugin
    plugins.add(file("/home/jjnkn/fielden/git/idea-apt/build/idea-sandbox/plugins/idea-apt"))
}

Trying to reload Gradle configuration or to build the plugin fails with the following:

Could not find idea-apt-0.1.5-SNAPSHOT-0.1.5-SNAPSHOT-unzipped.com.jetbrains.plugins.jar (unzipped.com.jetbrains.plugins:fielden.idea.apt:0.1.5-SNAPSHOT).
Searched in the following locations:
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2023.1.1/770a0552545fe6ab0de3e2f8ac9adb7ea3046417/ideaIC-2023.1.1/plugins/fielden.idea.apt/idea-apt-0.1.5-SNAPSHOT.jar
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2023.1.1/770a0552545fe6ab0de3e2f8ac9adb7ea3046417/ideaIC-2023.1.1/idea-apt-0.1.5-SNAPSHOT.jar
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/unzipped.com.jetbrains.plugins/fielden.idea.apt-0.1.5-SNAPSHOT/idea-apt-0.1.5-SNAPSHOT.jar
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2023.1.1/6ba1ff0f5cf440c16dd0c3b2f1fe5baacd53d918/idea-apt-0.1.5-SNAPSHOT-2023.1.1-unzipped.com.jetbrains.plugins.jar
    file:/home/jjnkn/fielden/git/idea-apt/build/idea-sandbox/plugins/idea-apt-0.1.5-SNAPSHOT.jar

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Why would it search Gradle caches if the specified path already contains everything it needs?

Note that both plugins are configured with the same IDE version and type.

Contents of the specified path:

idea-apt
└── lib
   ├── checker-qual-3.33.0.jar
   ├── commons-lang3-3.0.jar
   ├── error_prone_annotations-2.18.0.jar
   ├── failureaccess-1.0.1.jar
   ├── guava-32.1.2-jre.jar
   ├── instrumented-idea-apt-0.1.5-SNAPSHOT.jar
   ├── javapoet-1.13.0.jar
   ├── jsr305-3.0.2.jar
   ├── listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
   ├── log4j-api-2.20.0.jar
   └── log4j-core-2.20.0.jar

Although the instructions say the following (which I have followed):

It is also possible to refer to the sandbox directory of another Gradle project — to do that, point to the /projects/plugin-name/build/idea-sandbox/plugins/plugin-name/ directory

I also tried specifying “/home/jjnkn/fielden/git/idea-apt/build/idea-sandbox/plugins/idea-apt/lib/” (the same path but with /lib appended), which also fails:

[gradle-intellij-plugin :] Cannot create plugin from file '/home/jjnkn/fielden/git/idea-apt/build/idea-sandbox/plugins/idea-apt/lib': Plugin descriptor 'plugin.xml' is not found

Next, I tried “/home/jjnkn/fielden/git/idea-apt/build/idea-sandbox/plugins/idea-apt/lib/idea-apt-0.1.5-SNAPSHOT.jar" after symlinking idea-apt-0.1.5-SNAPSHOT.jar to instrumented-idea-apt-0.1.5-SNAPSHOT.jar (it wasn't working with the instrumented- prefix). This almost worked. The sandbox instance is able to start but the specified plugin fails to load as its dependencies are missing:

Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager PluginClassLoader(plugin=PluginDescriptor(name=Annotation Processing Tool, id=fielden.idea.apt, descriptorPath=plugin.xml, path=~/fielden/git/tg-IDE-plugins/intellij-idea/tg-idea-plugin/build/idea-sandbox/plugins/idea-apt-0.1.5-SNAPSHOT.jar, version=0.1.5-SNAPSHOT, package=null, isBundled=false), packagePrefix=null, instanceId=22, state=active)
0

Did you try pointing to the ZIP distribution, that contains all required 3rd party libraries?

0

Yann Cebron I did. The result is similar to the 1st error message in the post.

> Task :prepareKotlinBuildScriptModel UP-TO-DATE
[gradle-intellij-plugin :] Cannot create plugin from file '/home/jjnkn/fielden/git/idea-apt/build/distributions/idea-apt-0.1.5-SNAPSHOT.zip' - only directories or jars are supported

FAILURE: Build failed with an exception.

* What went wrong:
Could not find idea-apt-0.1.5-SNAPSHOT-0.1.5-SNAPSHOT-unzipped.com.jetbrains.plugins.jar (unzipped.com.jetbrains.plugins:fielden.idea.apt:0.1.5-SNAPSHOT).
Searched in the following locations:
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2023.1.1/770a0552545fe6ab0de3e2f8ac9adb7ea3046417/ideaIC-2023.1.1/plugins/fielden.idea.apt/idea-apt-0.1.5-SNAPSHOT.jar
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2023.1.1/770a0552545fe6ab0de3e2f8ac9adb7ea3046417/ideaIC-2023.1.1/idea-apt-0.1.5-SNAPSHOT.jar
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/unzipped.com.jetbrains.plugins/fielden.idea.apt-0.1.5-SNAPSHOT/idea-apt-0.1.5-SNAPSHOT.jar
    file:/home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2023.1.1/6ba1ff0f5cf440c16dd0c3b2f1fe5baacd53d918/idea-apt-0.1.5-SNAPSHOT-2023.1.1-unzipped.com.jetbrains.plugins.jar
    file:/home/jjnkn/fielden/git/idea-apt/build/distributions/idea-apt-0.1.5-SNAPSHOT.jar

Also note that at the beginning it says that only directories or jars are supported.

0

The configuration from the first post should basically work — this approach is also described in the FAQ: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin-faq.html#how-to-add-a-dependency-on-a-plugin-available-in-the-file-system

 

Maybe there's a Gradle cache issue here? Did you refer to the the plugin version from Marketplace before instead of the local version?

Try removing cached entry: /home/jjnkn/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/unzipped.com.jetbrains.plugins/

0

Jakub Chrzanowski Removing cached entries as you advised did the trick. The configuration from the first post works now. Thanks.

Did you refer to the the plugin version from Marketplace before instead of the local version?

I have only the local version at the moment, so I did not use the Marketplace.

0

请先登录再写评论。