On Aug 24, 2009, at 11:38 AM, Trond Andersen wrote:
<snip>
4.) A project can define a default profile.
Should Gradle maybe use the same way as ConfigSlurper handles it?
Outside of the environment {...} is the default?
-1- url = 'x'
-2- config/environment {
-3- jdbcUrl = 'y'
-4- dev { ... }
-5- }
I think the build/init.gradle context is already a default context
(line 1). line 3 is an equivalent location for doing this. People
might decide to go for the line 3 approach, as it visually separates
things. But functionality wise it shouldn't matter.
5.) As it is possible to specify a custom location for init files,
this should also be possible for gradle.properties files. Should it
be possible to specify more than one init/property file? Should we
use the same command line options to specify init/property files?
I prefer convention here. If there's a need for customization, I
think this should reference a task/closure/method which does the
customization. For instance - I didn't end up using property files.
I just modified the web.xml and modified the conflig-param section
of the web.xml instead. In this example the need isn't about
specifying the property or init file, but more a possibility to do
custom environment handling. See below.
I understand. My idea is that proposal is about supporting environment/
profile handling as well as improving other aspects of configuration
support. For example on a CI server you would like to inject a init
file from some custom location.
6.) Make it easy to apply any init/property files from a build.gradle.
Agreed.
I'm going to blog about this, but here's what I did regarding
environment specific version of web.xml:
<pre>
....
def config
if (System.properties['env.ocs'] != null) {
logger.info("A spesific environment has been specified $
{System.properties['env.ocs']}")
config = new ConfigSlurper(System.properties['env.ocs'])
.parse(new File(project.projectDir.path + File.separator
+ 'env.groovy').toURL())
} else {
logger.info("No specific environment has be specified")
config = new ConfigSlurper().parse(new
File(project.projectDir.path + File.separator + 'env.groovy').toURL())
}
def configMap = config.flatten()
def webApp = new XmlParser().parse(new File(webXmlPath))
def contextParams = webApp.'context-param';
logger.info("Found ${contextParams.size()} context parameters")
contextParams.each { contextParam ->
logger.info("Found param name: ${contextParam.'param-
name'.text()} and Param value: ${contextParam.'param-value'.text()}")
def paramName = contextParam.'param-name'.text()
if (configMap.containsKey(paramName)) {
logger.info("Modifying ${contextParam.'param-name'.text()} to $
{configMap.get(paramName)}")
contextParam.'param-value'[0].value = [configMap.get(paramName)]
}
}
...
</pre>
By supplying the -Denv.ocs=prod the ConfigSlurper will parse the
environment specific settings.Then I parse the web.xml and modify
it. With Gradle support this would probably be much more elegant. An
important point for me is that the configuration can be other things
that property files.
Definitely. As written above, config scripts and property files are
complimentary.
How should we call the thing?
Environment, Profiles, Configuration (to confuse people ;)) ?
- Hans
--
Hans Dockter
Gradle Project Manager
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email