Eclipse showing lots of unrelated files in project explorer - eclipse

I'm new to Eclipse, having done a lot of development in Visual Studio and XCode.
When I create a C++ project in my source tree the project explorer shows all the files in that folder and sub-folders. However there are lots of unrelated files that I don't want to see.
In Visual Studio and XCode I have to manually link source code to the project. This allows me to control the clutter of the project. Non-project files are "hidden" by default, because they aren't added to the project. In Eclipse everything is added by default. It seems that you can't decouple the file system's storage from the view you see in the project explorer.
Also I have a bunch of source in my tree that I don't want to compile as part of this project. Because it's for a different platform. I can't see how to remove these files from the compile list without also removing them from the file system.
Reading the docs hasn't helped much. What am I missing here?

There are 2 parts to this solution. First file name filters can be defined as described in this post:
Eclipse: how to hide custom files in Project Explorer
2nd the remaining files that I don't want compiled can be excluded by right clicking on them and Properties -> C++ build -> Exclude resource from build.
So it's more a negative space thing. In traditional systems, you have to explicitly add code to the project. In Eclipse you have to explicitly REMOVE code from the project. I prefer the old way because sometimes you want to include code from disparate regions on the disk and that just makes the all inclusive model of eclipse break. But I guess I'll cross that bridge when I get to it. sigh

Related

Separating source and build ouptut in Eclipse

Recently, my work computer was suffering hardware failures so I had the pleasure of migrating data over to a new computer. A project itself is much smaller than the generated output and a significant portion of time was spent moving those generated output.
Currently:
C:\workspace\Project\src\...
C:\workspace\Project\bin\...
Ideally:
C:\workspace\Project\src\...
C:\workspace_output\Project\bin\...
NOTE: For me the source is linked so they don't actually exist within the project.
I was able to change one particular project by following the directions here. However, I have numerous projects and it would be a fairly time-consuming to apply that change to each project (create an "output folder" then point the project to that folder).
Is there a better way to define this behavior within Eclipse? I couldn't find a ${PROJECT_NAME} system variable that I could use (e.g. something like this). I'm fine if the answer is NO as it appears that I have to manually set this for each project. Maybe the next best thing is to write a script to automatically create folders and modify the .project and .classpath.
An alternative like:
Start Eclipse on new machine, point it to the old workspace
Clean projects
Then copy projects onto new machine
Use Eclipse on new machine.
where I can cut out the work of "cleaning" the projects because they are already separate.
In general you'd want to use some kind of version control system or source code management, such as cvs, svn, git, Perforce, Visual SourceSafe, etc. Barring that, you can also use File > Export (or right-click on projects) to export a project or group of projects from Eclipse and it will, by default, exclude any derived content (such as compiled code). Then you can import those projects into another Eclipse workspace.

how to create a general project only containing one folder in netbeans 6.9

how to create a general project only containing one folder in netbeans 6.9? In eclipse i can do it, but in netbeans sometime i just want to organize some files related to some category, so i want to create a single project just only containing folder and files, but now it seems that it's not possible.
if someone has the same problem, and can share your experience, thank u.
When I need to have access to a collection of files located in a folder or group of sub-folders, and I don't need much IDE support, then I add the top-level folder to the "Favorites" tab. From there I can open any file in an editor, and perform other file system commands that NetBeans makes available. If you are using a version control system supported by NetBeans with that collection of files, then those commands should be available to you too. What is not available are things like "Build" and "Debug", etc. (obviously).
If you cannot see the "Favorites" tab (it would be in with "Projects", "Files", "Services", etc.), then open the Window menu and click on Favorites.
As #lepe suggests, if your files all tend to be of a particular type, then you can create a project of that type, and then have access to the files on the "Projects" tab. Just ignore the "extra" stuff that NetBeans is giving you.
Finally, "Freeform" project types exist for certain types of projects, and Java also has an "Automatic" project type (if you install the appropriate plugin from the Update Center). These types of projects more closely resemble NetBeans-generated projects insofar as they are designed to be used with existing Ant build.xml scripts and whatnot (Automatic projects are a bit looser on that), but they still assume that the project is intended for builds, etc.
If you have a "generic" project that uses Ant to "do stuff" kind of like a build, then you might be able to subvert one of the "Freeform" project types, cajoling it into what you need.
In the end, I find just having the folder in "Favorites" works the best for me when I don't need all the extra stuff.
The benefit of Projects as opposed to Favorites is that each project remembers the files you had open when you last switched away from that project.
I use NetBeans just for editing web stuff (HTML, CSS and JavaScript files) within the context of a larger Java project (for which I use Eclipse). I use the PHP version of NetBeans, since it's the most light weight version that handles these web resources. To create a new NetBeans project for my existing Java web app I do: File > New Project > PHP > PHP Application with Existing Sources. On the next wizard screen, in "Sources Folder" browse for the folder that is the parent of all your web stuff (e.g. src/main/webapp). Leave all the other fields with their default values, just to humour NetBeans that we're dealing with a PHP project. Click Finish. No PHP specific stuff gets created. A "nbproject" folder is the only thing that gets created in your chosen folder. (There is the option of locating this outside of the project but I find it convenient to have it located with the project itself, and I just configure my source control system to ignore this folder.)

