I've been using gradle to test and package my 1.3.7 Grails application. While the grails-gradle-plugin didn't quite meet my requirements, it did point to the Grails code needed to programmatically build a Grails application:
This approach worked successfully in 1.3.7.
Starting with Grails 2.0, the environment is partially lost when running in this way. Specifically:
- the default environment (test for test-app) is not picked up by the environments closure in Config.groovy
- a specified environment is not picked up by the log4j closure
- a specified environment is not picked up by dependency resolution (the test scope is not used, despite the test environment being specified)
The attached example contains a simple grails application that specifies an environments closure in both the top-level config and the log4j closure:
It also contains a simple groovy build script (to keep gradle out of the picture) that programmatically executes the grails build system.
The build script expects the following command line arguments:
Running TestApp in its default environment in 2.0.1 results in:
Running TestApp and specifying the test environment in 2.0.1 results in:
Both cases in 1.3.7 report:
Note: I am aware of the dependency related error that occurs when using the supplied build.groovy in 2.0.1; like I said, this is just an approximation of how I build to keep the sample simpler and is good enough to illustrate the problem.
Note: I did not illustrate the third problem (the test dependency scope).