====== Project as a Module Library ====== A project can be exported as a library usable from other projects. The exported library makes all types (classes, modules, ...) and resources (images, shaders, ...) available for import. These libraries are called module lib. Tutorial on creating and using a module lib [[:tutorials:advanced:create-module-lib|here]]. ===== Structure ===== Module lib follows the structure of [[:dev-guide:creating-own-plugin|GroIMP plugins]]. Thus, the way the lib is integrated is described in the ''plugin.xml'' file, automatically created when exported. ===== Compiled resources ===== All resources included in the project are added to a compiled resource zip (.grz file), that is automatically created when exported. The resources from this zip are loaded by GroIMP on startup, and made available through the imported types and references. The references can resolve resources from a module lib in the GroIMP path with the name: ''plg:{package name}.{plugin name}:{resource name}''. ===== Compiled classes ===== The classes in the project are exported compiled. ==== Package name ==== By default, .rgg types are compiled without a package. It makes them all visible from the same pool. However, to ensure uniqueness when importing module library, a package name is required during the export. GroIMP will use the given package name as default package during the compilation. Thus, if the project contains types with the named package, they will not be affected by the package name provided. The package name must follow java's specification on package names. ==== Reference wrapper ==== GroIMP implicitly wraps all references call in the project to be exported as a module library to make them use the resources from the library. Suppose we have a project that contains a resource with the name "shaderleaf". When exported, the module that uses ''setShader(shader("shaderleaf"))'', needs to point at the resource from the module lib, and not at a possible "shaderleaf" in a newly opened project. The wrappers force the references to point at ''plg:pkg.Plugin:"shaderleaf"''.