| Author |
Message |
|
|
Post subject: Accessing resources outside your plugin
Posted: Jan 08, 2008 - 02:36 AM
|
|
Joined: Nov 05, 2007
Posts: 13
|
|
Hi,
Has anyone ever tried using some resources outside your plug-in?
The plug-in jar is installed in the ECLIPSE/plugin directory.
If i have another folder within the same directory , what is the best way to get the path to the file(s) stored in that folder.
Any pointers/examples would be of great help,
/Prameela |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Accessing resources outside your plugin
Posted: May 05, 2008 - 06:18 AM
|
|
Joined: May 05, 2008
Posts: 2
|
|
I had the same issue..
in your Do Finish method add this piece of code
IProjectDescription description = ResourcesPlugin.getWorkspace()
.newProjectDescription(project.getName());
project.create(description, null);
if (project.exists() && !project.isOpen()) {
project.open(null);
}
// Setting Java Nature to the eclipse project
String[] natures = description.getNatureIds();
String[] newNatures = new String[ natures.length + 1 ];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[ natures.length ] = JavaCore.NATURE_ID;
description.setNatureIds(newNatures);
project.setDescription(description, null);
Create Java Project
IJavaProject javaProject = JavaCore.create(project);
if (javaProject.exists() && !javaProject.isOpen()) {
javaProject.open(null);
}
//creating web_struc.xml
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(new Path(containerName));
if (!resource.exists() || !(resource instanceof IContainer)) {
throwCoreException("Container \"" + containerName + "\" does not exist.");
}
IFolder outFolder = project.getFolder(new Path("out"));
if (!outFolder.exists()) {
outFolder.create(false, true, monitor);
}
IFolder outFolder1 = project.getFolder("test");
outFolder1.create(false,true,monitor);
IClasspathEntry[] rawClassPath = javaProject.getRawClasspath();
List classPath = new ArrayList(Arrays.asList(rawClassPath));
classPath.add(JavaRuntime.getDefaultJREContainerEntry());
IClasspathEntry[] paths = (IClasspathEntry[]) classPath.toArray(new IClasspathEntry[ classPath.size() ]);
javaProject.setRawClasspath(paths, null); |
|
|
| |
|
|
|
 |
|
|
| |