Eclipse autocomplete not working in some Java files

I have noticed that autocomplete is not working in some of java files in Eclipse.
Also, the files where autocomplete is not working, display a hollow "J" as the icon for the Java file. The files where autocomplete is working, icon for java file is a filled "J"
I am wondering if someone can point out what went wrong all of suddent, why the change in icons and why autocomplete and syntax highlighting is turned-off in the files with a hollow "J" icon?
Thanks.
update
Basically, I was doing what VonC has suggested but Eclipse was not refreshing that it why I was thinking that VonC's suggestion isn't working, after doing a refresh, the problem resolved.
Since this question is highly ranked on Google, I will add a solution to fix general auto complete issue, not for 'hollow J' ones.
Try Window (Windows/Linux) or Eclipse (OS X) -> Preferences -> Java -> Editor -> Content Assist -> Restore Defaults
also
Content Assist -> Advanced -> Restore Defaults
some answers (restore defaults) above do not work for some adt bundle installs as of jan '13.
in those cases, go to
Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced
and tick on the JAVA PROPOSAL options.
In this following picture, MyClass.java has a hollow J, because it is explicitly excluded from the sources to build:
Could you go to the properties of the project, "Java Build Path" Section, "Source" tab and see if some exclusion filter has been set ?
It is usual for instance to define:
**/Test*.java
to exclude at first building any unit-test class (when you have a large set of sources and do not want to be presented with Test classes during auto-completion, or do not want them considered during source searches).
Those with a hollow J aren't part of the build path of the project, so they can't participate in the normal build process and therefore auto-complete won't be enabled for these files (and other Java editor features!). You must add the folders with the Java files to be built to the build path using the 'source path' section of the project properties. This can be accessed by right clicking on a project in the project navigator / package explorer and going to Properties. See http://www.informit.com/articles/article.aspx?p=367962 for details.
Additionally, if the files aren't part of a Java project in the first place, you must create a project and move the files in, or put the files in an existing one. Again, make sure these file are under a source directory as described by that section of the project properties.
(source: teradata.com)
I cope with the issue by deleting the file if autocomplete does not work. Just before copying the source code. Then I have recreated the java file with the same name. Pasted the source code previously copied.
As an addendum to the #VonC answer, make sure that the Java files are part of the Inclusion pattern. I had a case where a build process was creating the project while only including .js files and not the Java files:
You can manually edit the inclusions via the Edit button. In my case, a fix was made to the build script to make it permanent.
Neither Restoring Defaults or my build path (file was already in package directory w/other files where auto-complete was working) fixed problem. Fix for me was to close the file explicitly (right click on file name in tab) and re-open. Interestingly, just re-starting Eclipse didn't work either.
Make sure you have the right directory structure. I believe that:
Hollow J icon beside Java file - will not be build
Normal J icon beside Java file - is a file to be build.
I made a mistake when I created webapp artefact. By default it does not create folder for Java, but for resources. I mistakenly put my sources there.
Have a look - see the difference.
I was able to get this fixed in Visual Studio Code, VSCode but entering crtl-shift-p and typing in clean. When I did that I ran the "Java: Clean Java Language Sever Workspace" command. This fixed my autocomplete issue for me.

Which NetBeans projects files should go into source control?

