How to use createMavenJarInfo to download required libraries for my Facet

Hi

I want to declare required libraries of my web facet. As I know, I should override getLibraries method on my FacetFrameworkSupportProvider class. In this method, I should return an array of LibraryInfo object, each representing a library as a jar file. Intellij will download them automatically from Maven repository. I have studied source code of struts facet plugin and tried to follow their implementation pattern. They have used MavenLibraryUtil.createMavenJarInfo method to create required library info object.

Signature of this method is:

public static LibraryInfo createMavenJarInfo(@NonNls String jarName , @NonNls String version , @NotNull @NonNls String... requiredClasses ) {
return createMavenJarInfo( jarName , version, jarName , requiredClasses);
}

Also there is another implementation of this method that is private and has an additional parameter that is downloadURL of the library (it's a first parameter of private method). This private one is called by above method. As it's clear, they are calling it passing jarName as downloadURL of the jar file.

This works fine for libraries (jar files) exists on first level of maven repository. But if you need a library under some subdirectories of maven repository, you can't use this method. As there is no usefull documentation about open api on the web (sorry JetBrains guys!). I don't know if there is another such utility to use. So I have implemented my own MavenUtil class that accepts downloadURL as a first parameter and it works fine.

I want to know that is there any utility method that could do this for me, so that I could remove my duplicate implementation and use an underlying api.

2 comments
Comment actions Permalink

You can use MavenLibraryUtil.createSubMavenJarInfo().

Hi

I want to declare required libraries of my web facet. As I know, I should override getLibraries method on my FacetFrameworkSupportProvider class. In this method, I should return an array of LibraryInfo object, each representing a library as a jar file. Intellij will download them automatically from Maven repository. I have studied source code of struts facet plugin and tried to follow their implementation pattern. They have used MavenLibraryUtil.createMavenJarInfo method to create required library info object.

Signature of this method is:

public static LibraryInfo createMavenJarInfo(@NonNls String jarName , @NonNls String version , @NotNull @NonNls String... requiredClasses ) {
return createMavenJarInfo( jarName , version, jarName , requiredClasses);
}

Also there is another implementation of this method that is private and has an additional parameter that is downloadURL of the library (it's a first parameter of private method). This private one is called by above method. As it's clear, they are calling it passing jarName as downloadURL of the jar file.

This works fine for libraries (jar files) exists on first level of maven repository. But if you need a library under some subdirectories of maven repository, you can't use this method. As there is no usefull documentation about open api on the web (sorry JetBrains guys!). I don't know if there is another such utility to use. So I have implemented my own MavenUtil class that accepts downloadURL as a first parameter and it works fine.

I want to know that is there any utility method that could do this for me, so that I could remove my duplicate implementation and use an underlying api.



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

`Thanks Nikolay

Yes, I'll check it tonight.

0

Please sign in to leave a comment.