Eclipse: Switching between build configurations doesn't update excluded files - eclipse

I have two c++ source files. I am building each in a separate build configuration. I have set up each build configuration to exclude the other source file. In the Project Explorer, one of the file's icons has a slash through it, showing it as the source file that is excluded and I cannot refactor code for this source file. This is all as expected, done according to the instructions found here.
I have verified that each file has the "Exclude resource from build" box checked for the appropriate build configuration. Furthermore, I have verified that the build command for each build configuration builds the correct source file.
Then I click Project->Build Configurations->Set Active and select the other build configuration but the same source file is excluded. I also tried switching configurations by actually building the different configurations, but again, the file exclusions remain the same (both the icon shows it as deactivated and I cannot refactor that source file).
I have searched various posts but do not see the exact circumstance I'm facing, though this one was close. Perhaps I don't know the correct terminology to do a proper search.
Am I switching between configurations correctly? Is there a workaround for this behavior (besides including all files in the build, if I need to refactor, and then re-excluding them before build)?
I have seen this behavior in Nsight (running Eclipse 3.8) and in Eclipse Mars (4.5.0). I am running on Linux CentOS 6.7, 64-bit.

In Window->Preferences->Indexer, select "Use active build configuration" (help.eclipse.org/mars/…) in the frame titled "Build configuration for the indexer".

Related

Eclipse does not show source code of maven dependencies in debug view

I've filed a bug by now: 495662 - Source Lookup: Not seeing source code in the debug view.
My issue sounds familiar but it can't be since that issue appears to be fixed. However,
I have set a breakpoint in a class coming from a dependency (via maven). The source code got downloaded but as the program reaches the line all I get to see is
Source not found.
I've tried to add lookup paths by clicking at "Edit Source Lookup Path..." but nothing changed. I don't know what I have to add such that the debugger finds the sources.
It appears that this stopped working for all my dependencies.
How did I break my source lookups and how can I fix it?
Could be important:
I am running my tomcat from a maven build these goals:
tomcat7:run-war -am -pl mz-web-server -Denv=dev
but this hasn't been a problem so far.
Further, none of my maven dependencies e.g. gwt-user*.jar or `spring*.jar or anything are listed in the Source Lookup Path. There is only the "Default" path which doesn't contain it either - shouldn't those jars be somewhat listed there?
After downloading Eclipse Mars 2, removing my project completely and re-importing it without any .settings, .project or .classpath files, I am still seeing this problem. I can't tell if this is really an Eclipse bug but at this point I don't know what else it could be.
I also tried removing C:\Users\<username>\.eclipse and restarted the IDE without different results.
These are the included libraries under Maven Dependencies. As you can see e.g. spring-security-core-*.jar is included and the source is pointing to the local maven repository. Clicking on edit I see the full path C:/Users/Stefan/.m2/repository/org/springframework/security/spring-security-core/4.0.3.RELEASE/spring-security-core-4.0.3.RELEASE-sources.jar and yes, the file is really there.
My Classpath Variables:
I don't know what the actual problem was and why it stopped working. As you can take out of my question I actually downloaded a clean version of Eclipse, checked out the naked project and imported it with maven without results.
However, I found this com.ifedorenko.m2e.sourcelookup plugin. The link was provided in "Java Debugging: Source not found".
Go to Help > Install New Software .. and use
http://ifedorenko.github.com/m2e-extras/
to search for the links. After installing this plugin I was finally able to debug the source code of dependencies.
Tested for Eclipse Neon:
Press 'Edit Source lookup ...', press Add button for 'Java Classpath Variable' in dialog and choose M2_REPO variable and press 'Extend...'.
Then choose source jar file for wanted dependency from file system tree.
After that press 'OK' on all dialogs and relaunch debug process.

Subclipse: How to add the default output folder to version control (*.class files)?

I am using eclipse 4.2 and Subclipse 1.8.20.
I am trying to add the contents of /WebContent/WEB-INF/classes to version control (this is also the default output folder of my project).
First let me state that this is possible with TortoiseSVN. I do understand why by default Subclipse ignores this directory, and I tried to change the Team settings, but I am not seeing a relevant entry for *.class files:
Is this at all possible with Subclipse?
More info:
Old an unanswered similar question: http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=473163
Same topic but opposite question: How can I ignore build directory in Subclipse?
It is a horribly bad idea to version your build directory. Every time Eclipse does an auto-build it will cause all of the files to need to be committed again.
To answer your question, all Eclipse team providers automatically ignore any resource that is marked as "Derived" by Eclipse. The Derived flag is set on files that are created by the Eclipse builders. If you select one of these files that are ignored in Eclipse, right click and choose Properties. Navigate to the Eclipse Resource page. There will be a bunch of checkboxes. You should see that one of these is labelled Derived and will likely be checked.
Do not try to change the checkbox value. I am just pointing out where you can see and confirm this.

Eclipse showing lots of unrelated files in project explorer

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

Eclipse automatically refresh resources and exclude build dir

Eclipse Helios: 40+ project working set, using maven (mvn-eclipse plugin) to generate eclipse project files.
'Resource is out of sync with the file system: ...' Appears after doing, among other things, a text search.
After a bit of googling found Prefs > Workspace > Refresh Automatically which is widely reported to be malfunctional, and has the same symptom for me. The source files are source controlled, so therefore have lock attributes on them, was curious if this may come into play with this.
Second part is regarding my build directory; eclipse knows proj_root/target is the build directory, but I would like to exclude resource sync'ing in that folder.
I basically never want to see that dialog, and don't want to have to take action to remedy it (ie manually refreshing).
I had the same problem with m2eclipse.
Marking target folder as Derived resource worked for me (right-click -> Properties -> Resource -> Derived).

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);