From 4ec3981489dc9ad31c4f8946731e346d48380ac9 Mon Sep 17 00:00:00 2001 From: Basil Peace Date: Fri, 31 Mar 2017 20:50:31 +0300 Subject: [PATCH] fix: Change of Gradle log level should not affect UP-TO-DATE check When the task was run again after successful run with different log level, the task was marked as not up-to-date, with the message ``` Value of input property 'args' has changed ``` --- .../gradle/packer/GradlePackerPlugin.groovy | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/org/fidata/gradle/packer/GradlePackerPlugin.groovy b/src/main/groovy/org/fidata/gradle/packer/GradlePackerPlugin.groovy index 6c1dc30..46acdde 100644 --- a/src/main/groovy/org/fidata/gradle/packer/GradlePackerPlugin.groovy +++ b/src/main/groovy/org/fidata/gradle/packer/GradlePackerPlugin.groovy @@ -93,7 +93,7 @@ class GradlePackerPlugin implements Plugin { String builderType = builder['type'] String buildName = builder['name'] ?: builderType String fullBuildName = "$imageName-$buildName" - Task t = project.task([type: Exec], "build-$fullBuildName") { + Task t = project.task("build-$fullBuildName") { group 'Build' ext.builderType = builderType ext.buildName = buildName @@ -107,10 +107,28 @@ class GradlePackerPlugin implements Plugin { ext.contextTemplateData['build_name'] = buildName ext.contextTemplateData['build_type'] = builderType ext.contextTemplateData['uuid'] = uuid + ext.upToDateWhen = [] + ext.inputProperties = [:] shouldRunAfter validate mustRunAfter cleanTask - commandLine((['packer', 'build', "-only=$buildName"] + customVariablesCmdLine + (project.gradle.startParameter.logLevel <= LogLevel.DEBUG ? ['-debug'] : []) + [fileName])) + doLast { + project.exec { + commandLine( + [ + 'packer', + 'build', + "-only=$buildName" + ] + + customVariablesCmdLine + + (project.gradle.startParameter.logLevel <= LogLevel.DEBUG ? ['-debug'] : []) + + [ + fileName + ] + ) + } + } inputs.file templateFile + inputs.property 'customVariablesCmdLine', customVariablesCmdLine } // VirtualBox ISO & OVF builders