Buildr Integration
Domgen is typically configured so that each time a project is built, domgen loads repository and generates any required artifacts as part of the build process. Domgen provides some rake tasks to support this use case. These rake tasks detect the presence of Buildr and if present will offer additional functionality as part of the build.
Loading the repository
Assuming domgen is braided into the
vendor/plugins/domgen
directory, the developer will typically create a
tasks/domgen.rake
file. This file will define a task that loads the repository
definition. By convention the repository definition is stored in a file named
architecture.rb
in the base directory of the project.
The developer can also pass a parameter to the define_load_task
method that
specifies the location of the repository definition.
Defining generator tasks
If a task generates code or assets that are compiled or packaged within a particular
project then then the method Domgen::Build.define_generate_task
should
be invoked within the block that defines the project. The first parameter is an array
of generators that are to be run. These task will generate
the source code within the projects base directory and will automatically add the source
to the project paths as appropriate. The tasks will have a name that is prefixed by the
project tasks.
If however the generator is independent of any particular project, it is more appropriate to
define the generator task in the tasks/domgen.rake
. As the generators are outside
of projects it is also required that additional configuration be supplied. Projects with a
database typically define the generators for sql in the following manner:
:repository_key | The name of the repository to run generators for. If there is a single repository then the repository name is the default value. |
---|---|
:target_dir | The base directory in which to generate artifacts, relative to the buildfile. Defaults is derived from buildr project path and :key value. |
:key | The string name used when naming the task and used if deriving a default directory. Defaults to the local project name if a buildr project is specified or the task is defined within a project else it defaults to 'default'. |
:buildr_project | The associated buildr project that is used to derive defaults and is extended to add paths to when source is generated. Defaults to the containing buildr project or nil. |
Defining XMI generator
Due to legacy reasons, the XMI generator uses a separate method to define the xmi task.
:repository_key | The name of the repository to run generators for. If there is a single repository then the repository name is the default value. |
---|---|
:filename | The name of the xmi file that is generated by task. Default is derived from the buildr project if specified, or the top level project if there is only one and the task is defined outside the project. |
:key | The string name used when naming the task and used if deriving a default directory. Defaults to the local project name if a buildr project is specified or the task is defined within a project else it defaults to 'xmi'. |
:buildr_project | The associated buildr project that is used to derive defaults. Defaults to the containing buildr project or the top level project if there is only one. |