Add jar inside of archive

Answered

I need to be able to add class jars that live inside other zip like archive files. Is this something that is doable?

 

I've tried registering the archive file as a ArchiveFileType, and messing with the library path in various ways, including the inner jar file name and not. I've even added a different DataNode type for these specific modules based on the LibraryData code then manually building the path to give to ModifiableModel.addRoot and .addJarDirectory with and without a "jar://" prefix and !/ sepparator. I've also tried a custom ArchiveFileSystem, ZipHandler etc.

6 comments
Comment actions Permalink

Could you please link your plugin's sources?

0
Comment actions Permalink

That would take some not insignificant amount of work. Is there a chance someone could explain how to allow an external system plugin to provide jar libraries that live inside a zip file?

 

What I had initially tried is: create LibraryData DataNode instances in ExternalSystemProjectResolver that point to the archive file, hoping it would just find the jars inside. Then I tried to use a path like "/path/here/foo.archive!/file.jar" (with or without a jar:// prefix). Neither worked. 

Next I tried changing to custom LibraryData sub classes and a custom Data Service to process that data much like the built in LibraryData service does, except it builds a "more proper" uri to the jar file. Even tried telling it it was a jar directory rather than just a root.

Currently, I extract the jar from the archive, then create normal project level libraries (LibraryData + LibraryDependencyData) when building the DataNode tree in the ExternalSystemProjectResolver and add a path to the LibraryData pointing to the the jar. This "works" as in the Library list shows valid entries, but references to symbols in the libraries/jars show up red (not found / unresolved). Oddly, ctrl+clicking on the package name in the import takes me to the right directory. but trying to do anything with the actual classes just gives me nothing.

 

So TL;DR; my question is, what is the correct way to add a Library in an external system plugin that lives inside an archive?

Once I know that, I'll know where to look to fix things.

0
Comment actions Permalink

I'm afraid but it seems impossible to help you without seeing the actual sources and understand the use case first (how would such libraries work at runtime?).

0
Comment actions Permalink

The libraries will be handled differently at runtime. The libraries that live in an archive are prebuilts that aren't directly shipped as is, rather they get included into the final project by the proprietary build system.

 

So all I really need is how to get Intellij to see the the classes inside the jar that live inside what is essentially a zip file.

0
Comment actions Permalink

It might work using com.intellij.psi.PsiElementFinder and provide custom "resolve" logic to your ZIP files.

0
Comment actions Permalink

I mean sure, that might be technically possible, but it seems like it'd require duplicating a lot of existing code and behavior that already exists. Intellij already has a fancy VFS api, why can't I point a library directly at a jar file in the zip?

0

Please sign in to leave a comment.