|
Re: changing an ordinary folder to a source folder in a project [message #181777 is a reply to message #181774] |
Mon, 27 November 2006 04:00   |
Eclipse User |
|
|
|
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 #181933 is a reply to message #181834] |
Tue, 28 November 2006 03:25  |
Eclipse User |
|
|
|
Eric Rizzo wrote:
> 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:
Me too ;-)
What I recommend is to replace the Projects view with the Package
Explorer and save the perspective again. There's a filter in the Package
Explorer that allows you to filter the Java files (if you don't want to
see them).
HTH
Dani
> 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.06338 seconds