How do I get the Project object in my Wizard step?
Hi!
I have created own the ModuleWizardStep during processing of creation of the new project. I need to get a reference of the Project object. I'am calling wizardContext.getProject() and it's returning NULL. If I'am calling wizardContext.getProjectName() then it returns my real project name.
I need to attach jar files to the my project and I'am trying to get the project object at this ModuleWizardStep because I need to get the ModifiableModuleModel object..
Source sample:
ModifiableModuleModel modifiableModel = ModuleManager.getInstance(project).getModifiableModel();
Module theModule = modifiableModel.getModules()[0];
// Getting Module Root Model:
ModuleRootManager rootManager = ModuleRootManager.getInstance(theModule);
rootModel = rootManager.getModifiableModel();
// Creating the new Library, adding its jar:
Library myLibrary = rootModel.getModuleLibraryTable().createLibrary(libraryName);
libraryModel = myLibrary.getModifiableModel();
// addding my library
String jarUrl = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, jarFile.getAbsolutePath() + JarFileSystem.JAR_SEPARATOR);
VirtualFile jarVirtualFile = virtualFileManager.findFileByUrl(jarUrl);
libraryModel.addRoot(jarVirtualFile, OrderRootType.CLASSES);
// commit changes
libraryModel.commit();
rootModel.commit();
How do I get the Project object in my Wizard step?
or
What Shall I do to attaching jars to new project during processing of creation of the new project?
ps: Sorry for my English:)
Thanks:)
Please sign in to leave a comment.
Answer in the JavaModuleBuilder.
Method addModuleLibrary
public void addModuleLibrary(java.lang.String moduleLibraryPath,
java.lang.String sourcePath)