私はgradleプラグインbmuschko/gradle-docker-pluginを使ってドッカーとgradleを統合しています。私はbuild.gradleファイルにいくつかのタスクを作成します。bmuschko/gradle-docker-pluginによって導入されたいくつかのケースで、gradleタスクをスキップする方法はありますか?
task copyJar(type: Copy) {
dependsOn build
from project.file("$project.buildDir/libs/" << jarName)
into project.file("$project.buildDir/docker")
}
task createDockerfile(type: Dockerfile) {
dependsOn copyJar
// Generate Dockerfile
}
task buildDockerImage(type: DockerBuildImage) {
dependsOn createDockerfile
inputDir = createDockerfile.destFile.parentFile
tag = 'example.com/' << jar.baseName
if (project.hasProperty('imageTag')) {
tag += ':' << imageTag
}
}
task pushDockerImage(type: DockerPushImage) {
dependsOn buildDockerImage
conventionMapping.imageName = { 'example.com/' + jar.baseName }
if (project.hasProperty('imageTag')) {
conventionMapping.tag = { imageTag }
}
}
私が欲しい私はgradle pushDockerImage
を実行すると、このタスクはスキップすることができ、ソースコードに変更がない場合、です。しかし、今度はgradle pushDockerImage
を実行するたびに、それが実行され、最後にドッカーレジストリに画像をプッシュするために長い時間がかかります。
Skipping task ':core/sample:buildDockerImage' as task onlyIf is false.
:core/sample:buildDockerImage SKIPPED
:core/sample:buildDockerImage (Thread[main,5,main]) completed. Took 1.765 secs.
:core/sample:pushDockerImage (Thread[main,5,main]) started.
:core/sample:pushDockerImage
Executing task ':core/sample:pushDockerImage' (up-to-date check took 0.001 secs) due to:
Task has not declared any outputs.
だからここbuildDockerImage
はスキップされますが、pushDockerImage
ではありません。
は私もgradle --info pushDockerImage
2回実行し、第二の時間のGradleは、次のINFOMATIONを示しています。私もそれをスキップすることはできますか?