Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Web Resource Plugin Dependency

Jeffrey Gullett August 13, 2019

I am attempting to write a Jira web resource plugin, but can't figure out the magic string for the dependency name so that I can use a specific Javascript file.  The file I want to use is located in C:\Program Files\Atlassian\JIRA\atlassian-jira\includes\jquery\plugins\color\color-min.js (or just color.js).  I already have included the dependency com.atlassian.plugins.jquery:jquery.  How do I ensure this other Javascript file is available by the time my Javascript gets run?  I have tried com.atlassian.plugins.jquery:color and com.atlassian.plugins.color:color, without success.  In general, where are these magic strings defined?

My atlassian-plugin.xml file looks like:

<atlassian-plugin ...>
    <plugin-info>
        ...
    </plugin-info>
    <web-resource name="my resources" key="my-key">
        <dependency>com.atlassian.plugins.jquery:jquery</dependency>
        <resource type="download" name="my.js" location="js/my.js" />
        <context>atl.general</context>
    </web-resource>
</atlassian-plugin>

An my.js looks like:

var WHITE = $.Color(255, 255, 255);

How can I modify either atlassian-plugin.xml or my.js to ensure that the color-min.js script has been loaded prior to declaring the global WHITE variable?

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2019

Hello,

You need to load your resources either in vm or soy template. For vm it would be like this:

 $webResourceManager.requireResourcesForContext("pluginkey:jira-plugin-resources")

Jeffrey Gullett August 13, 2019

Forgive my ignorance (I am new to developing Jira plugins), but I don't understand your answer.  I have updated the question with more details about my specific use case.  Do I just need to add this line to my Javascript file?  What exactly does that line do?  Thanks!

Suggest an answer

Log in or Sign up to answer