From 6171d29e9844f4ce164e652d10cd246c7a5e6216 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 11 Mar 2024 18:47:51 +0530 Subject: [PATCH] Fix clean task for standard libraries --- .../ballerina/plugin/BallerinaPlugin.groovy | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy index 1a82614..d9dc36b 100644 --- a/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy +++ b/src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy @@ -412,27 +412,25 @@ class BallerinaPlugin implements Plugin { } project.tasks.register('clean', Delete.class) { - doLast { - if (buildOnDocker) { - project.exec { - def deleteUsingDocker = """ - docker run -u root \ - -v $parentDirectory:/home/ballerina/$parentDirectory.name \ - ballerina/ballerina:$ballerinaDockerTag \ - /bin/sh -c "find /home/ballerina/$parentDirectory.name -type d -name 'build' -exec rm -rf {} + && find /home/ballerina/$parentDirectory.name -type d -name 'target' -exec rm -rf {} +" - """ - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine 'cmd', '/c', "$deleteUsingDocker" - } else { - commandLine 'sh', '-c', "$deleteUsingDocker" - } + if (buildOnDocker) { + project.exec { + def deleteUsingDocker = """ + docker run -u root \ + -v $parentDirectory:/home/ballerina/$parentDirectory.name \ + ballerina/ballerina:$ballerinaDockerTag \ + /bin/sh -c "find /home/ballerina/$parentDirectory.name -type d -name 'build' -exec rm -rf {} + && find /home/ballerina/$parentDirectory.name -type d -name 'target' -exec rm -rf {} +" + """ + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine 'cmd', '/c', "$deleteUsingDocker" + } else { + commandLine 'sh', '-c', "$deleteUsingDocker" } - } else { - delete "$project.projectDir/target" - delete "$project.projectDir/build" } - delete "$project.rootDir/target" + } else { + delete "$project.projectDir/target" + delete "$project.projectDir/build" } + delete "$project.rootDir/target" } }