Enforce is a Gradle plugin, so it is required to have build.gradle file where the dependency to the Enforce plugin is defined, and makes it possible to start using Enforce features. Below you can find an example for a basic build.gradle file:
Gradle provides a dependency mechanism which allows us to download Gradle plugins and its dependencies from a Maven Repository, the first time that a task from the build.gradle is executed, Gradle will automatically download the Enforce plugin and its dependencies, which will all be stored in a cache in your machine. this mechanism avoids to download the same file more than once.
You can try executing the next command:
Enforce requires access to a Salesforce Organization, so you need to provide the credentials and Security Token for an user with System Administrator rights.
Enforce provides a task for create credentials, which are stored on your home folder and can be encrypted also.
The task will ask for the credential values to be introduced, the Id represents the key that is used to identify the credential. This way, it is possible to store credentials for several organizations but you need to keep in mind that the Id must be unique. You can find here more information about Credential Management.
The easy way to integrate Enforce with your Salesforce project source code is making the build.gradle file part of your source code. That implies moving the build.gradle file to your project folder. Now, you can configure the path of your project code on Enforce, open your build.gradle file and add the next lines at the end:
In this case, we are assuming the next folder structure for your project:
In this case, the srcPath property is pointing at the src folder, which contains the Salesforce project.
Remember that a Salesforce project is the one that contains at least an package.xml , and valid Salesforce folders like: classes, objects, etc.
By default, the srcPath property points to the build.gradle folder.
You can list the available tasks provided by Enforce executing:
Now you have a basic Gradle project (build.gradle) and you can start using all the features!