We normally use Eclipse for a particular Java project, but recently I imported the project into NetBeans to use its dialog building features.
Since I'll probably come back to this, I wanted to store the NetBeans project files into version control. However, I don't want to commit files that are "mine" versus "project", i.e., files with my own settings that would conflict with another user's.
NetBeans created the following structure in the top-level project area:
nbbuild
nb-build.xml
nbproject
<various files>
configs
private
Clearly nbbuild is build output, so that won't go in. The nb-build.xml file seems likely, as does most of nbproject. However, nbproject/private suggests it's "mine". Peeking at "configs", it's not clear to me if that's mine or project...
Anyone have some guidelines?
The NetBeans knowledge base article on project files & version control discusses the NetBeans project files, with loose advice about which files are project specific (i.e. can be shared via version control), and which are user specific.
Here is the section on version control:
If the project is checked out of a version control system, the build (or nbbuild), dist (or nbdist), and the nbproject/private folders should not be checked into that version control system.
If the project is under the CVS, Subversion, or Mercurial version control systems, the appropriate "ignore" files are created or updated for these directories when the project is imported.
Though nbproject/private should be ignored, nbproject should be checked into the version control system. nbproject contains project metadata that enables other users to open the project in NetBeans without having to import the project first.
It turns out that both Thomas & Petercardona are correct, in a way. NetBeans recommends that you only import source code and/or documentation. Oh and the nbproject folder but not the *nbproject/private** folders.
From the NetBeans Knowledge Base article on importing Eclipse projects:
Version Control Considerations
If the project is checked out of a
version control system, the build (or
nbbuild), dist (or nbdist), and the
nbproject/private folders should not be checked into that version control
system.
If the project is under the CVS,
Subversion, or Mercurial version
control systems, the appropriate
"ignore" files are created or updated
for these directories when the project
is imported.
Though nbproject/private should be
ignored, nbproject should be checked
into the version control system.
nbproject contains project metadata that enables others users to open the
project in NetBeans without having to
import the project first.
None.
Only source files, build scripts, and documentation that is not automatically generated (e.g. - the output of tools such as JavaDoc and Doxygen) should be checked into a repository. Things like project files, binaries, and generated documentation should not be checked in.
The reason is two-fold. First, you don't want to overwrite another developer's project settings with your own. Second, other developers might not be using the same IDE as you (or even an IDE at all), so don't give them any more than they need to build (the project or its associated documentation) or run the project.
As tested with Netbeans 6.8, only the project.xml, configurations.xml and the main makefile (the customisable one in the parent dir of the 'nbproject' dir, with pre/post target definitions) must be distributed via the repository. All other files will be automatically (re)generated by Netbeans (Makefile-impl.ml, Makefile-variables.ml, all the Makefile-$CONF, Package-$CONF.bash). The 'private' dir should also be ignored, obviously.
You can check also
https://github.com/github/gitignore/blob/master/Global/NetBeans.gitignore
This open source project contains
A collection of useful .gitignore templates
Toptal has a useful tool for developers wanting to find out what should go on a .gitignore file.
https://www.toptal.com/developers/gitignore
For netbeans, just search Netbeans and it should return a template something like
**/nbproject/private/
**/nbproject/Makefile-*.mk
**/nbproject/Package-*.bash build/
nbbuild/
dist/
nbdist/
.nb-gradle/
Copying and pasting this into a .ignore file on your project's directory should solve your problem.

Why is eclipse trying to compile files not in my build path?

I have a rather large project which contains a number of third-party dependencies which are linked via svn:externals. These include tomcat and blazeDS, which are packaged by our installer via ant. The problem is that these projects contain dozens of sample JSP pages, and eclipse chokes on them when trying to build the project, producing hundreds of errors.
Our project setup is something like this:
src/
main/
test/
third-party/
blazeDS/
tomcat/
etc.
Now, in eclipse, my project's build path is set to only include subfolders in src/main and src/test. Yet, for some reason, it still tries to build everything beneath third-party. I have clicked on third-party and selected "remove from build path", but this had no effect. I even tried adding the third-party folder to the build path, and then excluding "", "/*", and "**/*.jsp", but again, to no effect.
What is going on here?
Edit: Thanks for the suggestions, though unfortunately, they don't seem to fix the issue. I don't have the CheckStyle plugin installed (I'm using Eclipse 3.4.1 with the only custom plugins being subclipse and flex builder), and I tried disabling all extra builders except for Java, but the errors are still being thrown.
I usually have this kind of issue with CheckStyle plugin, where you need to specify in its properties (right-click on project -> Properties -> CheckStyle):
"Exclude from check Files non located in a source directory"
Otherwise it does analyze (and reports warning/errors on) files which are not candidate to be compiled in the first place.
Couple of other suggestions:
try restarting your eclipse with the -clean option (eclipse software version of 'did you reboot it ?' ;) ). Beware it can reset your workspace perspectives, so you may want to try that with a copy of your workspace instead.
try deleting your project (your workspace reference of your project, not its actual content), and reimporting it (beware of your custom launchers, they may get removed in the process).
check if you do not have any linked directory within src or test, which would point to thirdparty(/**): that would explain the unwanted compilation.
It could be that your eclipse project is configured to have extra Builders. You can check that in the project's properties (right-click on project -> Properties -> Builders).
In my case it was because there was a reference to the file (which I had excluded from the build path) in another file which was in the build path. I wanted to exclude SegModel.hpp from the build path, but in another file, I had specified template short K::KEstimate<SegModel>(SegModel& m, short stepCode);