A bit of a blast from the past now that OpenLayers 3 has been released but it may be useful for someone who is working on or maintaining an OpenLayer 2 project.
Create a list of OpenLayers 2 classes used within a code base suitable for including in a custom build profile.
cd /path/to/your/js/ grep --ignore-case --recursive --no-filename --only-matching 'new OpenLayers\.[a-z0-9\.]*' | \ sed -e 's/new //' -e 's/\./\//g' -e 's/$/\.js/' | \ sort | \ uniq
- Find instances of
new OpenLayers.FOOin all source files below the current directory using
"new "from each matching line, replace the dots which separate the parts of the class name with forward slashes and add
.jsto the end to complete the path all using
-eapplies an expression to each line)
- Sort the list with
- Remove duplicates with
If you find
OpenLayers/Layer/Vector.js in the list then the vector rendering classes will need to be included manually:
OpenLayers/Renderer/Canvas.js OpenLayers/Renderer/SVG.js OpenLayers/Renderer/VML.js
If you are using classes such as
OpenLayers.LonLat. You will find that when using the build script you get an error as the source files can not be found as the class names do not match the location in the OpenLayers source. In most cases for these base classes you can simply remove them from the build config file as they will be automatically included as they are referenced by the other classes such as