Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added optional event timing based on https://gist.github.com/3499584

…but configurable via BuildConfig.groovy with the 'grails.script.logTiming' setting
  • Loading branch information...
commit 22dbc5143f94f58d4bfd729edfdd0f1fe819b580 1 parent 990f27f
Burt Beckwith authored
View
18 grails-bootstrap/src/main/groovy/grails/util/BuildSettings.groovy
@@ -192,10 +192,14 @@ class BuildSettings extends AbstractBuildSettings {
/**
* A property name to enable/disable AST conversion of closures actions&tags to methods
*/
-
public static final String CONVERT_CLOSURES_KEY = "grails.compile.artefacts.closures.convert"
/**
+ * Property name to enable/disable script event time logging.
+ */
+ public static final String LOG_SCRIPT_TIMING_KEY = 'grails.script.logTiming'
+
+ /**
* The base directory for the build, which is normally the root
* directory of the current project. If a command is run outside
* of a project, then this will be the current working directory
@@ -396,6 +400,8 @@ class BuildSettings extends AbstractBuildSettings {
*/
boolean offline = false
+ boolean logScriptTiming = false
+
GrailsCoreDependencies coreDependencies
private List<File> compileDependencies = []
@@ -770,6 +776,7 @@ class BuildSettings extends AbstractBuildSettings {
private boolean buildListenersSet
private boolean verboseCompileSet
private boolean convertClosuresArtefactsSet
+ private boolean logScriptTimingSet
private String resolveChecksum
private Map resolveCache = new ConcurrentHashMap()
private boolean readFromCache = false
@@ -923,6 +930,11 @@ class BuildSettings extends AbstractBuildSettings {
convertClosuresArtefactsSet = true
}
+ void setLogScriptTiming(boolean b) {
+ logScriptTiming = b
+ logScriptTimingSet = true
+ }
+
boolean getProjectWarOsgiHeaders() { projectWarOsgiHeaders }
void setProjectWarOsgiHeaders(boolean flag) {
@@ -1437,6 +1449,10 @@ class BuildSettings extends AbstractBuildSettings {
System.setProperty(CONVERT_CLOSURES_KEY, "$convertClosuresArtefacts")
}
+ if (!logScriptTimingSet) {
+ logScriptTiming = getPropertyValue(LOG_SCRIPT_TIMING_KEY, props, 'false').toBoolean()
+ }
+
if (!projectWarOsgiHeadersSet) {
projectWarOsgiHeaders = getPropertyValue(PROJECT_WAR_OSGI_HEADERS, props, 'false').toBoolean()
}
View
8 scripts/_GrailsEvents.groovy
@@ -16,6 +16,7 @@
import org.codehaus.groovy.grails.cli.support.GrailsBuildEventListener
import org.codehaus.groovy.grails.cli.logging.*
+
/**
* Gant script containing the Grails build event system.
*
@@ -47,9 +48,16 @@ classpath()
// Now load them.
eventListener.initialize()
+long eventInitStart = System.currentTimeMillis()
+
// Send a scripting event notification to any and all event hooks in plugins/user scripts
event = {String name, args ->
try {
+ boolean logTiming = binding.variables.containsKey('buildSettings') ? buildSettings.logScriptTiming : false
+ if (logTiming) {
+ grailsConsole.addStatus "#### (${System.currentTimeMillis() - eventInitStart}) $name $args"
+ grailsConsole.lastMessage = ''
+ }
eventListener.triggerEvent(name, * args)
}
catch(e) {
Please sign in to comment.
Something went wrong with that request. Please try again.