static StandardContext configure(Tomcat tomcat, Props props) {
try {
- String webDir = props.of("sonar.web.dev.sources");
- boolean dev = true;
- if (StringUtils.isEmpty(webDir)) {
- webDir = new File(props.of("sonar.path.home"), "web").getAbsolutePath();
- dev = false;
- }
- LoggerFactory.getLogger(Webapp.class).info("Webapp directory: " + webDir);
- StandardContext context = (StandardContext) tomcat.addWebapp(getContextPath(props), webDir);
+ StandardContext context = (StandardContext) tomcat.addWebapp(getContextPath(props), webappPath(props));
context.setClearReferencesHttpClientKeepAliveThread(false);
context.setClearReferencesStatic(false);
context.setClearReferencesStopThreads(false);
context.setUseNaming(false);
context.setDelegate(true);
context.setJarScanner(new NullJarScanner());
+ configureRails(props, context);
+
for (Map.Entry<Object, Object> entry : props.encryptedProperties().entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith("sonar.")) {
context.addParameter(key, entry.getValue().toString());
}
}
- configureRails(props, context, dev);
return context;
return context;
}
- static void configureRails(Props props, Context context, boolean development) {
- if (development) {
+ static void configureRails(Props props, Context context) {
+ // sonar.dev is kept for backward-compatibility
+ if (props.booleanOf("sonar.dev", false)) {
+ props.set("sonar.web.dev", "true");
+ }
+ if (props.booleanOf("sonar.web.dev", false)) {
context.addParameter(RAILS_ENV, "development");
context.addParameter(JRUBY_MAX_RUNTIMES, "3");
LoggerFactory.getLogger(Webapp.class).warn("WEB DEVELOPMENT MODE IS ENABLED - DO NOT USE FOR PRODUCTION USAGE");
context.addParameter(JRUBY_MAX_RUNTIMES, "1");
}
}
+
+ static String webappPath(Props props) {
+ String webDir = props.of("sonar.web.dev.sources");
+ if (StringUtils.isEmpty(webDir)) {
+ webDir = new File(props.of("sonar.path.home"), "web").getAbsolutePath();
+ }
+ LoggerFactory.getLogger(Webapp.class).info(String.format("Webapp directory: %s", webDir));
+ return webDir;
+ }
}
void define(WebService.NewController controller) {
controller.createAction("restart")
- .setDescription("Restart server. Available only on development mode (sonar.dev=true), except when using Java 6 " +
+ .setDescription("Restart server. Available only on development mode (sonar.web.dev=true), except when using Java 6 " +
"on MS Windows. Ruby on Rails extensions are not reloaded")
.setSince("4.3")
.setPost(true)
}
private boolean canRestart() {
- boolean ok = settings.getBoolean("sonar.dev");
+ boolean ok = settings.getBoolean("sonar.web.dev");
if (ok) {
ok = !system.isOsWindows() || system.isJavaAtLeast17();
}
# Defaults are respectively <installation home>/data and <installation home>/temp
#sonar.path.data=data
#sonar.path.temp=temp
+
+
+
+#--------------------------------------------------------------------------------------------------
+# DEVELOPMENT - only for developers
+
+# Dev mode allows to reload web sources on changes and to restart server when new versions
+# of plugins are deployed.
+#sonar.web.dev=false
+
+# Path to webapp sources for hot-reloading of Ruby on Rails, JS and CSS (only core,
+# plugins not supported).
+#sonar.web.dev.sources=/path/to/server/sonar-web/src/main/webapp