Validate Context in xml files?

Is it possible to extend liquibase to validate contexts of xml file.
I would like to be able to create a command line parameter which provides a list of valid context and then liquibase would perform the validation while creating ChangelogSets to see if Context is in the given list.

I am going through the code. Was hoping if someone can point me in the right direction on how to extend liquibase to create a new command line parameter and perform validation on context value after XML have been parsed.

The command line handling is done in liquibase-core/src/main/java/liquibase/integration/commandline/Main.java

There is a method parseOptions that looks for args starting with two dashes. It then takes the arg and splits it into two parts on an equals sign. It then uses reflection to see if the word after the two dashes, but before the equal sign matches a declared field in the Main class, and if so sets the value of that field to the value of the string after the equals. 

So to add the parameter, the thing you would need to do is just add a new field validateContexts to that class. 

The command line will also look for liquibase.properties and if a property setting is found that matches the field name, that can set the field also. 

Core processing of things then starts with the main.doMigration() method. That is where different commands are handled. I’m not sure on which commands you would want to do the context validation. 

I hope that gets you started in the correct direction. I don’t think it is really possible to extend liquibase with new command line options, so I think you’ll have to modify liquibase itself. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

It’s software, so anything is possible, and it’s open source, so have at it!

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/