Search code examples
grailsantgroovygroovy-console

Ant call to grails fails with "[exec] Application is pre-Grails 0.5, please run: grails upgrade"


I am facing a rather odd problem with our groovy build script. The whole project uses a helper groovy script that calls all other build scripts (maven and ant). One of the ant targets invoked by the groovy script calls, invokes through "exec" grails war:

    <exec executable="cmd" dir="${parentDir}/${grails.appname}">
        <arg value="/c"/>
        <arg path="${env.GRAILS_HOME}/bin/grails.bat"/>
        <arg value="war"/>
        <arg value="${grails.appname}-${app.version}.war"/>
    </exec>

The call of this block fails with:

     [exec] Application is pre-Grails 0.5, please run: grails upgrade

Any suggestions how to go around this problem?

Thanks for your time.


Solution

  • I finally found the solution to the problem, I don't know if this is the best way but it fixed my problem. So in the same target as the "exec" block I added a new "exec" block to invoke the upgrade on the grails.bat. So far so good, calling this command without parameters will generate a confirmation question whether to proceed with the requested operation - in ant this will create an infinite loop. In order to avoid this I added the "-f" parameter. The whole exec block:

        <exec executable="cmd" dir="${parentDir}/${grails.appname}">
            <arg value="/c"/>
            <arg path="${env.GRAILS_HOME}/bin/grails.bat"/>
            <arg value="upgrade"/>
            <arg value="-force"/>
        </exec>
    

    Hope this will help somebody.