标签:
https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-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:
If you haven‘t already done so, go ahead and open a terminal window and then do the following:
atlastutorial
folder you created earlier at the root of your home directory.Once you are in the folder, enter the atlas-create-jira-plugin
command to create the plugin.
atlas-create-jira-plugin
The command prompts you for the JIRA version.
1
for JIRA 5
and press RETURN.Respond to the prompts using the information in the following table:
Define value for groupId |
|
---|---|
Define value for artifactId |
|
Define value for version |
|
Define value for package |
|
The system prompts you to confirm the configuration you entered:
Confirm properties configuration:
groupId: com.atlassian.tutorial
artifactId: helloworld
version: 1.0-SNAPSHOT
package: com.atlassian.tutorial.helloworld
y
to continue.helloworld
project folder. This initial project folder contains the basic skeleton of a plugin.With a single command, you have a skeleton plugin project containing the following source:
Contents |
Description |
---|---|
|
A placeholder for a license file. |
|
Simple hints for running the atlas- commands. |
|
Maven configuration file for your project. |
|
The generated source for the plugin. |
Take a closer look at the code created for you in the src
directory. The src/test/java
contains a generated class and some placeholders for testing your plugin. You‘ll learn more about this later. The src/main
folder contains an initial/com/atlassian/tutorial/helloworld/MyPluginComponent.java
file and a/com/atlassian/tutorial/helloworld/MyPluginComponentImpl.java
. The src/main/resources
folder contains a singleatlassian-plugin.xml
file — 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:
Browse to and open the atlastutorial/helloworld/src/main/resources/atlassian-plugin.xml
file.
At this point the contents of the file should look like this:
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="helloworld"/>
<!-- add our web resources -->
<web-resource key="helloworld-resources" name="helloworld Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="helloworld.css" location="/css/helloworld.css"/>
<resource type="download" name="helloworld.js" location="/js/helloworld.js"/>
<resource type="download" name="images/" location="/images"/>
<context>helloworld</context>
</web-resource>
<!-- publish our component -->
<component key="myPluginComponent" class="com.atlassian.tutorial.helloworld.MyPluginComponentImpl" public="true">
<interface>com.atlassian.tutorial.helloworld.MyPluginComponent</interface>
</component>
<!-- import from the product container -->
<component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" />
</atlassian-plugin>
Several of the entries in the <plugin-info>
should look familiar. If you recall, the atlas-create-jira-plugin
command asked you for agroupId
and 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.
atlassian-plugin.xml
file.atlastutorial/helloworld/pom.xml
.artifactId
value.artifactId
you entered when you created the skeleton. The project.artifactId
you saw in the atlassian-plugin.xml
file references this value.groupId
and version
.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 the atlas-run
command. Try this command and see what happens:
Change directory to the root of your plugin project.
cd atlastutorial/helloworld
Enter the atlas-run
command.
The command creates a target
sub 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-standalone
command.
[WARNING] [talledLocalContainer] INFO: Deploying web application archive cargocpc.war
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.coyote.http11.Http11Protocol star
t
[WARNING] [talledLocalContainer] INFO: Starting Coyote HTTP/1.1 on http-2990
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.jk.common.ChannelSocket init
[WARNING] [talledLocalContainer] INFO: JK: ajp13 listening on /0.0.0.0:8009
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.jk.server.JkMain start
[WARNING] [talledLocalContainer] INFO: Jk running ID=0 time=0/130 config=null
[WARNING] [talledLocalContainer] May 9, 2012 8:15:56 AM org.apache.catalina.startup.Catalina start
[WARNING] [talledLocalContainer] INFO: Server startup in 100008 ms
[INFO] [talledLocalContainer] 2012-05-09 08:15:59,176 QuartzWorker-0 INFO ServiceRunner Backup Se
rvice [jira.bc.dataimport.DefaultExportService] Data export completed in 781ms. Wrote 622 entities t
o export in memory.
[INFO] [talledLocalContainer] 2012-05-09 08:15:59,186 QuartzWorker-0 INFO ServiceRunner Backup Se
rvice [jira.bc.dataimport.DefaultExportService] Attempting to save the Active Objects Backup
[INFO] [talledLocalContainer] 2012-05-09 08:15:59,487 QuartzWorker-0 INFO ServiceRunner Backup Se
rvice [jira.bc.dataimport.DefaultExportService] Finished saving the Active Objects Backup
[INFO] [talledLocalContainer] Tomcat 6.x started on port [2990]
[INFO] jira started successfully in 161s at http://manthony-PC:2990/jira
[INFO] Type Ctrl-D to shutdown gracefully
[INFO] Type Ctrl-C to exit
admin
.)atlas-run
and shutdown the process with CTRL-D
.In this step, you‘ll make a small change in your plugin‘s pom.xml
file. Then, you‘ll rebuild your plugin with the atlas-run
command.
pom.xml
file in your favorite editor.Locate the <organization>
element.
Update the element to look like the following:
<organization>
<name>HelloGoodby Inc.</name>
<url>http://www.helloworldgoodbye.com/</url>
</organization>
atlas-run
command in the terminal window.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.
标签:
原文地址:http://www.cnblogs.com/viewcozy/p/4912046.html