Working set from .gitignore in Eclipse - eclipse

How do I have a Project Explorer's Working Set be built automatically from the contents of .gitignore, and then kept in sync with .gitignore?
I am working on a C++ AutoTools project which, as it is common for AutoTools projects, generates quite a lot of files during the build stage. I do have them .gitignored already. Now I'm trying Eclipse on that project, and found that I'd have to carefully pick files to ignore again.

You cannot. This feature does not exist.
The working sets functionality was implemented a long time before GIT appeared, and it was a method for removing clutter in large projects, and what is important, it was was a method that resided in the UI domain.
In fact, A working set extension point documentation shows it is possible to create a self-updating working set, and the search over the egit codebase returns no results.
As I have said, this feature is not implemented.
However, you can create your own plugin that will do what you want. It is not very complicated, and should not take more than a day or two. Or just open a feature request in the Eclipse bugzilla.
As for your underlying problem, you could try using the derived resources mechanism. It was added to make possible to prevent team providers (CVS/GIT) from managing files that are a result of a build.
Just a word of warning - GIT won't allow you to ignore further changes to any resource already under its control.

Related

Managing Sandbox & Production Changes

I am looking quickly move changes between Salesforce Production & Sandbox. Is there any way we can know the difference between two environments i.e How many workflows, objects, email templates are modified/added in compared view.
I know we can use outbound change set but its tedious job of moving the changes and not feasible when Production is continuously being updated.
After speaking with the experts at two Dreamforce conferences I find the only way to get a description of an instance is to use the force.com IDE, as suggested by LaceySnr. I've learned a couple techniques that help.
First, I no longer even attempt to use change sets. These are time consuming to build, have no clarity as to what is really inside and sometimes just won't work.
Second, I keep at least two force.com IDE projects for each instance (test,production). The first project has everything (check everything in the metadata component). The second project is tiny and only has the components I want to work on.
The first project is checked into some change control system; CVS, SVN, Git, Mercurial, etc. Your choice. Using the differencing tools on this project let's you compare change sets.
But it is nearly impossible to develop using the first project because it takes too long for force.com to process even the smallest change. This is because it processes the entire project whenever any change is made. So, make all the code changes in the smaller project.
Then look at the ANT build tools http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_deploying_ant.htm to automate the migration of changes from the smaller to larger project.
I've not done this with workflows, but it is a method I use for code, layouts and objects: Use the force.com IDE from http://developer.force.com to setup projects for both Sandbox and Production, being sure to select all of the metadata components that you want (you'll want to include workflows for instance).
This will leave you with the contents of your projects stored inside a project directory in the IDE's workspace directory, then you can easily use a diff tool (I use the free DiffMerge on Mac) to compare the directories, and of course drill down into files to see what changes exist.

iPhone - Reuse, Share code between projects

I've found a really good tutorial on "Easy, Modular Code Sharing Across iPhone Apps: Static Libraries and Cross-Project References"
Now I need to understand if my approach can work.
Suppose I have my "main" project with all the assets I need (View Controllers, Delegates, etc.).
Now I create a new project and simply add a reference to every file I need from the first project; of course I DON'T select the "copy if needed" option.
In this way do I build a new project with all the assets from my main project?
If I change the code in the main project, this change will be reflected to all the referencig projects?
Is this an easier way to share code between projects?
Thanks.
Since I keep all my code under version control, the way I do it is to have modular code as Git repositories. That way, to add common code, or chunks of functionality to my project I just need to add these as submodules.
The advantages of this are:
Common code is kept in one place, versioned and backed up.
Having small repositories for code that does just one thing encourages writing modular code with minimal dependencies.
Submodules are added to a repository at a particular revision. So, if you change your common codebase, these changes are not automatically applied to the clones - you have to explicitly pull in changes. That way, if you accidentally change something that could break one of your projects, it won't appear suddenly.
If you set up your submodules properly, you can make changes to the common code from within one of your projects that can be pushed to all other repositories. That way you can work locally.
Your entire project is in a repository, without references to other projects, so you can move them, save them, archive and restore them without worrying about where the references point to.

Project files under version control?

