Skip to content

Commit

Permalink
Merge pull request #115 from MohamedSabthar/main
Browse files Browse the repository at this point in the history
Fix clean command falling with permission error
  • Loading branch information
MohamedSabthar authored Nov 9, 2023
2 parents 7eba13b + 5ae8d0b commit 016589f
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/main/groovy/io/ballerina/plugin/BallerinaPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,28 @@ class BallerinaPlugin implements Plugin<Project> {
}

project.tasks.register('clean', Delete.class) {
delete "$project.projectDir/target"
delete "$project.projectDir/build"
delete "$project.rootDir/target"
doLast {
if (buildOnDocker) {
project.exec {
def deleteUsingDocker = """
docker run --user root \
-v $parentDirectory:/home/ballerina/$parentDirectory.name \
-v $projectDirectory:/home/ballerina/$parentDirectory.name/$projectDirectory.name \
ballerina/ballerina:$ballerinaDockerTag \
/bin/sh -c "cd $parentDirectory.name/$projectDirectory.name && rm -rf build target"
"""
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"
}
}
}

Expand Down

0 comments on commit 016589f

Please sign in to comment.