Loading resource


I want to add a jar file to the built plugin.


|       |
|        myclass.class

Is this possible in normal build process? Because I want to get the url of that jar in the code.
I use getclass().getResource() to get the full path of the  jar_I_need_to_Add.jar
. For that the resource should be with the .class files (Not with the source code).
In maven there is a seperate resource directory where we can use getclass().getResource() to
load resources giving relative path.  But here we don't find any in a plugin project.

How can we do that.?


Comment actions Permalink


you can copy jar_I_need_to_Add.jar to the source folder and ensure that jar files are accepted by 'Resource patterns' in File | Settings | Compiler.

Nikolay Chashnikov
Software Developer
JetBrains, Inc
"Develop with pleasure!"

Comment actions Permalink

Thank you very much for your answer it was very much helpfull. Plugin works fine now. I also tried to build the project using ant.
For any body who is interested I will put what I did.

go to Build --> Generate Ant Build

and generate build.xml setting the ideahome. There I had to do some modification in build.xml. It is as follows.

<patternset id="compiler.resources">
    <include name="**/?*.properties"/>
    <include name="**/?*.xml"/>
    <include name="**/?*.gif"/>
    <include name="**/?*.png"/>
    <include name="**/?*.jpeg"/>
    <include name="**/?*.jpg"/>
    <include name="**/?*.html"/>
    <include name="**/?*.dtd"/>
    <include name="**/?*.tld"/>
    <include name="**/?*.ftl"/>
    <include name="**/?*.jar"/>
    <include name="**/?*.js"/>


I inserted red coloured.

add js if you want to add javascript file as a resource and add jar if you want to add jar as a resource(I included both).
And then go to the project directory(root)  and type ant. This generates the plugin.jar at the root directory. For me It worked fine.
Is'nt that the same process that you described?



Please sign in to leave a comment.