创建jira插件
2015-10-26 18:44
453 查看
准备环境、安装SDK
https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/install-the-atlassian-sdk-on-a-linux-or-mac-system
编写插件
https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/create-a-helloworld-plugin-project
Change directory to the
Once you are in the folder, enter the
1
The command prompts you for the JIRA version.
Enter
The command prompts you for the basic information each plugin needs.
Respond to the prompts using the information in the following table:
The system prompts you to confirm the configuration you entered:
1
2
3
4
5
Press
The system creates a
Take a closer look at the code created for you in the
At this point, your descriptor file should not define any modules. Let's test this, by looking in the descriptor file:
Open your favorite text editor.
Browse to and open the
At this point the contents of the file should look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Several of the entries in the
Your plugin includes resources that allow you to control look and feel. These appear under the web resources section. You'll learn more about these in another tutorial. For now, focus on the relatively simple
Close the
Open the
This file is a Maven project object model file. This file contains project and dependency information that Maven uses to build your plugin. This tutorial isn't going into the finer points of Maven or its files.
Search for the
You should find the
Familiarize yourself with the file a bit by looking for other values you entered through the command such as the
Close the file when you are done.
Open a command line (DOS prompt for Windows users).
Change directory to the root of your plugin project.
1
Enter the
The command creates a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/install-the-atlassian-sdk-on-a-linux-or-mac-system
编写插件
https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/create-a-helloworld-plugin-project
Create a HelloWorld Plugin Project
At this point, you have set up your environment and run a test with a standalone version of JIRA. In this section, you learn how to create a plugin module. For now, you are just going to use the command line tools. Later, you'll learn how to run the tools from an IDE. This page contains the following sections:Step 1: Create your first project
If you haven't already done so, go ahead and open a terminal window and then do the following:Change directory to the
atlastutorialfolder you created earlier at the root of your home directory.
Once you are in the folder, enter the
atlas-create-jira-plugincommand to create the plugin.
1
atlas-create-jira-plugin
The command prompts you for the JIRA version.
Enter
1for
JIRA 5and press RETURN.
The command prompts you for the basic information each plugin needs.
Respond to the prompts using the information in the following table:
Define value for groupId | com.atlassian.tutorial |
---|---|
Define value for artifactId | helloworld |
Define value for version | 1.0-SNAPSHOT |
Define value for package | com.atlassian.tutorial.helloworld |
1
Confirm properties configuration:
2
groupId: com.atlassian.tutorial
3
artifactId: helloworld
4
version: 1.0-SNAPSHOT
5
package: com.atlassian.tutorial.helloworld
Press
yto continue.
The system creates a
helloworldproject folder. This initial project folder contains the basic skeleton of a plugin.
Step 2: Examine the contents of the plugin skeleton
With a single command, you have a skeleton plugin project containing the following source:Contents | Description |
---|---|
LICENSE | A placeholder for a license file. |
README | Simple hints for running the atlas- commands. |
pom.xml | Maven configuration file for your project. |
src | The generated source for the plugin. |
srcdirectory. The
src/test/javacontains a generated class and some placeholders for testing your plugin. You'll learn more about this later. The
src/mainfolder contains an initial
/com/atlassian/tutorial/helloworld/MyPluginComponent.javafile and a
/com/atlassian/tutorial/helloworld/MyPluginComponentImpl.java. The
src/main/resourcesfolder contains a single
atlassian-plugin.xmlfile — this file is the descriptor. It defines the plugin modules your plugin uses.
At this point, your descriptor file should not define any modules. Let's test this, by looking in the descriptor file:
Open your favorite text editor.
Browse to and open the
atlastutorial/helloworld/src/main/resources/atlassian-plugin.xmlfile.
At this point the contents of the file should look like this:
1
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
2
<plugin-info>
3
<description>${project.description}</description>
4
<version>${project.version}</version>
5
<vendor name="${project.organization.name}" url="${project.organization.url}" />
6
<param name="plugin-icon">images/pluginIcon.png</param>
7
<param name="plugin-logo">images/pluginLogo.png</param>
8
</plugin-info>
9
<!-- add our i18n resource -->
10
<resource type="i18n" name="i18n" location="helloworld"/>
11
12
<!-- add our web resources -->
13
<web-resource key="helloworld-resources" name="helloworld Web Resources">
14
<dependency>com.atlassian.auiplugin:ajs</dependency>
15
16
<resource type="download" name="helloworld.css" location="/css/helloworld.css"/>
17
<resource type="download" name="helloworld.js" location="/js/helloworld.js"/>
18
<resource type="download" name="images/" location="/images"/>
19
<context>helloworld</context>
20
</web-resource>
21
22
<!-- publish our component -->
23
<component key="myPluginComponent" class="com.atlassian.tutorial.helloworld.MyPluginComponentImpl" public="true">
24
<interface>com.atlassian.tutorial.helloworld.MyPluginComponent</interface>
25
</component>
26
27
<!-- import from the product container -->
28
<component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" />
29
30
</atlassian-plugin>
Several of the entries in the
<plugin-info>should look familiar. If you recall, the
atlas-create-jira-plugincommand asked you for a
groupIdand an
artifactId. These values landed in another file all together.
Your plugin includes resources that allow you to control look and feel. These appear under the web resources section. You'll learn more about these in another tutorial. For now, focus on the relatively simple
<plugin-info>section.
Close the
atlassian-plugin.xmlfile.
Open the
atlastutorial/helloworld/pom.xml.
This file is a Maven project object model file. This file contains project and dependency information that Maven uses to build your plugin. This tutorial isn't going into the finer points of Maven or its files.
Search for the
artifactIdvalue.
You should find the
artifactIdyou entered when you created the skeleton. The
project.artifactIdyou saw in the
atlassian-plugin.xmlfile references this value.
Familiarize yourself with the file a bit by looking for other values you entered through the command such as the
groupIdand
version.
Close the file when you are done.
Step 3: Load the helloworld plugin into JIRA
Even though you haven't written any code, you can still load the skeleton plugin into JIRA. When you load a plugin into JIRA, it is visible in the Universal Plugin Manager (UPM). The UPM is in every Atlassian application. It allows you to install, view, and update plugins in your host application. The host application in this case is JIRA. You load a plugin using theatlas-runcommand. Try this command and see what happens:
Open a command line (DOS prompt for Windows users).
Change directory to the root of your plugin project.
1
cd atlastutorial/helloworld
Enter the
atlas-runcommand.
The command creates a
targetsub directory under your project root. You will examine this directory a bit more later. When the command completes successfully, you'll see some output that looks very similar to the output of the
atlas-run-standalonecommand.
1
[WARNING] [talledLocalContainer] INFO: Deploying web application archive cargocpc.war
2
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.coyote.http11.Http11Protocol star
3
t
4
[WARNING] [talledLocalContainer] INFO: Starting Coyote HTTP/1.1 on http-2990
5
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.jk.common.ChannelSocket init
6
[WARNING] [talledLocalContainer] INFO: JK: ajp13 listening on /0.0.0.0:8009
7
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.jk.server.JkMain start
8
[WARNING] [talledLocalContainer] INFO: Jk running ID=0 time=0/130 config=null
9
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.catalina.startup.Catalina start
10
[WARNING] [talledLocalContainer] INFO: Server startup in 100008 ms
11
[INFO] [talledLocalContainer] 2012-05-09 08:15:59,176 QuartzWorker-0 INFO ServiceRunnerBackup Se
12
rvice [jira.bc.dataimport.DefaultExportService] Data export completed in 781ms. Wrote 622 entities t
13
o export in memory.
14
[INFO] [talledLocalContainer] 2012-05-09 08:15:59,186 QuartzWorker-0 INFO ServiceRunnerBackup Se
15
rvice [jira.bc.dataimport.DefaultExportService] Attempting to save the Active Objects Backup
16
[INFO] [talledLocalContainer] 2012-05-09 08:15:59,487 QuartzWorker-0 INFO ServiceRunnerBackup Se
17
rvice [jira.bc.dataimport.DefaultExportService] Finished saving the Active Objects Backup
18
[INFO] [talledLocalContainer] Tomcat 6.x started on port [2990]
19
[INFO] jira started successfully in 161s at http://manthony-PC:2990/jira[/code]
20[INFO] Type Ctrl-D to shutdown gracefully
21[INFO] Type Ctrl-C to exit
Open your browser and log into the JIRA instance.
(Remember, the username and password are bothadmin.)
Select the
cog (Administration) icon in the right corner.
Choose Add-ons from the menu.
The system places you on the Administration page.
Choose Manage Add-ons from the left-hand menu.
The system opens the Manage Add-ons page.
Locate the helloworld plugin listings in User-installed Add-ons category.
You'll find two listings for your plugin. One for the plugin itself and one for the plugin tests.
Expand each entry by click it.
You should see the following for the plugin alone:
The plugin has just the basic modules that you get for "free" when you create a plugin. These modules don't do much yet.
Close the JIRA browser window.
Return to the terminal window where you startedatlas-runand shutdown the process withCTRL-D.Step 4: Make a change and see it reflected in the application
In this step, you'll make a small change in your plugin'spom.xmlfile. Then, you'll rebuild your plugin with theatlas-runcommand.
Open thepom.xmlfile in your favorite editor.
Locate the<organization>element.
Update the element to look like the following:
1<organization>
2<name>HelloGoodby Inc.</name>
3<url>http://www.helloworldgoodbye.com/</url>
4</organization>
Save and close the file.
Run theatlas-runcommand in the terminal window.
Open the plugins page in your browser using the following path http://localhost:2990/jira/plugins/servlet/upm#manage.
JIRA still prompts you for the username/password.
Expand the helloworld plugin to see your changes.The Next Steps
So far, you've used the SDK from a command line. However, most programmers working in complex code prefer the help of an integrated development environment (IDE). One of the most popular IDE is Eclipse. In the next section, you install and configure the Eclipse IDE on Windows orfor Linux/Mac. If you are using IntelliJ, please see this page.
相关文章推荐
- 安装python及web.py
- MyEclipse相关部署问题
- Python的运行时方法补丁技术
- FusionChartsFree例子
- IDEA maven项目创建速度慢
- OO设计模式五大原则
- unicode和ascII
- jQuery fileupload 一次上传多个文件
- Linux系统的内存分配
- 2015长春赛区总结
- 小学奥数 李白的酒
- 嗅探的实现与防范
- 【蓝桥杯练习题】出现次数最多的整数
- 海量数据挖掘MMDS week5: 计算广告Computational Advertising
- AES在Android、JAVA端正常加密解密
- Memcached有个stats命令
- 海量数据挖掘MMDS week5: 计算广告Computational Advertising
- 为什么要在JAVA,C++等集合中引入迭代器
- Conclusion SIFT描述子提取步骤
- JDBC关于时间的存取