Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.0.3
-
Component/s: Configuration
-
Labels:None
-
Patch Submitted:Yes
Description
It can be useful to be able to define the context path that jetty will use for the application - for example, if you are running apache in front of jetty for development.
The context path could be specified in the following locations:
1. System property
2. application.properties
3. Config.groovy
If not specified in one of these, then it should default to what it does now, 'grailsAppName'.
Some sample code:
In RunApp.groovy:
Change the runApp target to derive the context path:
// Get the application context path by looking for a property named 'app.context' in the following order of precedence:
// System properties
// application.properties
// config
// default to grailsAppName if not specified
props = Ant.antProject.properties
appContext = System.getProperty("app.context")
appContext = appContext ? appContext : props.'app.context'
appContext = appContext ? appContext : config.app.context
appContext = appContext ? appContext : grailsAppName
if(!appContext.startsWith('/')) {
appContext = "/${appContext}"
}
and modify the StatusFinal event to reflect the appContext:
event('StatusFinal', ["Server running. Browse to http://localhost:$serverPort$appContext"])
In the setupWebContext target, use the appContext variable in the webContext definition:
webContext = new WebAppContext("${basedir}/web-app", "${appContext}")
Now, you can affect the context path in 1 of 3 ways:
1. grails -Dapp.context=mycontext run-app
2. in application.properties, define property:
app.context=mycontext
3. in Config.groovy define the app.context property:
environments {
development {
app.context='mycontext'
}
}
I've attached a modified version of the grails-1.0 RunApp.groovy file for comparison.
For more information, see
http://www.javathinking.com/?p=49
http://www.nabble.com/Defining-the-context-path-in-application.properties-td12976557.html
Thanks.
Attachments
Issue Links
| This issue duplicates: | ||||
| GRAILS-2435 | Make it possible to run dev server (jetty) without application context (or with custom one) |
|
|
|
I have produced a better implementation: