

def use_plugin(pluginName):
  from org.gvsig.andami import PluginsLocator

  pluginsManager = PluginsLocator.getManager()
  other = pluginsManager.getPlugin(pluginName)
  scripting = pluginsManager.getPlugin("org.gvsig.scripting.app.mainplugin")
  scripting.addDependencyWithPlugin(other)

def use_jar(fname, root=__file__):
  from java.io import File
  import sys
  import os

  if isinstance(fname,File):
    f = fname
    fname = f.getPath()
  else:
    f = File(fname)
  if not f.isAbsolute() :
    rf = File(root)
    if rf.isFile() :
      rf = rf.getParentFile()
    f = File( rf,fname)

  fname = f.getCanonicalPath()
  if not fname in sys.path:
    sys.path.append(fname)

