The plugin is invoked by when the core component is used by one of the Pineapple clients. To trigger invocation by the core component the plugin needs to be configured.
Two steps are needed to configure the plugin:
For more info about configuration of plugins:
The plugin supports the operations:
For more information about the default operations, refer to the Operation and workflow reference.
When invoked with this operation the plugin will traverse the module model and create all the Git entities (e.g. repository) defined in the model:
The purpose of defining a resource for this plugin is twofold:
To define a new resource, add a resource element to the target environment in the configuration file ${pineapple.home.dir}/conf/resources.xml:
<?xml version="1.0" encoding="UTF-8"?> <configuration xmlns="http://pineapple.dev.java.net/ns/environment_1_0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <environments> <environment id="local" > <resources> <resource id="git-pineapple-example-repo" plugin-id="com.alpha.pineapple.plugin.git" /> <property key="uri" value="https://github.com/athrane/pineapple-git-plugin-test-repository.git"/> </resource> </resources> </environment> </environments> </configuration>
For all the details about configuration of environments and resources, please visit the Environment Configuration Reference.
The semantics of the resource element is:
Identifies the resource uniquely in the current environment. This ID is referenced from models which intends to use the plugin.
A module defines the input used by Pineapple to execute operations. A module is defined by a directory layout. Part of a module is the model(s) which defines what happens when the module is invoked. A model is put together by one or more sub models from different plugins. Each plugin defines its own schema for its particular model
This plugin defines a schema named The Git plugin schema which defines the http://pineapple.dev.java.net/ns/plugin/git_1_0 namespace. For more information about where the schema can be found, refer to the Schema locations for plugins page.
The list of entities which should be processed when the plugin is invoked are defined in the module model files which are located at ${module-dir}/models/${environment}.xml where:
If the model file doesn't exist for an environment where the plugin should be used, then create the model file and name it after the target environment, e.g. linux-vagrant.xml for an environment named linux-vagrant.
Module model files are defined using the module model configuration schema which defines the http://pineapple.dev.java.net/ns/module_model_1_0 namespace. Since module model files contain elements from multiple namespaces all the elements and attributes should be qualified. The header and root element should be defined as (look in the Modules configuration document for more details):
This example shows definition of the minimal model file for linux-vagrant:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" />
The next step is to include the The Git plugin schema to get access to the entities defined by the schema:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:gp="http://pineapple.dev.java.net/ns/plugin/git_1_0" />
Now we have a minimal module model file with three namespaces:
Add a new model stanza with a target-resource attribute. The value of the target-resource should match the id of the resource which was defined previously in the section Define resource, e.g. git-pineapple-example-repo:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:gp="http://pineapple.dev.java.net/ns/plugin/git_1_0" /> <mmd:model target-resource="git-pineapple-example-repo"> <mmd:content /> </mmd:model> </mmd:models>
Add content to the model which uses the plugin through the git-pineapple-example-repo reference:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:gp="http://pineapple.dev.java.net/ns/plugin/git_1_0" /> <mmd:model target-resource="git-pineapple-example-repo"> <mmd:content> <gp:git> </gp:git> </mmd:content> </mmd:model> </mmd:models>
Define a set of entities which should be processed when Pineapple is invoked with the model:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:gp="http://pineapple.dev.java.net/ns/plugin/git_1_0" /> <mmd:model target-resource="git-node"> <mmd:content> <gp:git> <gp:repository destination="modules:pineapple-git-plugin-test-repository" branch="master" /> </gp:git> </mmd:content> </mmd:model> </mmd:models>
Defines a Git repository.
<gp:repository destination="modules:pineapple-git-plugin-test-repository" branch="master" />
Operation semantics:
The semantics of the attributes are:
Optional attribute. Defines the branch which is cloned, when a remote repository is cloned. Default value is master.
Example: HEAD and 1.0.
Optional attribute. Defines the local destination where the cloned repository is stored, when a remote repository is cloned. The value can be prefixed with the modules: identifier. If the identifier is present then Pineapple will interpret the path as an relative path where the root is the Pineapple modules directory. If the identifier is present then the path is resolved with the root in Pineapple modules directory. Afterwards the cloned repository is positioned and can be used as a module if the repository contains a module.
Default value is modules:project where the project is resolved from the project part of the URI defined for Git resource. See Git on the Server - The Protocols.
Examples: modules:pineapple-git-plugin-test-repository and /tmp/myrepo.