Config file validation and conversion not being called by default
I'm testing a dist of staticSearch 2.0 with a project that until now has used 1.4. My expectation was that just running the search build would be enough to cause the config file to be checked and an offer made to update it, but that doesn't happen. If I just run the search build in the normal way, not only is the config file not updated, but the staticSearch build proceeds to delete the contents of its own folder, which is obviously disastrous.
However, if I run only:
ant -DssConfig=../config_staticSearch.xml validate.config
then the config file is checked, and the offer made to update it. So I believe that somehow the build is failing to run the initial config file validation, and therefore is loading a config file it can't parse properly, failing to find the target search page and therefore document collection, and defaulting to its own folder, which it then proceeds to try to clean.
I have more investigation to do, but I think at the very least:
- The XSLT that processes the config file should itself run some basic checks on the file to make sure it's correct, just in case the validation process fails for some reason. It should raise an error if key info is not there (such as an accessible search page).
- The process that cleans out a target folder before building a search should check to make sure it's not going to clean out its own folder, which is never the right thing to do.
- Of course the initial failure to run the validation targets should be fixed.
The problem appears to be the init target. If we look at the logic here:
<echo message="Initializing staticSearch build using codebase in ${ssBaseDir.converted}..."/>
<echo message="Deleting old products..."/>
<delete dir="temp"/>
<delete file="${ssBaseDir.converted}/xsl/config.xsl"/>
<delete file="${tempSearchPageOutput}"/>
<delete dir="${staticSearchDir}"/>
<echo message="Creating new static search directory: ${staticSearchDir}"/>
<mkdir dir="${staticSearchDir}"/>
<echo>Running staticSearch build based on config file:
${ssConfigFile}</echo>
The cleaning out of the staticSearchDir (which is supposed to be the target directory in the website location) runs BEFORE the configuration file has been validated and checked; that directory is parsed out from the config file at the top of the ant build file. In other words, BEFORE the build has validated and (in the case of v1 config files) converted the file, it tries to use it to find information it needs to do the cleanup; failing to successfully parse this info, it presumably tries to delete files in the current folder instead, and the current folder is its own folder.
The solution I believe is to run the config file validation before we do anything else. Unfortunately, the way the config file is now used -- being parsed before it can be converted -- means that we can't then elegantly proceed with the build, so we would have to convert the file, report the new location to the user, and stop, so that they can restart their staticSearch build using the new v2 version of the file.
Working on this in branch issue-341-config.
PR is waiting.
PR was merged a long time ago, so I believe that this can be closed.