对于我的小工具,我将所有 XML、HTML、JavaScript 和 CSS 从 atlassian-plugin.xml 中分离出来。
最初的设置比较复杂,但是一旦你把它弄对了,关注点的分离就比把所有东西都改成atlassian-plugin.xml 文件要好得多。
另一方面,相对路径确实看起来很疯狂。
我的文件系统如下所示:
- resources/
- gadgets/
- css/
- example.css
- html/
- example.html
- js/
- example.js
- examaple-gadget.xml
- atlassian-plugin.xml
在/resources/atlassian-plugin.xml:
<!-- add our web resources -->
<web-resource key="${project.artifactId}-resources" name="${project.artifactId} Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="example-gadgets/" location="/gadgets"/>
<context>immersive-for-connections</context>
</web-resource>
<gadget name="Example JIRA Gadget" i18n-name-key="example-jira-gadget.name" key="example-jira-gadget" location="gadgets/example-gadget.xml">
<!-- hosted at: /rest/gadgets/1.0/g/${project.groupId}.${project.artifactId}:example-gadgets/gadgets/example-gadget.xml -->
<description key="jira-query-gadget.description">The JIRA Query Gadget Plugin</description>
</gadget>
在/resources/gadgets/example-gadget.xml 中(将${project.artifactId} 和${project.groupId} 替换为正确的值):
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
...
<Content type="html" view="example.view" preferred_width="100%" href="../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/html/example.html"/>
</Module>
在/resources/gadgets/html/example.html 中(将${project.artifactId} 和${project.groupId} 替换为正确的值):
<!DOCTYPE html>
<html>
<head>
...
<!-- added ../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/ to most relative links -->
<link href="../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/css/example.css" type="text/css" rel="stylesheet">
<script src="../../../../../../download/resources/${project.groupId}.${project.artifactId}:${project.artifactId}-resources/gadgets/js/example.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
...
</body>
</html>