Skip to content

Commit

Permalink
Merge pull request #139 from Nuvindu/clean-task
Browse files Browse the repository at this point in the history
Fix clean task for standard libraries
  • Loading branch information
Nuvindu authored Mar 11, 2024
2 parents 4adbc45 + 6171d29 commit 2447f46
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -412,27 +412,25 @@ class BallerinaPlugin implements Plugin<Project> {
}

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"
}
}

Expand Down

0 comments on commit 2447f46

Please sign in to comment.