Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.1
-
Fix Version/s: 2.1-RC1
-
Component/s: Build System, Configuration
-
Labels:None
-
Testcase included:yes
Description
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:
... GrailsRootLoader rootLoader = new GrailsRootLoader(prepareClasspath(classpath), ClassLoader.systemClassLoader); GrailsBuildHelper helper = new GrailsBuildHelper(rootLoader, null, baseDir.absolutePath) int returnCode = helper.execute(command, '', env) ...
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:
...
log4j = {
...
environments {
development {
println ">>>>>>> LOG4J DSL: development"
}
test {
println ">>>>>>> LOG4J DSL: test"
}
}
}
environments {
development {
println ">>>>>>> Config: development"
}
test {
println ">>>>>>> Config: test"
}
}
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:
groovy build.groovy $GRAILS_HOME $GRAILS_APP_LOCATION $CAMEL_CASED_GRAILS_COMMAND $OPTIONAL_ENVIRONMENT
For example,
groovy build.groovy C:\grails-2.0.1 env-test TestApp groovy build.groovy C:\grails-1.3.7 env-test TestApp development
Running TestApp in its default environment in 2.0.1 results in:
>>>>>>> Config: development >>>>>>> LOG4J DSL: development >>>>>>> Config: development >>>>>>> LOG4J DSL: development
Running TestApp and specifying the test environment in 2.0.1 results in:
>>>>>>> Config: test >>>>>>> LOG4J DSL: development >>>>>>> Config: test >>>>>>> LOG4J DSL: development
Both cases in 1.3.7 report:
>>>>>>> Config: test >>>>>>> LOG4J DSL: test >>>>>>> Config: test >>>>>>> LOG4J DSL: test
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).
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits