How to run version migration code?

Hi,

we at haskforce have a major change in our architecture. In the past we had a global config and are now moving towards independent configurations per module, implemented as an persistable Service. 
The question is how to perform the migration? Its really hard to perform these inside the module, since i have to intialialise other modules or even create ones. Recursion might happen or i have to do some way to complicated stuff.

Is there a way to create a Project-Pre initialise hook?

4 comments
Comment actions Permalink

Hi,

you can keep the old class which loads the global config and take values from it in the new services by default. (We have a special extension point com.intellij.conversion.ConverterProvider to support migration of config files on xml level before the project is loaded, but it doesn't work with the global config.)

0
Comment actions Permalink

the problem is that we are changing the architecture. I might have used global wrong, i mean project-level with it (not application level). 
in the past we had a project level setting for compiler etc. Now we built a new backend wich persists these settings on the module level. This makes it possible to implement real framework support for our build tools. So most of our settings are now gone.

I know i can just access these values from the services, but to have a sane solution, where in the future we can just delete the code and move on, we have to migrate. When i am doing it per module-service, i don't know if every module has migrated. I may be possible that modules need to be created.

We have UI which queries the modules and decides whether it should be visible or not, so the code has to be executed before the ui is initialised.

If its not really possible without some complicated hacks, i can just ask the users to reimport their projects.

0
Comment actions Permalink

It sounds like what you need is a ConverterProvider - I've used it several times for run configuration migration and also for project config migration. It can be tricky, and I've found it to be a little unreliable but I'm not sure if that was bugs in the migration itself or my migration code. It generally does a nice job though, and as far as I'm aware is the only way to do a sane migration of config when moving things around.

0
Comment actions Permalink

i just wanted to write the conversion code via ConverterProvider, but i stumbled across a showstopper. I don't have a project yet. I don't see how i can add modules. Also i can't use my existing code!

Hmm maybe i have to rethink my process. When perform it inside my services i fear deadlocks etc (I need write access to create modules). Maybe after the project loaded? When do the Toolbars start initialising, is there a Topic i can listen to, or maybe ProjectManagerListener.projectOpened (there is unfortunately no information when the method is invoked)? 

Ideally i would run the code at the end of the loading-screen, maybe even displaying some message in the loading bar

0

Please sign in to leave a comment.