How do I get the Project object in my Wizard step?

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

How do I get the Project object in my Wizard step?


What Shall I do to attaching jars to new project during processing of creation of the new project?

ps: Sorry for my English:)


1 comment
Comment actions Permalink

Answer in the JavaModuleBuilder.

Method addModuleLibrary

public void addModuleLibrary(java.lang.String moduleLibraryPath,
java.lang.String sourcePath)


Please sign in to leave a comment.