I am trying to add an xsl file (ctest2junit.xsl) to the resources directory of my Bamboo plugin. I have modified the atlassian-plugin.xml by adding this line in the taskType tag:
<resource type="download" name="ctest2junit" location="ctest2junit.xsl"/>
Now, how do I access this resource from my Task class ?
In the execute method I tried various things without success :
URL xsl = getClass().getResource("ctest2junit");
// or
URL xsl = getClass().getResource("main/resources/ctest2junit");
I guess I am plain wrong. Could someone tell me how I should do that ?
Community moderators have prevented the ability to post new answers.
This seems to work (Missing the forward slash!)
URL xsl = getClass().getResource("/foo.xsl");
buildLogger.addBuildLogEntry("xsl : " + xsl );
Sorry for the confusion!
Anecdotally, I think declaring the resource in atlassian-plugin.xml and providing a class to load those resources would be much more straightforward than forcing you to load it from the classloader itself might be a good idea. Ill try to get something like that in the next release of the plugin api.
It works now, thank you very much.
I think that your idea is good. I instinctively tried to add the resource in atlassian-plugin.xml.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You were half right - you don't need to specify a <resource> element in the plugin discriptor (this is currently only used for resources that can be referenced in the UI). Simply change your code sample like so:
URL xsl = getClass().getResource("ctest2junit.xsl");
and you should get a valid URL to your XSL file :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your message. I have removed the resource element in the plugin descriptor and modified the code as specified :
URL xsl = getClass().getResource("ctest2junit.xsl");
buildLogger.addBuildLogEntry("xsl : " + xsl );
However, I get :
xsl : null
It seems there is still something wrong. The XSL file is in ./src/main/resources/ctest2junit.xsl and the java source is in src/main/java/ch/xxx/yyy/CTest2JUnitConverterTask.java
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.