I have a file model.xml i want to add to my eclipse plugin to read at runtime.
I tried adding it to the manifest.mf binary build and source build and adding it to the build.properties bin.includes but when I look in the bin folder there are only .class files.
Surely plugins can contain resources and not just .class files right?
You just list the file in the bin.includes in the build.properties - you should be able to do that in plugin.xml/MANIFEST.MF/build.properties editor.
For example in one of my plugins the build.properties is:
output.. = bin/
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
plugin.xml,\
fragment.e4xmi
source.. = src/
Which includes a plugin.xml and a fragment.e4xmi file.
Note: These are not copied to the bin directory in your project. When you test your plugin they will be accessed directly in the project. When you build/export your plug-in they will be included in the plugin jar.
You use the FileLocator API to access these files - that understands where to look.
For example, to access the fragment.e4xmi shown above:
Bundle bundle = FrameworkUtil.getBundle(getClass());
// or some other way to get the current bundle
URL url = FileLocator.find(bundle, new Path("fragment.e4xmi"));
Related
I'm trying to create a Plug-in project that reads a text file from a folder called "resources" of the same project.
From what I understood is that I need to add this folder to the build.properties like this:
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
resources/
However, after compiling my bin folder does not include the resources folder nor any of its files.
Is there any obvious mistake?
The final plug-in does not normally have a bin folder.
The bin.includes specifies which folders are copied in to the final plug-in. So your setting will give you a resources folder in the plug-in.
Use the FileLocator class to find resources in a plug-in.
I'm trying to create a plugin that compiles source into a jar as well as the com/ directory.
My build.properties contains:
bin.includes = META-INF/,\
plugin.properties,\
.
jars.compile.order = myDir/myJar.jar
source.myDir/myJar.jar = src/
output.myDir/myJar.jar = bin/
source.. = src/
And the manifest contains:
Bundle-ClassPath: myDir/myJar.jar, .
It seems to output as expected. But I'm not 100% sure this is right since I get a warning stating: The folders 'src/' share the same output folder but are targeted for different libraries in the build.properties.
For the build.properties file in Eclipse I get the warning
The plug-in's classpath library '.' does not have a corresponding source build entry
The build.properties file has the following content:
bin.includes = .settings/,\
META-INF/,\
.,\
Processes/,\
Resources/,\
Schemas/,\
Service Descriptors/,\
.WebResources/,\
pom.xml,\
target/
What am I missing here?
The . entry in the bin.includes is the entry for the plugn's main source code. The build needs to know where to look for that source code. For a plugin using a src directory for the source you need
source.. = src/
in the build.properties to provide that information.
You might also need
output.. = bin/
to say where the output classes are located.
I am attempting to develop an Eclipse plugin. The plugin runs from inside Eclipse (i.e. when I launch a test instance of Eclipse with my plugin from inside Eclipse, I can use the plugin in the test instance.)
However, when I attempt to generate a plugin that could be installed by other systems using File > Expoort > Deployable Plug-ins and fragments, the zip file created, contains a single jar file which itself contains only a manifest file:
$ jar tvf com.foo.bar_1.0.0.d.jar
0 Wed Feb 10 12:14:12 EST 2016 META-INF/
863 Wed Feb 10 12:14:10 EST 2016 META-INF/MANIFEST.MF
For example, it does not include my icons or my plugin.xml file.
I am not (yet) using maven-tycho or any other extra-Eclipse means of building the plugin.
Can anyone suggest what I may be doing wrong?
You must list everything you want in the plugin in the build.properties file, so check that file. When you run from within Eclipse this file is not checked for accuracy but it must be correct when you export.
For a simple plugin it might look something like:
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
OSGI-INF/
source.. = src/
This is including the 'META-INF' folder, the 'bin' folder (where your class files are), the 'plugin.xml' file and the 'OSGI-INF' folder.
In the plugin.xml editor use the 'Build' tab to set the contents of this file.
I have an eclipse RCP application, where I need to add some external jar files.
The problem is that I can't add the jars simply to a plugin and add this plugin to my RCP application.
For several reasons I must only add paths to directories where the jar files are located. These jar files have to be added to the program's classpath at startup.
And the paths to the directories are a variable (e.g. they are placed in a file).
Is there a possibility to add external paths somehow to the classpath?
add external directory to classpath,there are three method:
> **1. System.setProperty("java.class.path",
> System.getProperty("java.class.path")+";"+"directory");**
File file = new File("/home/../my.jar");
URLClassLoader classloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Method add = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class });
add.setAccessible(true);
add.invoke(classloader, new Object[] { file.toURI().toURL() });
configurate classpath variable in .bashrc