Atlassian JIRA 插件开发(二) — 插件项目框架搭建

直入话题,创建插件框架,并采用Eclipse开发。

1.创建插件文件目录,用于存放自己的代码和开发版JIRA程序;
这儿是SDK安装目录的bin文件夹,可以看到有很多的批处理命令,下面我们就采用atlas-create-jira-plugin来创建jira plugin:
Atlassian JIRA 插件开发(二) — 插件项目框架搭建_第1张图片
一定有人问:atlas-create-jira4-plugin有何用?这是因为JIRA版本间有一定的差异,各个插件的适应范围也不同,创建也有一定的差别。这个差别也会在JIRA升级的时候体现出来。

2.创建插件项目;
打开命令行,输入atlas-create-jira-plugin,截图如下:
Atlassian JIRA 插件开发(二) — 插件项目框架搭建_第2张图片
这时候,需要输入一定的内容:

  • Define value for groupId: : atlas.plugin.jira(项目组)
  • Define value for artifactId: : yieryi(插件项目名称)
  • Define value for version: 1.0-SNAPSHOT: :(插件项目版本,默认不输入为1.0,以后你可以为1.1等,这个要与插件版本区别开)

余下内容不用输入,直接回车,然后就会出现以下内容:
Atlassian JIRA 插件开发(二) — 插件项目框架搭建_第3张图片
成功之后,可以进入插件项目目录下查看:
Atlassian JIRA 插件开发(二) — 插件项目框架搭建_第4张图片
发现目下有一个文件夹【src】和三个文件。使用maven开发过项目的孩子应该知道pom.xml的作用,一切的修改由此开始。
进入到【src】目录下可以看到有两个文件夹,main和test,mian是用来存储插件代码,test用来存储测试代码。
Atlassian JIRA 插件开发(二) — 插件项目框架搭建_第5张图片

3.生成Eclipse的插件项目
在pom.xml所在文件夹路径下,在命令行中输入:

atlas-mvn eclipse:add-maven-repo -Declipse.workspace="你的plugin project的Eclipse空间路径"

注:最近我更新了Maven库,发现此命令不好用了,报错
这里写图片描述

atlas-mvn eclipse:configure-workspace -Declipse.workspace="你的plugin project的Eclipse空间路径"

来替代上面命令即可,原因还未找到,看看官网是否有说法。
这样在此路径下就会生成此plugin project的Eclipse 空间的相关信息,如图:

之后将此plugin project代码工程文件导入到Eclipse空间下,在pom.xml文件路径下,执行atlas-mvn eclipse:eclipse,即可。
此plugin project路径下生成.settings文件夹,就是Eclipse的配置。

新版SDK生成Eclipse时报错:
Atlassian JIRA 插件开发(二) — 插件项目框架搭建_第6张图片

[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.yieryi:test >---------------------------
[INFO] Building test 1.0
[INFO] --------------------------[ atlassian-plugin ]--------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping test
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.989 s
[INFO] Finished at: 2020-07-19T09:54:27+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "${mavenPluginName}=$mavenPluginName". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

This error is generated if you try to invoke a build command that Maven does not understand. In general, you have the following options to perform build steps:

Invoke a lifecycle phase, e.g. mvn install This runs the lifecycle
phase install and all its predecessor phases like compile and test.
Please see Introduction to the Build Lifecycle for more information
about available lifecycle phases. Invoke a plugin goal via the plugin
prefix, e.g. mvn compiler:compile Eventually, the plugin prefix
translates to a group id and artifact id of a plugin. Maven resolves
plugin prefixes by first looking at the plugins of the current
project’s POM and next by checking the metadata of user-defined plugin
groups. Invoke a plugin goal via the versionless plugin coordinates,
e.g. mvn org.apache.maven.plugins:maven-compiler-plugin:compile To
resolve the plugin version, Maven will first check the project’s POM
and fallback to the latest release version of the plugin that was
deployed to the configured plugin repositories. Invoke a plugin goal
via the fully qualified plugin coordinates, e.g. mvn
org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile You can
freely mix all of these styles within a single command line.

The error described here is usually caused by typo in the command so
be sure to check you specified a valid lifecycle phase.

你可能感兴趣的:(插件开发,Atlassian)