How to create library for module with its ModuleDependencyItem.DependencyScope scope?

Answered

Lets say, i can create lib and add it to module. for example

ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
LibraryTable libraryTable = rootModel.getModuleLibraryTable();
Library lib = libraryTable.createLibrary(libName);
Library.ModifiableModel modifiableModel = lib.getModifiableModel();
String libPath = "some path";
modifiableModel.addJarDirectory("file://" + libPath, true);
modifiableModel.commit();
rootModel.commit();

but it add by default in compile scope. i need to add a library in provided scope in some case. 
but for now unable to pass `ModuleDependencyItem.DependencyScope` while create a lib. 
is there any api available to pass ModuleDependencyItem.DependencyScope while create lib.

Thanks in advance

0
1 comment

See com.intellij.openapi.roots.ModuleRootModificationUtil#addModuleLibrary(com.intellij.openapi.module.Module, java.lang.String, java.util.List<java.lang.String>, java.util.List<java.lang.String>, com.intellij.openapi.roots.DependencyScope)

0

Please sign in to leave a comment.