Add profiling option, update CLI displayed version.
This commit is contained in:
parent
8d461e2cc4
commit
43008cf0d7
@ -68,6 +68,12 @@ abstract class AbstractBuildCommand extends AbstractSubCommand {
|
|||||||
)
|
)
|
||||||
boolean dryRun
|
boolean dryRun
|
||||||
|
|
||||||
|
@CommandLine.Option(
|
||||||
|
names = ['--profile'],
|
||||||
|
description = 'Log elapsed times for build steps.'
|
||||||
|
)
|
||||||
|
boolean profile
|
||||||
|
|
||||||
protected StaticSiteGenerator staticSiteGenerator = null
|
protected StaticSiteGenerator staticSiteGenerator = null
|
||||||
|
|
||||||
protected final Integer doSingleBuild(String buildName) {
|
protected final Integer doSingleBuild(String buildName) {
|
||||||
@ -77,6 +83,7 @@ abstract class AbstractBuildCommand extends AbstractSubCommand {
|
|||||||
def groovyClassLoader = new GroovyClassLoader(this.class.classLoader)
|
def groovyClassLoader = new GroovyClassLoader(this.class.classLoader)
|
||||||
|
|
||||||
if (this.gradle) {
|
if (this.gradle) {
|
||||||
|
def gradleStartTime = System.currentTimeMillis()
|
||||||
def projectConnection = GradleConnector.newConnector()
|
def projectConnection = GradleConnector.newConnector()
|
||||||
.forProjectDirectory(
|
.forProjectDirectory(
|
||||||
this.commonCliOptions.projectDir.toPath().resolve(this.gradleProjectDir).toFile()
|
this.commonCliOptions.projectDir.toPath().resolve(this.gradleProjectDir).toFile()
|
||||||
@ -97,6 +104,11 @@ abstract class AbstractBuildCommand extends AbstractSubCommand {
|
|||||||
|
|
||||||
projectConnection.newBuild().forTasks('ssgJars').run()
|
projectConnection.newBuild().forTasks('ssgJars').run()
|
||||||
projectConnection.close()
|
projectConnection.close()
|
||||||
|
|
||||||
|
if (this.profile) {
|
||||||
|
def gradleElapsedTime = System.currentTimeMillis() - gradleStartTime
|
||||||
|
logger.info("Gradle connection elapsed time: ${gradleElapsedTime / 1000} seconds")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.libDirs.each { libDir ->
|
this.libDirs.each { libDir ->
|
||||||
@ -123,6 +135,8 @@ abstract class AbstractBuildCommand extends AbstractSubCommand {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def buildStartTime = System.currentTimeMillis()
|
||||||
|
|
||||||
final Collection<Diagnostic> diagnostics = this.staticSiteGenerator.doBuild(
|
final Collection<Diagnostic> diagnostics = this.staticSiteGenerator.doBuild(
|
||||||
this.commonCliOptions.projectDir,
|
this.commonCliOptions.projectDir,
|
||||||
buildName,
|
buildName,
|
||||||
@ -130,6 +144,11 @@ abstract class AbstractBuildCommand extends AbstractSubCommand {
|
|||||||
this.scriptArgs ?: [:]
|
this.scriptArgs ?: [:]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def buildElapsedTime = System.currentTimeMillis() - buildStartTime
|
||||||
|
if (this.profile) {
|
||||||
|
logger.info("Build $buildName elapsed time: ${buildElapsedTime / 1000} seconds")
|
||||||
|
}
|
||||||
|
|
||||||
if (!diagnostics.isEmpty()) {
|
if (!diagnostics.isEmpty()) {
|
||||||
diagnostics.each {
|
diagnostics.each {
|
||||||
logger.error(it.message)
|
logger.error(it.message)
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import picocli.CommandLine
|
|||||||
@CommandLine.Command(
|
@CommandLine.Command(
|
||||||
name = 'ssg',
|
name = 'ssg',
|
||||||
mixinStandardHelpOptions = true,
|
mixinStandardHelpOptions = true,
|
||||||
version = '0.4.0',
|
version = '0.6.0-SNAPSHOT',
|
||||||
description = 'A static site generator which can interface with Gradle for high extensibility.',
|
description = 'A static site generator which can interface with Gradle for high extensibility.',
|
||||||
subcommands = [SsgInit, SsgBuild, SsgWatch]
|
subcommands = [SsgInit, SsgBuild, SsgWatch]
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user