I work on a large project where all the source files are stored in a version control except the project files. This was the lead developer's decision. His reasoning was:
Its to time consuming to reconcile the differences among developers' working directories.
It allows developers to work independently until their changes are stable
Instead, a developer initially gets a copy of a fellow developer's project files. Then when new files are added each developer notifies all the rest about the change. This strikes me as far more time consuming in the long run.
In my opinion the supposed benefits of not tracking changes to the project files are outweighed by the danger. In addition to references to its needed source files each project file has configuration settings that would be very time consuming and error prone to reproduce if it became corrupted or there was a hardware failure. Some of them have source code embedded in them that would be nearly impossible to recover.
I tried to convince the lead that both of his reasons can be accomplished by:
Agreeing on a standard folder structure
Using relative paths in the project files
Using the version control system more effectively
But so far he's unwilling to heed my suggestions. I checked the svn log and discovered that each major version's history begins with an Add. I have a feeling he doesn't know how to use the branching feature at all.
Am I worrying about nothing or are my concerns valid?
Your concerns are valid. There's no good reason to exclude project files from the repository. They should absolutely be under version control. You'll need to standardize on a directory structure for automated builds as well, so your lead is just postponing the inevitable.
Here are some reasons to check project (*.*proj) files into version control:
Avoid unnecessary build breaks. Relying on individual developers to notify the rest of the team every time the add, remove or rename a source file is not a sustainable practice. There will be mistakes and you will end up with broken builds and your team will waste valuable time trying to determine why the build broke.
Maintain an authoritative source configuration. If there are no project files in the repository, you don't have enough information there to reliably build the solution. Is your team planning to deliver a build from one of your developer's machines? If so, which one? The whole point of having a source control repository is to maintain an authoritative source configuration from which you build and deliver releases.
Simplify management of your projects. Having each team member independently updating their individual copies of your various project files gets more complicated when you introduce project types that not everyone is familiar with. What happens if you need to introduce a WiX project to generate an MSI package or a Database project?
I'd also argue that the two points made in defense of this strategy of not checking in project files are easily refuted. Let's take a look at each:
Its to time consuming to reconcile the differences among developers' working directories.
Source configurations should always be setup with relative paths. If you have hard coded paths in your source configuration (project files, resource files, etc.) then you're doing it wrong. Choosing to ignore the problem is not going to make it go away.
It allows developers to work independently until their changes are stable
No, using version control lets developers work in isolation until their changes are stable. If you each continue to maintain your own separate copies of the project files, as soon as someone checks in a change that references a class in a new source file, you've broken everyone on the team until they stop what they're doing and carefully update their project files. Compare that experience with just "getting latest" from source control.
Generally, a project checked out of SVN should be working, or there should be tools included to make it work (e.g. autogen.sh). If the project file is missing or you need knowledge about which files should be in the project, there is something missing.
Automatically generated files should not be in SVN, as it is pointless to track the changes to these.
Project files with relative path belong under source control.
Files that don't: For example in .Net, I would not put the .suo (user options) web.config (or app.config under source control. You may have developers using different connection strings, etc.
In the case of web.config, I like to put a web.config.example in. That way you copy the file to web.config upon initial checkout and tweak what settings you'd like. If you add something that needs to be added to all web.config, you merge those lines into the .example version and notify the team to merge that into their local version.
I think it depends on the IDE and configuration of the project. Some IDEs have hard-coded absolute paths and that's a real problem with multiple developers working on the same code with different local copies and configurations. Avoid absolute path references to libraries, for example, if you can.
In Eclipse (and Java), it's fine to commit .project and .classpath files (so long as the classpath doesn't have absolute references). However, you may find that using tools like Maven can help having some independence from the IDE and individual settings (in which case you wouldn't need to commit .project, .settings and .classpath in Eclipse since m2eclipse would re-create them for you automatically). This might not apply as well to other languages/environments.
In addition, if I need to reference something really specific to my machine (either configuration or file location), it tend to have my own local branch in Git which I rebase when necessary, committing only the common parts to the remote repository. Git diff/rebase works well: it tends to be able to work out the diffs even if the local changes affect files that have been modified remotely, except when those changes conflict, in which case you get the opportunity to merge the changes manually.
That's just retarded. With a set up like that, I can have a perfectly working project containing files that are subtly different from everyone else. Imagine the havoc this would cause if someone accidentally propagates this mess into QA and everyone is trying to figure out what's going on. Imagine the catastrophe that would ensue if it ever got released to the production environment...!

Managing multiple branches in Eclipse, or getting a VS-like setup for Eclipse

In VS, it's simple. Everything the project needs is stored in the project folder and all VS settings are stored in one place. Eclipse, however, stores Eclipse settings with the project and keeps a .metadata at the workspace level which is needed to detect the projects in the workspace. Thus, I can't simply branch a project and then open it in Eclipse. I need to set up a workspace, branch it into that workspace, copy over all my workspace settings (settings import/export doesn't even work right in Eclipse) so I have the same Eclipse settings, then do some kind of import to get the project in the workspace. This is what I generally refer to as a pain in the freaking neck, and it causes me to not branch any Java projects and to keep them all in one folder. This is also a pain.
Is there any way I can get a setup where I can just branch a project and open it in Eclipse, while maintaining the same Eclipse settings?
UPDATE: The current state of the question is expressed by the comment to soru's post.
Pretty sure you want to:
Keep the same workspace for all projects (or maybe a few, at the level of say 'hobby' and 'work').
switch between different branches in the same project by using the features of your version control tool/plugin
if you want to work on multiple branches at the same time, just create two projects, and manage them both as above.
if you want to temporarily hide the inactive version, use the 'working set' feature.
The main limitation is that you might want to have projects with the same name, but you can't. So sometimes you have to make up a project name different from the underlying folder name.
In general, mapping between VS and Eclipse:
Installation <-> workspace
Solution <-> working set
Project <-> project or folder or VC system branch or working set node
Refs:
VS object model
using working sets in Eclipse
working with branches in subclipe
Well, I'm not a fan of keeping any IDE specific settings in the repo, but when I do I keep only .project, .classpath and .settings.
You can also keep you settings at the workspace level (Windows->Preferences),and not on the project level (Project->Properties).
Also why do you create a seperate workspace for branches? You can keep it in one workspace, no need to create another one.
You could also use "switch" in subversion (I don't know if that's what you are using, but other revision systems should have something similar) and go to the branch you have created.
(of course if you wan to work concurrently on more than one branch then it doesn't help)
I can't speak to the Eclispe problem, as i'm only a n00b user, but I can speak to the secondary question.
I've been working in systems for a number of years that ended up needing to have various branches of the same code done for a variety of reasons.
One of the best reasons for keeping specific settings in project-specific locations is that so the various compiler / sdk / etc. settings & files can be specific per-branch and not collide between branches.
This allows, for example, for the work to upgrade a code set to a newer sdk/compiler to be done without impacting the ability to work on the existing "main line" code set with the previous sdk/compiler should the need arise.
In my experience in the computer game industry as a core technology wog, this happens a LOT.
I'm sure the same situations occur outside the computer game industry, maybe just not at the same pace.

Eclipse + Perforce: Is it possible to avoid interrupting a build to check out a file?

This may be somewhat obscure but I've been happily using Eclipse + Perfoce/P4WSAD for over a year now and have thus far been unable to figure this out myself. I often start a build and let it run in the background while I continue to edit source files. The problem occurs when I try to edit a file that is not checked out from perforce. In this case, eclipse pops up a modal dialog box that forces me to choose between either canceling the build or canceling the check-out operation. So usually I just cancel the build, check out the file, and start the build up again, but this is very time consuming. Is it possible to get eclipse to allow check-outs during builds?
I don't know, but you may want to check with Perforce on this (as this might be something specific to their plugin rather than something in the team su8pport), I never have this problem with SVN or CVS (though maybe my builds are not big enough). Also from what I understand the first generation Perforce plugin had major problems, but they have a new one that's much better. You should make sure you are on the new one.
A simple solution (although it can be disk-space consuming) is to have a building branch on which you merge any of your recently committed development (simple merges with no conflicts: you overwrite what is on the build branch).
Another eclipse project references that build branch sources and builds it whenever you want, while you edit the sources of your first original project.