Library.ModifiableModel.addRoot for jar

Hi,

I have a piece of code like this:

Library.ModifiableModel libraryModel = mylib.getModifiableModel();
VirtualFile jar = // Some jar file on local file system
libraryModel.addRoot (jar, OrderRootType.CLASSES);
libraryModel.commit();

When I am committing I see the following exception:

ERROR - epositoryCache.RepositoryCache - The following url expected to be a directory but happens to be a file: file://C:/misha/work/prodlogs/p63950/lib/javassist-3.4.GA.jar

Is it something that is expected or am I doing something wrong?

Thanks in advance,

Misha

1 comment
Comment actions Permalink

I answered my own question. My code should be:

Library.ModifiableModel libraryModel = mylib.getModifiableModel();
VirtualFile jar = // Some jar file on local file system
String url = VirtualFileManager.constructUrl (JarFileSystem.PROTOCOL, jar.getPath()) + JarFileSystem.JAR_SEPARATOR;
libraryModel.addRoot (url, OrderRootType.CLASSES);
libraryModel.commit();

It would be nice to document such quirks. It seems addRoot(VirtualFile) is nor usable with jars

0

Please sign in to leave a comment.