Skip to main content



      Home
Home » Newcomers » Newcomers » claspath relative to plugin
claspath relative to plugin [message #263334] Mon, 18 August 2008 06:10 Go to next message
Eclipse UserFriend
Originally posted by: agata.vackova.javlinconsulting.cz

Hi,
is is possible to set classpath in project properties relative to an
plugin? I need to set something like that:
<classpathentry kind="lib"
path=" platform:/plugin/com.cloveretl.gui/lib/lib/cloveretl.engine. jar "/>
So, the path would depend on the plugin location and in different eclipses
the path would show to different locations.
Re: claspath relative to plugin [message #263337 is a reply to message #263334] Mon, 18 August 2008 06:18 Go to previous messageGo to next message
Eclipse UserFriend
I'm not sure why you wouldn't just make your project a plugin project
and let the PDE manage the classpath for you by adding a dependency on
the com.cloveretl.gui plugin in the MANIFEST.MF?

agad wrote:
> Hi, is is possible to set classpath in project properties relative to
> an plugin? I need to set something like that:
> <classpathentry kind="lib"
> path=" platform:/plugin/com.cloveretl.gui/lib/lib/cloveretl.engine. jar "/>
> So, the path would depend on the plugin location and in different
> eclipses the path would show to different locations.
>
Re: claspath relative to plugin [message #263339 is a reply to message #263337] Mon, 18 August 2008 06:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: agata.vackova.javlinconsulting.cz

I create java example project which needs some jar files provided by a
plug-in.
When creating this project by wizard it works properly and has correct
paths, but when I import it to another eclipse I need to change the path.
I would like to have in .classpath file paths relative to plug-in
location. Is is possible?
Re: claspath relative to plugin [message #263342 is a reply to message #263339] Mon, 18 August 2008 06:40 Go to previous messageGo to next message
Eclipse UserFriend
I don't think there are any symbolic variables that would definitely
work for this purpose (because plugins could be installed in places like
the dropins folder or using link files). You could define a variable
yourself for just that one jar and then the other users would need to
define it as well. Note that even if you aren't developing a plugin,
you'd likely find that making your project a plugin project will make it
easier to manage the classpath. The scenario you describe would work
very well, for example.


agad wrote:
> I create java example project which needs some jar files provided by a
> plug-in.
> When creating this project by wizard it works properly and has correct
> paths, but when I import it to another eclipse I need to change the
> path. I would like to have in .classpath file paths relative to
> plug-in location. Is is possible?
>
Re: claspath relative to plugin [message #263345 is a reply to message #263342] Mon, 18 August 2008 07:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: agata.vackova.javlinconsulting.cz

So, can I define a variable or user library in "Cretate my project"
wizard? I would like user need do nothing after wizard ends its job (like
now, when the path is hardocored) and importing such project would be easy
to (now user need to change 22 jar paths, which are provided with one
plugin).

Ed Merks wrote:

> I don't think there are any symbolic variables that would definitely
> work for this purpose (because plugins could be installed in places like
> the dropins folder or using link files). You could define a variable
> yourself for just that one jar and then the other users would need to
> define it as well. Note that even if you aren't developing a plugin,
> you'd likely find that making your project a plugin project will make it
> easier to manage the classpath. The scenario you describe would work
> very well, for example.


> agad wrote:
>> I create java example project which needs some jar files provided by a
>> plug-in.
>> When creating this project by wizard it works properly and has correct
>> paths, but when I import it to another eclipse I need to change the
>> path. I would like to have in .classpath file paths relative to
>> plug-in location. Is is possible?
>>
Re: claspath relative to plugin [message #263352 is a reply to message #263345] Mon, 18 August 2008 07:15 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------010104060708010604030004
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Agad,

We have some somewhat brutal code like this that determines the
classpath for plugins and creates variables to put on the classpath of a
generated project, but we generally avoid that now by always creating a
project with a PDE nature:

| *public static *List<String> getClasspathPaths(String pluginID) *throws *JETException
{
List<String> result = *new *ArrayList<String>();
*try*
{
Bundle bundle = Platform.getBundle(pluginID);
String requires = (String)bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH);
*if *(requires == *null*)
{
requires = ".";
}
ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, requires);
*if *(elements != *null*)
{
*for *(*int *i = 0; i < elements.length; ++i)
{
ManifestElement element = elements[i];
String value = element.getValue();
*if *(".".equals(value))
{
value = "/";
}
*try*
{
URL url = bundle.getEntry(value);
*if *(url != *null*)
{
URL resolvedURL = FileLocator.resolve(url);
String resolvedURLString = resolvedURL.toString();
*if *(resolvedURLString.endsWith("!/"))
{
resolvedURLString = resolvedURL.getFile();
resolvedURLString = resolvedURLString.substring(0,resolvedURLString.length() - "!/".length());
}
*if *(resolvedURLString.startsWith("file:"))
{
result.add(resolvedURLString.substring("file:".length()));
}
*else*
{
result.add(FileLocator.toFileURL(url).getFile());
}
}
}
*catch *(IOException exception)
{
*throw new *JETException(exception);
}
}
}
}
*catch *(BundleException exception)
{
*throw new *JETException(exception);
}
*return *result;
}

/**
* An {@link IClasspathAttribute#getName() class path attribute name}
* that records the originating plugin ID
* for each classpath entry created by
* {@link #addClasspathEntries(Collection, String)}
* and {@link #addClasspathEntries(Collection, String, String)}.
* @since 2.3
*/
*public static final *String PLUGIN_ID_CLASSPATH_ATTRIBUTE_NAME = "plugin_id";

*public static **void *addClasspathEntries(Collection<IClasspathEntry> classpathEntries, String variableName, String pluginID) *throws *JETException
{
*for *(ListIterator<String> i = getClasspathPaths(pluginID).listIterator(); i.hasNext(); )
{
IPath path = *new *Path(i.next());
*if *(variableName == *null*)
{
classpathEntries.add
(JavaCore.newLibraryEntry
(path, null, null, null, *new *IClasspathAttribute [] { JavaCore.newClasspathAttribute(PLUGIN_ID_CLASSPATH_ATTRIBUTE _NAME, pluginID) } , *true*));
}
*else*
{
String mangledName = variableName + (i.previousIndex() == 0 ? "" : "_" + i.previousIndex());
*try*
{
JavaCore.setClasspathVariable(mangledName, path, *null*);
}
*catch *(JavaModelException exception)
{
*throw new *JETException(exception);
}
classpathEntries.add
(JavaCore.newVariableEntry
(*new *Path(mangledName), null, null, null, *new *IClasspathAttribute [] { JavaCore.newClasspathAttribute(PLUGIN_ID_CLASSPATH_ATTRIBUTE _NAME, pluginID) }, *true*));
}
}
}|



agad wrote:
> So, can I define a variable or user library in "Cretate my project"
> wizard? I would like user need do nothing after wizard ends its job
> (like now, when the path is hardocored) and importing such project
> would be easy to (now user need to change 22 jar paths, which are
> provided with one plugin).
>
> Ed Merks wrote:
>
>> I don't think there are any symbolic variables that would definitely
>> work for this purpose (because plugins could be installed in places
>> like the dropins folder or using link files). You could define a
>> variable yourself for just that one jar and then the other users
>> would need to define it as well. Note that even if you aren't
>> developing a plugin, you'd likely find that making your project a
>> plugin project will make it easier to manage the classpath. The
>> scenario you describe would work very well, for example.
>
>
>> agad wrote:
>>> I create java example project which needs some jar files provided by
>>> a plug-in.
>>> When creating this project by wizard it works properly and has
>>> correct paths, but when I import it to another eclipse I need to
>>> change the path. I would like to have in .classpath file paths
>>> relative to plug-in location. Is is possible?
>>>
>
>

--------------010104060708010604030004
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Agad,<br>
<br>
We have some somewhat brutal code like this that determines the
classpath for plugins and creates variables to put on the classpath of
a generated project, but we generally avoid that now by always creating
a project with a PDE nature:<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">
Re: claspath relative to plugin [message #263357 is a reply to message #263352] Mon, 18 August 2008 07:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: agata.vackova.javlinconsulting.cz

Hi, the solution looks fine, but I get error:
Access restriction: The method setClasspathVariable(String, IPath,
IProgressMonitor) from the type JavaCore is not accessible due to
restriction on required library
/home/avackova/eclipses/Ganymede/eclipse/plugins/org.eclipse .jdt.core_3.4.0.v_874.jar

, so I can't use it :-(
Re: claspath relative to plugin [message #263359 is a reply to message #263352] Mon, 18 August 2008 07:54 Go to previous message
Eclipse UserFriend
Originally posted by: agata.vackova.javlinconsulting.cz

Seems to work - thank you :-). Sorry for last post - wrong dependencies
order.
Previous Topic:Highlight a Line in an editor
Next Topic:JFreeChart is eclipse question
Goto Forum:
  


Current Time: Fri May 02 08:38:09 EDT 2025

Powered by FUDForum. Page generated in 0.08492 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top