How to find manifest file ?

Any ideas on how i can get hold of every META-INF/MANIFEST.MF file in the module classpath as a PsiFile ?

Thanks.

12 comments
Comment actions Permalink

Hello Hugo,

Any ideas on how i can get hold of every META-INF/MANIFEST.MF file in
the module classpath as a PsiFile ?


You can start with PsiShortNameCache.getFilesByName("MANIFEST.MF").

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

That only seems to work for files in project scope.
I need to find the manifest files in the dependencies jars of a module.

0
Comment actions Permalink

Hello Hugo,

That only seems to work for files in project scope. I need to find the
manifest files in the dependencies jars of a module.


1) com.intellij.psi.PsiManager#findPackage()
2) com.intellij.psi.PsiPackage#getDirectories()
3) com.intellij.psi.PsiDirectory#findFile()

Spring plugin does this, combined with CachedValuesProvider.

-tt


0
Comment actions Permalink

I tried that, but PsiManager#findPackage() doesn't return the META-INF "package".

0
Comment actions Permalink

You have wrong project setup then. SpringSchemaProvider.java does this.
You can check the source code for sample.

0
Comment actions Permalink

Is the source code for the Spring plugin available ? I can't find it in the dev package.

I will check it out, but the Spring plugin is for 7.0 only and i'm using 6.0.5 so the behaviour is different in these versions.

0
Comment actions Permalink

Hello Hugo,

Is the source code for the Spring plugin available ? I can't find it
in the dev package.


http://svn.jetbrains.org/idea/Trunk/bundled/spring/

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks, i see the code.

Well, i'm doing the same thing but for me PsiManager.findPackage("META-INF") always returns null.
Could this be a behaviour change from 6.0.5 to 7 ?

0
Comment actions Permalink

Hello Hugo,

Thanks, i see the code.

Well, i'm doing the same thing but for me
PsiManager.findPackage("META-INF") always returns null. Could this be
a behaviour change from 6.0.5 to 7 ?


Ah, indeed, I remember I fixed this early in 7.0.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Ok, so is there any workaround for this ?

0
Comment actions Permalink

Anyone ?

Sorry to bump this but i can't find any workaround and it would be great if someone could confirm that either there's no workaround or if there is one so that i can move on.

0
Comment actions Permalink

Hello Hugo,

Anyone ?

Sorry to bump this but i can't find any workaround and it would be
great if someone could confirm that either there's no workaround or if
there is one so that i can move on.


You can get all content roots of modules and libraries and check for the
presence of META-INF and MANIFEST.MF by directly traversing the VFS. Since
you're interested only in specific paths, this won't be a major performance
problem.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.