Until now that is :). Acceleo can now be used in conjunction with ClearCase or other pessimist-locking Version Control Systems (VCS). How does it work?
You might have noticed the "getGenerationStrategy()" method of the Java class we generate for your main mtl files; this is the method that matters for us. You simply need to change it from its default "return super.getGenerationStrategy()" to "return new WorkspaceAwareStrategy()" and you're done! Acceleo will now prompt the users of your generators to check out the files before attempting to modify them.
Two things to note :
- You must change the javadoc of "getGenerationStrategy()" so that it doesn't contain "@generated" anymore : delete this tag, change it to "@not-generated", change it to "@generated NOT"... just don't leave this tag as-is or the Acceleo builder will override your change.
- You cannot use this strategy in standalone mode, its goal is to integrate with the Eclipse workspace and its team providers.
For example, with SVN you can set the property "svn:needs-lock" on a file to prevent any edition without prior locking. If you attempt to regenerate a file with such a property set with Acceleo, here is what you will get :
"java.io.FileNotFoundException: [...]\Library.java (Access denied)"
Pretty mean, huh? If you make use of the WorskpaceAwareStrategy though, you will get this instead :
All you have to do is to tick off the files for which you wish to take the lock. Files you do not check will not be locked for edition.
No comments:
Post a Comment