Build JIRA Plugins Using Apache Ivy/Ant
Atlassian Plugin SDK comes with a custom maven distribution and build and test system based on maven. As with other maven projects, customising the build process is difficult and time intensive.
In our projects, we need the ability to include Groovy classes as part of the plugin sources. There was no easy way to include the Groovy class compilation phase into the maven system. We decided to develop our own ant and ivy based build system similar to the build system we use for all our projects to address the situation. The only downside of this is that we lose the maven based command-line plugin install system which speeds up the plugin install process before testing. On the bright side, this removes the necessity to download the Atlassian Plugin SDK and modify the PATH environment to use the supplied maven.
Directory Structure
The directory structure adopted (shown below) for the plugin project is similar to the standard SPT project structure that is adopted for all our projects.
Dependency Management
Apache Ivy is used as the dependency management system, since it integrates seamlessly into the very flexible and easy to use Ant build system. The ivy dependency configuration file shows the various dependencies we required for our plugin project. Note that the exclude list excludes all the libraries that are included in the groovy-all jar file that is available from the Groovy installation. A custom ivy settings file was necessary to add the Atlassian maven repository to the repository search path. Lastly a standard ant build script and associated properties file was used to build the plugin jar file.
To summarise, the following are the files necessary to build the plugin:
Plugin Distribution
Plugins are developed and distributed as jar files with a few custom settings used by the Atlassian plugin system. The Atlassian plugin system uses OSGI to load and configure the plugins dynamically. The following are the customisations to the jar file necessary to comply with the plugin management system.
- Include the config/atlassian-plugin.xml at the root of the jar file hierarchy.
- Include all libraries required for the module in the META-INF/lib directory of the jar file (Note: you may also chose to aggregate all the jar file into a single jar)
- Include all resources (Velocity templates, images, CSS etc) into the jar file.
The following is a sample structure for a plugin jar file
META-INF/META-INF/MANIFEST.MFMETA-INF/lib/META-INF/lib/XmlSchema-1.4.7.jarMETA-INF/lib/cxf-bundle-2.2.7.jarMETA-INF/lib/groovy-all-1.8.2.jarMETA-INF/lib/groovyws-0.5.2.jarMETA-INF/lib/jaxb-api-2.1.jarMETA-INF/lib/jaxrpc-api-1.1.jarMETA-INF/lib/jdom-1.1.jarMETA-INF/lib/jtds-1.2.4.jarMETA-INF/lib/wsdl4j-1.6.2.jaratlassian-plugin.xmlsptci/sptci/submgr/sptci/submgr/action/sptci/submgr/component/sptci/submgr/model/sptci/submgr/action/IsbnSearch$_populate_closure1.classsptci/submgr/action/IsbnSearch.classsptci/submgr/component/Isbn.classsptci/submgr/model/Book.classsptci/submgr/model/DatabaseConnection.classsptci/submgr/model/ServerConfiguration.classsptci/submgr/model/TMMConnection.classtemplates/templates/browser-isbnsearch.vmtemplates/edit-isbn.vm
Once the plugin jar file has been created, you can install to a running JIRA system through the administration section.