How do you make your public class accessible to the plugin-user?

By that I mean, I want to make a public class, which I as the plug-in writer authored, available for use by the plug-in user.

Just the way I use System.out.println(), written by Sun to write my plug-in, so I want the plugin users to be able to invoke in their code my API.

So I was thinking that I needed to include the public class in a jar I deploy with my plugin. It sounds simple, but really I can't find any answers searching in the forum and none of the documentation addresses it.

4 comments

Hello softwarevisualization,

By that I mean, I want to make a public class, which I as the plug-in
writer authored, available for use by the plug-in user.

Just the way I use System.out.println(), written by Sun to write my
plug-in, so I want the plugin users to be able to invoke in their code
my API.

So I was thinking that I needed to include the public class in a jar I
deploy with my plugin. It sounds simple, but really I can't find any
answers searching in the forum and none of the documentation addresses
it.


For a class to be visible from a module if should be present in the modules
dependencies.
(similar to java.lang.System, which is linked through module/project JDK)

You could programatically add a library dependecy to a given module. However,
linking that dependency to JAR file that is part of your plugin seems a bit
brittle.

Look at bundled Jetbrains plugins - there's no magic there.
Hibernate plugin requires hibernate JAR on the classpath, etc.

-tt


0

Hi Taras,

Thanks for replying.

OK, so an acceptable approach is to require the user to manually download and install a jar and then add it to the classpath for their project? I am worried that it ought to happen automagically for the plugin user. Do users go for this? So there is not a mechanism that automatically adds .jars to any project the plugin has been loaded into?

0

No, there's no mechanism which magically adds your plugin jar to the project. Normally the IDE(A) is used to create software which should be able to run outside of the IDE. Having such an automatic dependency to your plugin would break that. By forcing the user to add your plugin jar manually to the project makes it obvious that he has to distribute your plugin jar together with his software once development is finished.

0

Well that makes sense to me. The details of my plugin are such that the the user would not want to include my jar in their distribution; my plugin is a development-only tool, the way refactoring is of development-only interest.

0

Please sign in to leave a comment.