|
Re: changing an ordinary folder to a source folder in a project [message #181777 is a reply to message #181774] |
Mon, 27 November 2006 09:00 |
Remy Suen Messages: 462 Registered: July 2009 |
Senior Member |
|
|
Srikanth wrote:
> I have a folder in my project and I want to change it into a source
> folder. And the project is a Java Project. How should I do this?
If you mean for coding, just right-click on the folder in the Package
Explorer View, then Build Path -> Use as Source Folder.
If you mean how to do it using the JDT APIs, then you need to update
your IJavaProject's raw classpath.
// get your IProject
IProject project = getProject();
// create the corresponding IJavaProject
IJavaProject ijp = JavaCore.create(project);
// get the folder
IFolder folder = project.getFolder("nameOfNewSrcFolder");
// create a new source entry for it
IClasspathEntry entry = JavaCore.newSourceEntry(folder.getFullPath());
// retrieve the project's current classpath
IClasspathEntry[] entries = ijp.getRawClasspath();
// create a new array with the original entries and the new source entry
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
newEntries[newEntries.length - 1] = entry;
ijp.setRawClasspath(newEntries, new NullProgressMonitor());
That should be the general gist of it.
Regards,
Rem
|
|
|
Re: changing an ordinary folder to a source folder in a project [message #181782 is a reply to message #181777] |
Mon, 27 November 2006 09:35 |
Eclipse User |
|
|
|
Originally posted by: sri1025.gmail.com
> If you mean for coding, just right-click on the folder in the Package
> Explorer View, then Build Path -> Use as Source Folder.
Thanks Rem!
I meant for coding and sorry for not specifying that in the first post. I
use Java Browsing perspective for coding and Resource perspective for
dealing with the other folders so didn't find any options when I right
clicked on the folder which I wanted to change to a source folder.
Just got addicted to Java Browsing perspective and unable to come out of
it :D
Thank you very much,
Srikanth
|
|
|
Re: changing an ordinary folder to a source folder in a project [message #181834 is a reply to message #181782] |
Mon, 27 November 2006 18:42 |
Eclipse User |
|
|
|
Originally posted by: eclipse4.rizzoweb.com
Srikanth wrote:
>> If you mean for coding, just right-click on the folder in the Package
>> Explorer View, then Build Path -> Use as Source Folder.
>
> Thanks Rem!
>
> I meant for coding and sorry for not specifying that in the first post.
> I use Java Browsing perspective for coding and Resource perspective for
> dealing with the other folders so didn't find any options when I right
> clicked on the folder which I wanted to change to a source folder.
>
> Just got addicted to Java Browsing perspective and unable to come out of
> it :D
I, too, prefer Java Browsing perspective. However, there are several
ways you can accomplish this from that perspective:
a) you can use Window > Show View... to open the Package Explorer and
make it a Fast View that is minimized when not in use.
b) You can right-click the project name and choose Properties. On the
Build Path section of the Properties you can select additional source
directories.
Hope this helps,
Eric
|
|
|
|
Powered by
FUDForum. Page generated in 0.08781 seconds