This task is able to undeploy code from Salesforce organization. To avoid dependency problems It truncates code and it deploys code truncated as first step and then It will try to delete all code from Salesforce organization according to local code.
This class only have a parameter called excludes it can be used as task property or into your build script.
All code will be undeployed from SalesForce organization, truncating dependencies of next elements with its respective interceptors:
Note: Those interceptors by default are support on upload, deploy, update and undeploy tasks. You are able to create your custom interceptors using globalInterceptor or interceptor.
When the undeploy task is executed all interceptors by default will be executed.
To add a new global interceptor you can use globalInterceptor method in the plugin extension “enforce”, it will be visible for all tasks that using the truncated process.
enforce {
globalInterceptor('classes','printClassName', { classFile ->
println classFile.name
})
}
undeploy {
interceptors = ['printClassName']
}
update {
interceptors = ['printClassName']
}
To add a new interceptor you can use interceptor or firstInterceptor methods for each task where you want to add a new custom interceptor.
Adding a new anonymous interceptor, it will always be executed because it doesn’t have a specific name.
undeploy {
interceptor('classes', { classFile ->
println classFile.path
})
}
Adding a new custom interceptor that will execute after of all interceptors on the classes for example.
undeploy {
interceptor('classes','doLast', { classFile ->
println classFile.path
})
}
Adding a new custom interceptor that will execute before of all interceptors on the objects for example.
undeploy {
firstInterceptor('objects', 'doFirst', { objectFile ->
println objectFile.name
})
}
Note: Those interceptors have to be into build.gradle file.
This parameter can exclude files by:
$gradle truncate -Phelp
To exclude all classes.
$ gradle undeploy -Pexcludes=classes
$ gradle undeploy -Pexcludes=classes/**
$ gradle undeploy -Pexcludes=classes/*.cls
To exclude all classes all objects and all triggers.
$ gradle undeploy -Pexcludes=classes,objects,triggers
To exclude the Class1.cls
$ gradle undeploy -Pexcludes=classes/Class1.cls
To exclude Class1.cls and Trigger1.cls
$ gradle undeploy -Pexcludes=classes/Class1.cls,triggers/Trigger1.trigger
To exclude all files that contain Account word with any extension and any folders.
$ gradle undeploy -Pexcludes=**\*Account*/**
To exclude all files with .cls extension.
$ gradle undeploy -Pexcludes=**/*.cls
command:
$ gradle undeploy
output:
> gradle undeploy
:undeploy
___________________________________________
Username: john.doe@email.com
Login type: login
___________________________________________
[zip] Building zip: /user/build/deploy.zip
Starting undeploy...
[==================================================] 100%
All components truncated were successfully uploaded
[zip] Building zip: /user/build/deploy.zip
[==================================================] 100%
The files were successfully deleted
BUILD SUCCESSFUL