eclipse - force save actions on untouched files - java

Is there any way to make force global save actions for a project?
My team uses a specified formatter and a save actions. Formatting all code is easy to be done, but later on when someone does edit in some file, VCS diff goes mad - save actions come into play and changing 1 line results in many lines edited.
"Format edited lines instead of Format all lines." is a know workaround, but I'd rather not use it.

My team uses a formatter and save actions too. I couldn't find a way to force global save actions in a whole project and VCS diff really gets everyone mad after some change because of the format change...
What we did was ask everyone to commit their changes to svn and use the formatter an save actions. Then, I changed the format of all files in the project and comitted it. Everyone downloaded again the project, with format changes already done, and continued working without madness :)

You want to format your whole source code at once right? Then right-click your project and select Source -> Format.
To run the save actions you have to select your packages right-click and select Source -> Clean Up...

#user714965 Using Clean Up as save actions seemed the best, till I found this this plugin that does exactly what I want - applies save actions.
http://marketplace.eclipse.org/sites/default/files/styles/ds_solution_screenshot/public/Screen%20Shot%202011-10-10%20at%2011.25.52%20PM.png
http://marketplace.eclipse.org/content/save-actions-extensions#.U-ynLfl_tCZ

Related

Is there a way to update comments when saving an Eclipse file?

This isn't exactly a programming question, but my goal is to add a comment at the top of the class that shows when you last edited the file, updating when it saves. I know Eclipse can access the date and time, since adding a "Date Created:" comment was easy, but that's just editing the new file code templates so I would imagine it's not in the same area. I've been learning Java and Eclipse for about a year now, and this would be super helpful to keep track of files.
Here's a picture in case I wasn't clear
No, not out of the box. Someone could write a plug-in to do it, but as the comments have mentioned, once you're past a trivial example, this is usually the job for a source control system.

Eclipse is not applying part of my patch but no errors

My team and I often exchange patches created in eclipse when working on the same parts of code. I just made a patch for my teammate that includes our changes he had just given me and a function I just added. When I save the patch in a txt file and open it, I see that function.
(I created the patch by right clicking on my project folder, Team -> Create Patch)
He is taking the patch and he has all the same changes in his code except for that one function. He right clicks on the project folder and Team->Apply Patch. He sees a lot of conflicts in the Apply Patch wizard because the wizard is seeing all the same code already in the patch in his workspace (minus that one function I added). He applies and gets no errors. HOWEVER, the one function doesn't go into his code.
Why is this? I thought maybe he had to revert all of his code first and then apply the patch, but it should work regardless, right?
So to be clear here was the process we just did:

Applying a new code template to existing java file

We have lot of java files which were developed using a code formatter ,code style (has copyright info) templates. Now we decided to update the formatter and style template. Is it possible to update all the java files based on the new code formatter and code style templates?
It is a tedious process to manually go and edit all copy right statements in the java files. So if we could do it quickly, it will be very helpful for us.
We are using eclipse v3.4 for our development.
Eclipse 3.4 is quite old, so I'm not 100% sure this feature is available...
Right-click on the project or package you want to format, and select Source > Format.
That will only apply the format settings selected in Preferences/Java/ Code Style/Formatter. It will not add or alter code or comments. You choose a template when you create a new class/file.
yes, manually this works with Ctrl-Shift-f, which autoformats the current code / class, with the formatting rules.
For full automatic reformatting via batch you need further answers. But beware sometimes the rukles can destroy the readability of some special classes.
I would prefer manually go throug all classes, and apply Ctrl-Shift-f.
During this you might see, than some formatting rules should be adapted.

How to properly roll back to an older version in CVS HEAD using Eclipse?

I have a CVS repository in which I have a set of Eclipse Java projects where I need to roll HEAD back to the state it was at a specific time yesterday essentially abandoning all commits happened since said time.
I've tried different things, including using "Replace with another branch or version" which gives the proper sources, but where it appears that CVS now thinks I'm actually working "back in time" instead of in HEAD but with other sources which result in changed files showing up in Team Synchronize etc. Also commits tells me I'm working on a sticky tag and fails.
So, what is the proper way to tell Eclipse 3.5.1 that I need to rollback HEAD to yesterday?
I usually use the following for individual files:
Replace With -> History
Which can be found under the right click menu
Pick the version you want (it also includes eclipse locally saved versions)
Then commit to make it the HEAD
I ended up manually merging the files up in HEAD and very, very carefully checking in the sources. This was no fun.
Unless you have a tag in CVS, you will have to examine each file for this, and choose the version to revert to. (it is due to the way CVS stores changes, they are not file system snapshots like other SCMs).
You did a checkin in CVS with many files and after that you want to undo that?
My solution:
Mark the files (if no good checkin after the bad checkin you can mark all) --> Right click "Compare with" --> With Branch or Version --> Dates --> Add Date --> Take Date where you know the HEAD is ok --> Now you are in the Synchronize view, mark all files --> Replace --> Check in the files again
This will not really undo your CVS checkin (history) but you get with not too many clicks the old state. And you dont have to do it file for file.

A good solution to include some template text into a source file using SVN?

I have a Java project in a SVN repository, with a bunch of .java files, each of those files has a licence agreement flower box at the top of the file (I have customers which have licenced the source as well as running the product).
Is there a good way to be able to modify / maintain the licence text in one place rather than having to update all the source files manually if it changes?
Looking at some similar (but not identical) questions it seems like SVN does not have this functionality out of the box - what other approaches would be most suitable?
Edit: Ideally the solution would act like the SVN keywords (Id, Author etc.) rather than being a build-time solution. The customer has access to the SVN repository too, so it would be ideal if the licence text was present in the SVN version of the file. I know SVN has commit triggers - what's a simple way to implement that?
Edit 2: Looking at the SVN hooks it doesn't look like what I'd like to do is possible. I guess build process that can be run when the text changes is ok - since it won't change too often.
Modify the source files that need to contain the text of the license to contain some token instead, and then move the license text to a single file that's kept in subversion. Finally, as part of your build process, add a step that substitutes the text of the license for the token. At my job, I do something along these lines using a combination of sed and make. You could then execute this single step before distributing the source to your customers.
ANT can do the substitution easily. Look into the <copy> target.

Categories

Resources