In order for Gradle to work with Artifactory, all that is needed is a properly configured build.gradle script file.
Instead of dwelling on configuration details we will just mention the main configuration steps and show a sample Gradle script that we believe shows all the required information that's needed to get you started.
It also demonstrates the effectiveness and brevity of Gradle
For your information, this build script is used for building the Build Integration project as is also available in source control.
Resolution Configuration
Using Artifactory's Gradle Init Script Generator
With Artifactory's Gradle init script generator, you can easily create a Gradle init script that handles resolution:
Provisioning Dynamic Settings for Users
You can deploy and provision a dynamic settings template for your users.
Once downloaded, settings will be generated on the fly according to your own logic and can automatically include user authentication information.
Please see the Provisioning Build Tool Settings section under Filtered Resources.
Manual Configuration Steps
This section describes a manual integration of Gradle with Artifactory and works for Gradle 0.8. For Gradle version 0.9-preview-3 and above it is recommended to use the Gradle Artifactory Plugin for publication
Define the Artifactory repository that will be used by Gradle for artifacts resolution.
Optionally provide credentials in case you do not allow anonymous artifact downloads on the Artifactory repository.
Define the local repository in Artifactory to which module artifacts will be deployed.
Optionally provide deployment credentials.
If you would also like Gradle to auto-generate a POM file for your artifacts, define the Maven artifact attributes, and -
Define local Artifactory repository which will be used for POM deployment (typically this would be the same as the one used for Gradle/Ivy artifacts).
Sample Build Script and Properties
build.gradle
And the properties file under the same directory:
gradle.properties
Running Gradle
The following clause is needed for gradle to recognize Artifactory
To build your project and upload the generated artifacts to Artifactory, simply run:
Please refer to the Gradle documentation for more detailed information on building with Gradle (running sub-tasks etc.).
Getting Debugging Information from Gradle
If you experience problems, it is highly recommended to run Gradle with the -d option. This typically provides useful readable information on what went wrong.
Dependency Declaration Snippets
You can use the Artifactory UI to obtain dependency declaration snippets by selecting either an artifact and copying the "Gradle Dependency Declaration" section into your build.gradle file.