- Library definition: consists of the name of the library, the library type, a pointer to the library archive volume(s).
- Library reference: a reference to a library object, especially used when a project consumes a library.
- Actual Library: the actual set of all the files belong to library in an archive, excluding any metadata that might exist. It is interchangeable with raw library.
Goals & Strategies
- Some of 3rd party libraries will be bundled with the IDE standard distribution and others will be made available on the stable update center. A more detailed list of these libraries to be bundled can be found in this plan.
- Additional metadata may need to be defined to express addtional support for things like:
- Location of documentation files in SDoc format etc.
In order to achieve the goals stated above, the implementation includes:
- Defining the libraries with the proper information and registering them in the IDE
- Consuming the libraries in a Web, PHP or Ruby on Rails project.
- library.properties. This file contains properties that provide information related to library consumption. The following properties are to be implemented:
LibraryRoot=<path from archive root to library folder> DefaultLibraryDir=<default relative destination folder in projects that consume the library> (optional)
The LibraryRoot property is used to determine the actual location of the library files. This is used by the Library Manager when a library is consumed to ignore unneeded zip artifacts (e.g. from jmaki) and to shorten the path to the library when extracted (e.g. resources/some_library/some_library_version_1.0/a_file could be extracted to $projectdir/web/a_file if desired).
- Packaging in an NBM which basically consists of a NetBeans Module wrapper for the library archive, its library definition and the layer file registration information. This can then be installed via the Plugin Manager and will appear automatically in the Libraries manager automatically upon a successful installation.
When choosing Add Library, there will be a dialog that lists all the available libraries to be added:
The default location for each project type is:
- For Web projects, the location is web/resources/<library name>
- For Ruby on Rails projects, the location is public/resources/<library name>
- For PHP projects, the location is $src-root/resources/<library name> (where $src-root is defined by the PHP project)
The specified location must be under the web folder of the project or under the project folder. If the library.properties file exists and provides a LibraryRoot property, the files are extracted as specified above; otherwise, all of the contents of the zip archives provided by the library definition are extracted.
If the destination directory contains some files that will be overwritten by the library extraction, a warning dialog appears. If the user selects "No", then the library is not added to the project. After the user selects "Yes" to add the library, every file that is to be overwritten brings up a dialog providing options to handle the collision (Yes, No, No to All, Yes to All).
When one or more libraries are selected in the libraries customizer and the 'Remove' button is pressed, the following steps are executed for each selected library:
- A dialog appears, asking the user if the library's files should be removed as well. If the user selects "No", no further action is done.
- All files and directories extracted or created during the library consumption are removed. This includes the folders that may have been created when the user selected a destination folder for the library.
- Unresolved library reference - Occurs when there is no library definition for a given library reference in the project.
- Missing Sources - Occurs when there are no files associated with the library reference in the project (relative to the location specified by the user).
When the library references are in these error states, the Remove action removes the library reference from the project without deleting any project source files.
- Get all libraries first: LibraryManager.getDefault().getLibraries()
- Get the 'scriptpath' volume content: Library.getContent("scriptpath"). This returns a URL to the actual archive zip file. The content of the zip file can then be extracted into a relative project location.
- Get notified when a library is added / registered in the Library Manager: LibraryManager.addPropertyChangeListener. Consider using WeakListeners to avoid memory leaks.
- Add a library: LibraryManager.getDefault().addLibrary()
Issues not solved for NetBeans 6.5:
- Widget library consumption